diff --git a/src/estimator/global_metric.jl b/src/estimator/global_metric.jl index b9e817f..ac81d2d 100644 --- a/src/estimator/global_metric.jl +++ b/src/estimator/global_metric.jl @@ -5,40 +5,40 @@ Representation of a [`DAG`](@ref)'s cost as estimated by the [`GlobalMetricEstim # Fields: `.data`: The total data transfer.\\ -`.computeEffort`: The total compute effort.\\ -`.computeIntensity`: The compute intensity, will always equal `.computeEffort / .data`. +`.compute_effort`: The total compute effort.\\ +`.compute_intensity`: The compute intensity, will always equal `.compute_effort / .data`. !!! note - Note that the `computeIntensity` doesn't necessarily make sense in the context of only operation costs. + Note that the `compute_intensity` doesn't necessarily make sense in the context of only operation costs. It will still work as intended when adding/subtracting to/from a `graph_cost` estimate. """ const CDCost = NamedTuple{ - (:data, :computeEffort, :computeIntensity),Tuple{Float64,Float64,Float64} + (:data, :compute_effort, :compute_intensity),Tuple{Float64,Float64,Float64} } function Base.:+(cost1::CDCost, cost2::CDCost)::CDCost d = cost1.data + cost2.data - ce = computeEffort = cost1.computeEffort + cost2.computeEffort - return (data=d, computeEffort=ce, computeIntensity=ce / d)::CDCost + ce = compute_effort = cost1.compute_effort + cost2.compute_effort + return (data=d, compute_effort=ce, compute_intensity=ce / d)::CDCost end function Base.:-(cost1::CDCost, cost2::CDCost)::CDCost d = cost1.data - cost2.data - ce = computeEffort = cost1.computeEffort - cost2.computeEffort - return (data=d, computeEffort=ce, computeIntensity=ce / d)::CDCost + ce = compute_effort = cost1.compute_effort - cost2.compute_effort + return (data=d, compute_effort=ce, compute_intensity=ce / d)::CDCost end function Base.isless(cost1::CDCost, cost2::CDCost)::Bool - return cost1.data + cost1.computeEffort < cost2.data + cost2.computeEffort + return cost1.data + cost1.compute_effort < cost2.data + cost2.compute_effort end function Base.zero(type::Type{CDCost}) - return (data=0.0, computeEffort=0.0, computeIntensity=0.0)::CDCost + return (data=0.0, compute_effort=0.0, compute_intensity=0.0)::CDCost end function Base.typemax(type::Type{CDCost}) - return (data=Inf, computeEffort=Inf, computeIntensity=0.0)::CDCost + return (data=Inf, compute_effort=Inf, compute_intensity=0.0)::CDCost end """ @@ -56,8 +56,8 @@ function graph_cost(estimator::GlobalMetricEstimator, graph::DAG) properties = get_properties(graph) return ( data=properties.data, - computeEffort=properties.computeEffort, - computeIntensity=properties.computeIntensity, + compute_effort=properties.compute_effort, + compute_intensity=properties.compute_intensity, )::CDCost end @@ -67,8 +67,8 @@ function operation_effect( s = length(operation.input) - 1 return ( data=s * -data(task(operation.input[1])), - computeEffort=s * -compute_effort(task(operation.input[1])), - computeIntensity=typeof(operation.input) <: DataTaskNode ? 0.0 : Inf, + compute_effort=s * -compute_effort(task(operation.input[1])), + compute_intensity=typeof(operation.input) <: DataTaskNode ? 0.0 : Inf, )::CDCost end @@ -78,7 +78,7 @@ function operation_effect( s::Float64 = length(parents(operation.input)) - 1 d::Float64 = s * data(task(operation.input)) ce::Float64 = s * compute_effort(task(operation.input)) - return (data=d, computeEffort=ce, computeIntensity=ce / d)::CDCost + return (data=d, compute_effort=ce, compute_intensity=ce / d)::CDCost end function String(::GlobalMetricEstimator) diff --git a/src/graph/interface.jl b/src/graph/interface.jl index 0fa74cc..97d092d 100644 --- a/src/graph/interface.jl +++ b/src/graph/interface.jl @@ -7,7 +7,7 @@ See also: [`DAG`](@ref), [`pop_operation!`](@ref) """ function push_operation!(graph::DAG, operation::Operation) # 1.: Add the operation to the DAG - push!(graph.operationsToApply, operation) + push!(graph.operations_to_apply, operation) return nothing end @@ -21,10 +21,10 @@ See also: [`DAG`](@ref), [`push_operation!`](@ref) """ function pop_operation!(graph::DAG) # 1.: Remove the operation from the appliedChain of the DAG - if !isempty(graph.operationsToApply) - pop!(graph.operationsToApply) - elseif !isempty(graph.appliedOperations) - appliedOp = pop!(graph.appliedOperations) + if !isempty(graph.operations_to_apply) + pop!(graph.operations_to_apply) + elseif !isempty(graph.applied_operations) + appliedOp = pop!(graph.applied_operations) revert_operation!(graph, appliedOp) else error("No more operations to pop!") @@ -38,7 +38,8 @@ end Return `true` if [`pop_operation!`](@ref) is possible, `false` otherwise. """ -can_pop(graph::DAG) = !isempty(graph.operationsToApply) || !isempty(graph.appliedOperations) +can_pop(graph::DAG) = + !isempty(graph.operations_to_apply) || !isempty(graph.applied_operations) """ reset_graph!(graph::DAG) diff --git a/src/graph/mute.jl b/src/graph/mute.jl index f927967..4dbe93d 100644 --- a/src/graph/mute.jl +++ b/src/graph/mute.jl @@ -56,7 +56,7 @@ function _insert_node!(graph::DAG, node::Node; track=true, invalidate_cache=true if (!invalidate_cache) return node end - push!(graph.dirtyNodes, node) + push!(graph.dirty_nodes, node) return node end @@ -110,8 +110,8 @@ function _insert_edge!( invalidate_operation_caches!(graph, node1) invalidate_operation_caches!(graph, node2) - push!(graph.dirtyNodes, node1) - push!(graph.dirtyNodes, node2) + push!(graph.dirty_nodes, node1) + push!(graph.dirty_nodes, node2) return nothing end @@ -145,7 +145,7 @@ function _remove_node!(graph::DAG, node::Node; track=true, invalidate_cache=true end invalidate_operation_caches!(graph, node) - delete!(graph.dirtyNodes, node) + delete!(graph.dirty_nodes, node) return nothing end @@ -207,10 +207,10 @@ function _remove_edge!( invalidate_operation_caches!(graph, node1) invalidate_operation_caches!(graph, node2) if (node1 in graph) - push!(graph.dirtyNodes, node1) + push!(graph.dirty_nodes, node1) end if (node2 in graph) - push!(graph.dirtyNodes, node2) + push!(graph.dirty_nodes, node2) end return removed_node_index @@ -235,7 +235,7 @@ Invalidate the operation caches for a given [`NodeReduction`](@ref). This deletes the operation from the graph's possible operations and from the involved nodes' own operation caches. """ function invalidate_caches!(graph::DAG, operation::NodeReduction) - delete!(graph.possibleOperations, operation) + delete!(graph.possible_operations, operation) for node in operation.input node.nodeReduction = missing @@ -252,7 +252,7 @@ Invalidate the operation caches for a given [`NodeSplit`](@ref). This deletes the operation from the graph's possible operations and from the involved nodes' own operation caches. """ function invalidate_caches!(graph::DAG, operation::NodeSplit) - delete!(graph.possibleOperations, operation) + delete!(graph.possible_operations, operation) # delete the operation from all caches of nodes involved in the operation # for node split there is only one node diff --git a/src/graph/print.jl b/src/graph/print.jl index 118679c..d1fc5af 100644 --- a/src/graph/print.jl +++ b/src/graph/print.jl @@ -28,14 +28,14 @@ function Base.show(io::IO, graph::DAG) print(io, " Nodes: ") nodeDict = Dict{Type,Int64}() - noEdges = 0 + number_of_edges = 0 for node in graph.nodes if haskey(nodeDict, typeof(task(node))) nodeDict[typeof(task(node))] = nodeDict[typeof(task(node))] + 1 else nodeDict[typeof(task(node))] = 1 end - noEdges += length(parents(node)) + number_of_edges += length(parents(node)) end if length(graph.nodes) <= 20 @@ -58,9 +58,9 @@ function Base.show(io::IO, graph::DAG) end end println(io) - println(io, " Edges: ", noEdges) + println(io, " Edges: ", number_of_edges) properties = get_properties(graph) - println(io, " Total Compute Effort: ", properties.computeEffort) + println(io, " Total Compute Effort: ", properties.compute_effort) println(io, " Total Data Transfer: ", properties.data) - return println(io, " Total Compute Intensity: ", properties.computeIntensity) + return println(io, " Total Compute Intensity: ", properties.compute_intensity) end diff --git a/src/graph/properties.jl b/src/graph/properties.jl index 9515820..0f52b12 100644 --- a/src/graph/properties.jl +++ b/src/graph/properties.jl @@ -8,7 +8,7 @@ function get_properties(graph::DAG) apply_all!(graph) # TODO: tests stop working without the if condition, which means there is probably a bug in the lazy evaluation and in the tests - if (graph.properties.computeEffort <= 0.0) + if (graph.properties.compute_effort <= 0.0) graph.properties = GraphProperties(graph) end @@ -51,5 +51,5 @@ end Return the number of operations applied to the graph. """ function operation_stack_length(graph::DAG) - return length(graph.appliedOperations) + length(graph.operationsToApply) + return length(graph.applied_operations) + length(graph.operations_to_apply) end diff --git a/src/graph/type.jl b/src/graph/type.jl index b5ceeb4..a5f8715 100644 --- a/src/graph/type.jl +++ b/src/graph/type.jl @@ -7,8 +7,8 @@ A struct storing all possible operations on a [`DAG`](@ref). To get the [`PossibleOperations`](@ref) on a [`DAG`](@ref), use [`get_operations`](@ref). """ mutable struct PossibleOperations - nodeReductions::Set{NodeReduction} - nodeSplits::Set{NodeSplit} + node_reductions::Set{NodeReduction} + node_splits::Set{NodeSplit} end """ @@ -24,16 +24,16 @@ mutable struct DAG nodes::Set{Union{DataTaskNode,ComputeTaskNode}} # The operations currently applied to the set of nodes - appliedOperations::Stack{AppliedOperation} + applied_operations::Stack{AppliedOperation} # The operations not currently applied but part of the current state of the DAG - operationsToApply::Deque{Operation} + operations_to_apply::Deque{Operation} # The possible operations at the current state of the DAG - possibleOperations::PossibleOperations + possible_operations::PossibleOperations # The set of nodes whose possible operations need to be reevaluated - dirtyNodes::Set{Union{DataTaskNode,ComputeTaskNode}} + dirty_nodes::Set{Union{DataTaskNode,ComputeTaskNode}} # "snapshot" system: keep track of added/removed nodes/edges since last snapshot # these are muted in insert_node! etc. diff --git a/src/graph/validate.jl b/src/graph/validate.jl index ad95d19..9caef4b 100644 --- a/src/graph/validate.jl +++ b/src/graph/validate.jl @@ -30,18 +30,18 @@ function is_valid(graph::DAG) @assert is_valid(graph, node) end - for op in graph.operationsToApply + for op in graph.operations_to_apply @assert is_valid(graph, op) end - for nr in graph.possibleOperations.nodeReductions + for nr in graph.possible_operations.node_reductions @assert is_valid(graph, nr) end - for ns in graph.possibleOperations.nodeSplits + for ns in graph.possible_operations.node_splits @assert is_valid(graph, ns) end - for node in graph.dirtyNodes + for node in graph.dirty_nodes @assert node in graph "Dirty Node is not part of the graph!" @assert ismissing(node.nodeReduction) "Dirty Node has a NodeReduction!" @assert ismissing(node.nodeSplit) "Dirty Node has a NodeSplit!" diff --git a/src/operation/apply.jl b/src/operation/apply.jl index 0de5eea..99dce26 100644 --- a/src/operation/apply.jl +++ b/src/operation/apply.jl @@ -4,15 +4,15 @@ Apply all unapplied operations in the DAG. Is automatically called in all functions that require the latest state of the [`DAG`](@ref). """ function apply_all!(graph::DAG) - while !isempty(graph.operationsToApply) + while !isempty(graph.operations_to_apply) # get next operation to apply from front of the deque - op = popfirst!(graph.operationsToApply) + op = popfirst!(graph.operations_to_apply) # apply it appliedOp = apply_operation!(graph, op) - # push to the end of the appliedOperations deque - push!(graph.appliedOperations, appliedOp) + # push to the end of the applied_operations deque + push!(graph.applied_operations, appliedOp) end return nothing end diff --git a/src/operation/clean.jl b/src/operation/clean.jl index eec9d3f..9e0b997 100644 --- a/src/operation/clean.jl +++ b/src/operation/clean.jl @@ -30,11 +30,11 @@ function find_reductions!(graph::DAG, node::Node) if reductionVector !== nothing nr = NodeReduction(reductionVector) - push!(graph.possibleOperations.nodeReductions, nr) + push!(graph.possible_operations.node_reductions, nr) for node in reductionVector if !ismissing(node.nodeReduction) # it can happen that the dirty node becomes part of an existing NodeReduction and overrides those ones now - # this is only a problem insofar the existing NodeReduction has to be deleted and replaced also in the possibleOperations + # this is only a problem insofar the existing NodeReduction has to be deleted and replaced also in the possible_operations invalidate_caches!(graph, node.nodeReduction) end node.nodeReduction = nr @@ -56,7 +56,7 @@ function find_splits!(graph::DAG, node::Node) if (can_split(node)) ns = NodeSplit(node) - push!(graph.possibleOperations.nodeSplits, ns) + push!(graph.possible_operations.node_splits, ns) node.nodeSplit = ns end diff --git a/src/operation/find.jl b/src/operation/find.jl index 6179cec..20e9a2c 100644 --- a/src/operation/find.jl +++ b/src/operation/find.jl @@ -25,25 +25,25 @@ function insert_operation!(ns::NodeSplit) end """ - nr_insertion!(operations::PossibleOperations, nodeReductions::Vector{Vector{NodeReduction}}) + nr_insertion!(operations::PossibleOperations, node_reductions::Vector{Vector{NodeReduction}}) Insert the node reductions into the graph and the nodes' caches. Employs multithreading for speedup. """ function nr_insertion!( - operations::PossibleOperations, nodeReductions::Vector{Vector{NodeReduction}} + operations::PossibleOperations, node_reductions::Vector{Vector{NodeReduction}} ) total_len = 0 - for vec in nodeReductions + for vec in node_reductions total_len += length(vec) end - sizehint!(operations.nodeReductions, total_len) + sizehint!(operations.node_reductions, total_len) - t = @task for vec in nodeReductions - union!(operations.nodeReductions, Set(vec)) + t = @task for vec in node_reductions + union!(operations.node_reductions, Set(vec)) end schedule(t) - @threads for vec in nodeReductions + @threads for vec in node_reductions for op in vec insert_operation!(op) end @@ -55,25 +55,25 @@ function nr_insertion!( end """ - ns_insertion!(operations::PossibleOperations, nodeSplits::Vector{Vector{NodeSplits}}) + ns_insertion!(operations::PossibleOperations, node_splits::Vector{Vector{NodeSplits}}) Insert the node splits into the graph and the nodes' caches. Employs multithreading for speedup. """ function ns_insertion!( - operations::PossibleOperations, nodeSplits::Vector{Vector{NodeSplit}} + operations::PossibleOperations, node_splits::Vector{Vector{NodeSplit}} ) total_len = 0 - for vec in nodeSplits + for vec in node_splits total_len += length(vec) end - sizehint!(operations.nodeSplits, total_len) + sizehint!(operations.node_splits, total_len) - t = @task for vec in nodeSplits - union!(operations.nodeSplits, Set(vec)) + t = @task for vec in node_splits + union!(operations.node_splits, Set(vec)) end schedule(t) - @threads for vec in nodeSplits + @threads for vec in node_splits for op in vec insert_operation!(op) end @@ -124,11 +124,11 @@ function generate_operations(graph::DAG) insert!(trie, candidate) end - nodeReductions = collect(trie) + node_reductions = collect(trie) - for nrVec in nodeReductions + for nrVec in node_reductions # parent sets are ordered and any node can only be part of one nodeReduction, so a NodeReduction is uniquely identifiable by its first element - # this prevents duplicate nodeReductions being generated + # this prevents duplicate node_reductions being generated lock(checkedNodesLock) if (nrVec[1] in checkedNodes) unlock(checkedNodesLock) @@ -144,7 +144,7 @@ function generate_operations(graph::DAG) # launch thread for node reduction insertion # remove duplicates - nr_task = @spawn nr_insertion!(graph.possibleOperations, generatedReductions) + nr_task = @spawn nr_insertion!(graph.possible_operations, generatedReductions) # find possible node splits @threads for node in nodeArray @@ -154,9 +154,9 @@ function generate_operations(graph::DAG) end # launch thread for node split insertion - ns_task = @spawn ns_insertion!(graph.possibleOperations, generatedSplits) + ns_task = @spawn ns_insertion!(graph.possible_operations, generatedSplits) - empty!(graph.dirtyNodes) + empty!(graph.dirty_nodes) wait(nr_task) wait(ns_task) diff --git a/src/operation/get.jl b/src/operation/get.jl index 3294459..ff13398 100644 --- a/src/operation/get.jl +++ b/src/operation/get.jl @@ -10,12 +10,12 @@ Return the [`PossibleOperations`](@ref) of the graph at the current state. function get_operations(graph::DAG) apply_all!(graph) - if isempty(graph.possibleOperations) + if isempty(graph.possible_operations) generate_operations(graph) end - clean_node!.(Ref(graph), graph.dirtyNodes) - empty!(graph.dirtyNodes) + clean_node!.(Ref(graph), graph.dirty_nodes) + empty!(graph.dirty_nodes) - return graph.possibleOperations + return graph.possible_operations end diff --git a/src/operation/iterate.jl b/src/operation/iterate.jl index 1a9ece4..4eb6727 100644 --- a/src/operation/iterate.jl +++ b/src/operation/iterate.jl @@ -5,10 +5,10 @@ _POIteratorStateType = NamedTuple{ } @inline function Base.iterate( - possibleOperations::PossibleOperations + possible_operations::PossibleOperations )::Union{Nothing,_POIteratorStateType} for fieldname in _POSSIBLE_OPERATIONS_FIELDS - iterator = iterate(getfield(possibleOperations, fieldname)) + iterator = iterate(getfield(possible_operations, fieldname)) if (!isnothing(iterator)) return (result=iterator[1], state=(fieldname, iterator[2])) end @@ -18,10 +18,10 @@ _POIteratorStateType = NamedTuple{ end @inline function Base.iterate( - possibleOperations::PossibleOperations, state + possible_operations::PossibleOperations, state )::Union{Nothing,_POIteratorStateType} newStateSym = state[1] - newStateIt = iterate(getfield(possibleOperations, newStateSym), state[2]) + newStateIt = iterate(getfield(possible_operations, newStateSym), state[2]) if !isnothing(newStateIt) return (result=newStateIt[1], state=(newStateSym, newStateIt[2])) end @@ -31,7 +31,7 @@ end while index <= length(_POSSIBLE_OPERATIONS_FIELDS) newStateSym = _POSSIBLE_OPERATIONS_FIELDS[index] - newStateIt = iterate(getfield(possibleOperations, newStateSym)) + newStateIt = iterate(getfield(possible_operations, newStateSym)) if !isnothing(newStateIt) return (result=newStateIt[1], state=(newStateSym, newStateIt[2])) end diff --git a/src/operation/print.jl b/src/operation/print.jl index 274531a..400e32d 100644 --- a/src/operation/print.jl +++ b/src/operation/print.jl @@ -4,14 +4,14 @@ Print a string representation of the set of possible operations to io. """ function Base.show(io::IO, ops::PossibleOperations) - print(io, length(ops.nodeReductions)) + print(io, length(ops.node_reductions)) println(io, " Node Reductions: ") - for nr in ops.nodeReductions + for nr in ops.node_reductions println(io, " - ", nr) end - print(io, length(ops.nodeSplits)) + print(io, length(ops.node_splits)) println(io, " Node Splits: ") - for ns in ops.nodeSplits + for ns in ops.node_splits println(io, " - ", ns) end end diff --git a/src/operation/utility.jl b/src/operation/utility.jl index 0424798..263c926 100644 --- a/src/operation/utility.jl +++ b/src/operation/utility.jl @@ -4,7 +4,7 @@ Return whether `operations` is empty, i.e. all of its fields are empty. """ function Base.isempty(operations::PossibleOperations) - return isempty(operations.nodeReductions) && isempty(operations.nodeSplits) + return isempty(operations.node_reductions) && isempty(operations.node_splits) end """ @@ -14,8 +14,8 @@ Return a named tuple with the number of each of the operation types as a named t """ function Base.length(operations::PossibleOperations) return ( - nodeReductions=length(operations.nodeReductions), - nodeSplits=length(operations.nodeSplits), + node_reductions=length(operations.node_reductions), + node_splits=length(operations.node_splits), ) end @@ -25,7 +25,7 @@ end Delete the given node reduction from the possible operations. """ function Base.delete!(operations::PossibleOperations, op::NodeReduction) - delete!(operations.nodeReductions, op) + delete!(operations.node_reductions, op) return operations end @@ -35,7 +35,7 @@ end Delete the given node split from the possible operations. """ function Base.delete!(operations::PossibleOperations, op::NodeSplit) - delete!(operations.nodeSplits, op) + delete!(operations.node_splits, op) return operations end diff --git a/src/optimization/random_walk.jl b/src/optimization/random_walk.jl index 62d02c2..ab381a7 100644 --- a/src/optimization/random_walk.jl +++ b/src/optimization/random_walk.jl @@ -15,7 +15,7 @@ function optimize_step!(optimizer::RandomWalkOptimizer, graph::DAG) operations = get_operations(graph) if sum(length(operations)) == 0 && - length(graph.appliedOperations) + length(graph.operationsToApply) == 0 + length(graph.applied_operations) + length(graph.operations_to_apply) == 0 # in case there are zero operations possible at all on the graph return false end @@ -29,11 +29,11 @@ function optimize_step!(optimizer::RandomWalkOptimizer, graph::DAG) # choose one of split/reduce option = rand(r, 1:2) - if option == 1 && !isempty(operations.nodeReductions) - push_operation!(graph, rand(r, collect(operations.nodeReductions))) + if option == 1 && !isempty(operations.node_reductions) + push_operation!(graph, rand(r, collect(operations.node_reductions))) return true - elseif option == 2 && !isempty(operations.nodeSplits) - push_operation!(graph, rand(r, collect(operations.nodeSplits))) + elseif option == 2 && !isempty(operations.node_splits) + push_operation!(graph, rand(r, collect(operations.node_splits))) return true end else diff --git a/src/optimization/reduce.jl b/src/optimization/reduce.jl index edd49d2..36bdb0e 100644 --- a/src/optimization/reduce.jl +++ b/src/optimization/reduce.jl @@ -14,14 +14,14 @@ function optimize_step!(optimizer::ReductionOptimizer, graph::DAG) return false end - push_operation!(graph, first(operations.nodeReductions)) + push_operation!(graph, first(operations.node_reductions)) return true end function fixpoint_reached(optimizer::ReductionOptimizer, graph::DAG) operations = get_operations(graph) - return isempty(operations.nodeReductions) + return isempty(operations.node_reductions) end function optimize_to_fixpoint!(optimizer::ReductionOptimizer, graph::DAG) diff --git a/src/optimization/split.jl b/src/optimization/split.jl index 0d38dae..b610494 100644 --- a/src/optimization/split.jl +++ b/src/optimization/split.jl @@ -14,14 +14,14 @@ function optimize_step!(optimizer::SplitOptimizer, graph::DAG) return false end - push_operation!(graph, first(operations.nodeSplits)) + push_operation!(graph, first(operations.node_splits)) return true end function fixpoint_reached(optimizer::SplitOptimizer, graph::DAG) operations = get_operations(graph) - return isempty(operations.nodeSplits) + return isempty(operations.node_splits) end function optimize_to_fixpoint!(optimizer::SplitOptimizer, graph::DAG) diff --git a/src/properties/create.jl b/src/properties/create.jl index 72f7b9a..5d0de61 100644 --- a/src/properties/create.jl +++ b/src/properties/create.jl @@ -5,7 +5,11 @@ Create an empty [`GraphProperties`](@ref) object. """ function GraphProperties() return ( - data=0.0, computeEffort=0.0, computeIntensity=0.0, noNodes=0, noEdges=0 + data=0.0, + compute_effort=0.0, + compute_intensity=0.0, + number_of_nodes=0, + number_of_edges=0, )::GraphProperties end @@ -41,10 +45,10 @@ function GraphProperties(graph::DAG) return ( data=d, - computeEffort=ce, - computeIntensity=(d == 0) ? 0.0 : ce / d, - noNodes=length(graph.nodes), - noEdges=ed, + compute_effort=ce, + compute_intensity=(d == 0) ? 0.0 : ce / d, + number_of_nodes=length(graph.nodes), + number_of_edges=ed, )::GraphProperties end @@ -66,9 +70,9 @@ function GraphProperties(diff::Diff) return ( data=d, - computeEffort=ce, - computeIntensity=(d == 0) ? 0.0 : ce / d, - noNodes=length(diff.addedNodes) - length(diff.removedNodes), - noEdges=length(diff.addedEdges) - length(diff.removedEdges), + compute_effort=ce, + compute_intensity=(d == 0) ? 0.0 : ce / d, + number_of_nodes=length(diff.addedNodes) - length(diff.removedNodes), + number_of_edges=length(diff.addedEdges) - length(diff.removedEdges), )::GraphProperties end diff --git a/src/properties/type.jl b/src/properties/type.jl index 9fea9c6..7f7e001 100644 --- a/src/properties/type.jl +++ b/src/properties/type.jl @@ -5,12 +5,12 @@ Representation of a [`DAG`](@ref)'s properties. # Fields: `.data`: The total data transfer.\\ -`.computeEffort`: The total compute effort.\\ -`.computeIntensity`: The compute intensity, will always equal `.computeEffort / .data`.\\ -`.noNodes`: Number of [`Node`](@ref)s.\\ -`.noEdges`: Number of [`Edge`](@ref)s. +`.compute_effort`: The total compute effort.\\ +`.compute_intensity`: The compute intensity, will always equal `.compute_effort / .data`.\\ +`.number_of_nodes`: Number of [`Node`](@ref)s.\\ +`.number_of_edges`: Number of [`Edge`](@ref)s. """ const GraphProperties = NamedTuple{ - (:data, :computeEffort, :computeIntensity, :noNodes, :noEdges), + (:data, :compute_effort, :compute_intensity, :number_of_nodes, :number_of_edges), Tuple{Float64,Float64,Float64,Int,Int}, } diff --git a/src/properties/utility.jl b/src/properties/utility.jl index 1760d2a..ceddc76 100644 --- a/src/properties/utility.jl +++ b/src/properties/utility.jl @@ -7,14 +7,14 @@ Also take care to keep consistent compute intensity. function Base.:-(prop1::GraphProperties, prop2::GraphProperties) return ( data=prop1.data - prop2.data, - computeEffort=prop1.computeEffort - prop2.computeEffort, - computeIntensity=if (prop1.data - prop2.data == 0) + compute_effort=prop1.compute_effort - prop2.compute_effort, + compute_intensity=if (prop1.data - prop2.data == 0) 0.0 else - (prop1.computeEffort - prop2.computeEffort) / (prop1.data - prop2.data) + (prop1.compute_effort - prop2.compute_effort) / (prop1.data - prop2.data) end, - noNodes=prop1.noNodes - prop2.noNodes, - noEdges=prop1.noEdges - prop2.noEdges, + number_of_nodes=prop1.number_of_nodes - prop2.number_of_nodes, + number_of_edges=prop1.number_of_edges - prop2.number_of_edges, )::GraphProperties end @@ -27,28 +27,28 @@ Also take care to keep consistent compute intensity. function Base.:+(prop1::GraphProperties, prop2::GraphProperties) return ( data=prop1.data + prop2.data, - computeEffort=prop1.computeEffort + prop2.computeEffort, - computeIntensity=if (prop1.data + prop2.data == 0) + compute_effort=prop1.compute_effort + prop2.compute_effort, + compute_intensity=if (prop1.data + prop2.data == 0) 0.0 else - (prop1.computeEffort + prop2.computeEffort) / (prop1.data + prop2.data) + (prop1.compute_effort + prop2.compute_effort) / (prop1.data + prop2.data) end, - noNodes=prop1.noNodes + prop2.noNodes, - noEdges=prop1.noEdges + prop2.noEdges, + number_of_nodes=prop1.number_of_nodes + prop2.number_of_nodes, + number_of_edges=prop1.number_of_edges + prop2.number_of_edges, )::GraphProperties end """ -(prop::GraphProperties) -Unary negation of the graph properties. `.computeIntensity` will not be negated because `.data` and `.computeEffort` both are. +Unary negation of the graph properties. `.compute_intensity` will not be negated because `.data` and `.compute_effort` both are. """ function Base.:-(prop::GraphProperties) return ( data=-prop.data, - computeEffort=-prop.computeEffort, - computeIntensity=prop.computeIntensity, # no negation here! - noNodes=-prop.noNodes, - noEdges=-prop.noEdges, + compute_effort=-prop.compute_effort, + compute_intensity=prop.compute_intensity, # no negation here! + number_of_nodes=-prop.number_of_nodes, + number_of_edges=-prop.number_of_edges, )::GraphProperties end diff --git a/src/utils.jl b/src/utils.jl index d320ea5..b8593e0 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -72,18 +72,18 @@ function mem(graph::DAG) size += mem(n) end - size += sizeof(graph.appliedOperations) - size += sizeof(graph.operationsToApply) + size += sizeof(graph.applied_operations) + size += sizeof(graph.operations_to_apply) - size += sizeof(graph.possibleOperations) - for op in graph.possibleOperations.nodeReductions + size += sizeof(graph.possible_operations) + for op in graph.possible_operations.node_reductions size += mem(op) end - for op in graph.possibleOperations.nodeSplits + for op in graph.possible_operations.node_splits size += mem(op) end - size += Base.summarysize(graph.dirtyNodes; exclude=Union{Node}) + size += Base.summarysize(graph.dirty_nodes; exclude=Union{Node}) return size += sizeof(diff) end diff --git a/test/strassen_test.jl b/test/strassen_test.jl index e67491e..61c927d 100644 --- a/test/strassen_test.jl +++ b/test/strassen_test.jl @@ -38,8 +38,8 @@ EDGE_NUMBERS = (3, 96, 747, 5304) #, 37203 @test get_exit_node(g) isa DataTaskNode props = get_properties(g) - @test NODE_NUM_EXPECTED == props.noNodes - @test EDGE_NUM_EXPECTED == props.noEdges + @test NODE_NUM_EXPECTED == props.number_of_nodes + @test EDGE_NUM_EXPECTED == props.number_of_edges end f = get_compute_function(g, mm, cpu_st(), @__MODULE__)