Utility
Helper Functions
ComputableDAGs._lt_node_tuples
— Method_lt_node_tuples(n1::Tuple{Node, Int}, n2::Tuple{Node, Int})
Less-Than comparison between nodes with indices.
ComputableDAGs._lt_nodes
— Method_lt_nodes(n1::Node, n2::Node)
Less-Than comparison between nodes. Uses the nodes' ids to sort.
ComputableDAGs.bytes_to_human_readable
— Methodbytes_to_human_readable(bytes)
Return a human readable string representation of the given number.
julia> using ComputableDAGs
julia> ComputableDAGs.bytes_to_human_readable(4096)
"4.0 KiB"
ComputableDAGs.infer_types!
— Methodinfer_types!(schedule::Vector{FunctionCall})
Infer the result type of each function call in the given schedule. Returns a dictionary with the result type for each Node
. This assumes that each node has only one statically inferrable return type and will throw an exceptin otherwise. This also assumes that the given Vector
contains a topological ordering of its nodes, such as returned by a call to schedule_dag
.
ComputableDAGs.lower
— Methodlower(schedule::Vector{Node}, machine::Machine)
After schedule_dag
has made a schedule of nodes, this function lowers the vector of Node
s into a vector of FunctionCall
s.
ComputableDAGs.mem
— Methodmem(graph::DAG)
Return the memory footprint of the graph in Byte. Should be the same result as Base.summarysize(graph)
but a lot faster.
ComputableDAGs.mem
— Methodmem(op::Operation)
Return the memory footprint of the node in Byte. Used in mem(graph::DAG)
. Unlike Base.summarysize()
this doesn't follow all references which would yield (almost) the size of the entire graph.
ComputableDAGs.mem
— Methodmem(op::Operation)
Return the memory footprint of the operation in Byte. Used in mem(graph::DAG)
. Unlike Base.summarysize()
this doesn't follow all references which would yield (almost) the size of the entire graph.
ComputableDAGs.noop
— Methodnoop()
Function with no arguments, returns nothing, does nothing. Useful for noop FunctionCall
s.
ComputableDAGs.sort_node!
— Methodsort_node!(node::Node)
Sort the nodes' parents and children vectors. The vectors are mostly very short so sorting does not take a lot of time. Sorted nodes are required to make the finding of NodeReduction
s a lot faster using the NodeTrie
data structure.
ComputableDAGs.unpack_identity
— Methodunpack_identity(x::SVector)
Function taking an SVector
, returning it unpacked.
ComputableDAGs.unroll_symbol_vector
— Methodunroll_symbol_vector(vec::Vector{Symbol})
Return the given vector as single String without quotation marks or brackets.
Trie Helper
This is a simple implementation of a Trie Data Structure to greatly improve the performance of the Node Reduction search.
ComputableDAGs.NodeIdTrie
— TypeNodeIdTrie
Helper struct for NodeTrie
. After the Trie's first level, every Trie level contains the vector of nodes that had children up to that level, and the TrieNode's children by UUID of the node's children.
ComputableDAGs.NodeIdTrie
— MethodNodeIdTrie()
Constructor for an empty NodeIdTrie
.
ComputableDAGs.NodeTrie
— TypeNodeTrie
Trie data structure for node reduction, inserts nodes by children. Assumes that given nodes have ordered vectors of children (see sort_node!
). First insertion level is the node's own task type and thus does not have a value (every node has a task type).
ComputableDAGs.NodeTrie
— MethodNodeTrie()
Constructor for an empty NodeTrie
.
Base.collect
— Methodcollect(trie::NodeTrie)
Return all sets of at least 2 Node
s that have accumulated in leaves of the trie.
Base.insert!
— Methodinsert!(trie::NodeTrie, node::Node)
Insert the given node into the trie. It's sorted by its type in the first layer, then by its children in the following layers.
ComputableDAGs.collect_helper
— Methodcollect_helper(trie::NodeIdTrie, acc::Set{Vector{Node}})
Collects the Vectors of this NodeIdTrie
node and all its children and puts them in the acc
argument.
ComputableDAGs.insert_helper!
— Methodinsert_helper!(trie::NodeIdTrie, node::Node, depth::Int)
Insert the given node into the trie. The depth is used to iterate through the trie layers, while the function calls itself recursively until it ran through all children of the node.