Code generation and efficiency
While the graph can be evaluated with eval_graph, the ideal way to utilize a good graph is to produce efficient code. Currently code generation to Julia, Matlab, and C is supported.
Improving graph topology
The Compgraph is a general framework, and sometimes the topology can be improved. This is especially important before code generation.
GraphMatFun.compress_graph! — Functioncompress_graph!(graph,cref=[];verbose=false)Searches for nodes which can be removed or reorganized without changing the function it represents. Corresponding references in the cref-vector are removed.
Missing docstring for compress_graph_output_cleaning!. Check Documenter's build log for details.
GraphMatFun.compress_graph_dangling! — Functioncompress_graph_dangling!(graph,cref=[];verbose=false)Removes dangling nodes in the graph. If a node is not used anywhere and it is not in the output, it can safely be removed.
GraphMatFun.compress_graph_redundant! — Functioncompress_graph_redundant!(
graph,
cref = [];
compress_lincomb = true,
verbose = false,
)Removes from the graph redundant nodes, that is, nodes that repeat a computation that is already present in the graph. Nodes corresponding to a linear combination are removed only if the coefficients are the same and compress_lincomb is set to true.
GraphMatFun.compress_graph_trivial! — Functioncompress_graph_trivial!(graph,cref=[];verbose=false)Removes from graph the following operations I\B -> B IB -> B BI -> B
GraphMatFun.compress_graph_zero_coeff! — Functioncompress_graph_zero_coeff!(graph,cref=[];droptol=0;verbose=false)Searches for linear combinations with zero coeff and removes those. The cref list deletes references to zero coeffs and updates all other crefs.
GraphMatFun.compress_graph_passthrough! — Functioncompress_graph_passthrough!(graph,cref=[];verbose=false);Identifies lincombs of length one with coeff equal to one. The node has no effect and is redirected appropriately.
Missing docstring for extract_sums. Check Documenter's build log for details.
GraphMatFun.has_trivial_nodes — Functionhas_trivial_node(graph) -> BoolChecks whether the graph has trivial nodes, that is, multiplications by the identity or linear systems whose coefficient is the identity matrix.
GraphMatFun.has_identity_lincomb — Functionhas_identity_lincomb(graph) -> BoolChecks whether the graph has a node which is a linear combination of identity matrices.
Code generation
GraphMatFun.gen_code — Functiongen_code(
fname,
graph;
priohelp = Dict{Symbol,Float64}(),
lang = LangJulia(),
funname = "dummy",
precomputed_nodes = [:A],
)Generates the code for the graph in the language specified in lang and writes it into the file fname. The string funname is the function name. Topological order of the nodes is comptued using get_topo_order and priohelp can be used to influence the order. The nodes listed in precomputed_nodes are viewed as inputs, and code to compute these nodes are not computed.
Currently supported languages: LangC_MKL, LangC_OpenBLAS, LangJulia, LangMatlab.
GraphMatFun.LangJulia — TypeLangJulia(overwrite_input=true,inline=true,alloc_function,only_overwrite=false)Code generation in julia language, with optional overwriting of input. The parameter alloc_function is a function of three parameters alloc_function(k) where k is the memory slot (default is alloc_function(k)=similar(A,T)). The only_overwrite specifies if f should be created if the overwrite funtion f! contains the actual code.
GraphMatFun.LangMatlab — TypeLangMatlab()Code generation for the Matlab language.
GraphMatFun.LangC_MKL — Type LangC_MKL(gen_main::Bool)Code generation in C using the oneAPI MKL implementation of BLAS.
GraphMatFun.LangC_OpenBLAS — Type LangC_OpenBLAS(gen_main::Bool)Code generation in C using the OpenBLAS implementation of BLAS.