Open
Conversation
See JuliaLang/julia#55076 for details
Member
|
Can test locally by typing |
| root::GraphNode{T}, | ||
| cX::AbstractMatrix{T}, | ||
| operators::OperatorEnum, | ||
| loopVectorization::Val{true} |
Member
There was a problem hiding this comment.
Suggested change
| loopVectorization::Val{true} | |
| ::EvalOptions{true} |
| op::UInt8 # (Possibly undefined) If operator, this is the index of the operator in the degree-specific operator enum | ||
| children::NTuple{D,Base.RefValue{GraphNode{T,D}}} # Children nodes | ||
| visited::Bool # search accounting, initialised to false | ||
| cache::AbstractArray{T} |
Member
There was a problem hiding this comment.
Since this might not be backwards compatible, I wonder if an alternative would be to convert to a val type (T) where instead of val::T, you have val::Tuple{T,Bool,Array{T,1}}? Then you wouldn’t need to modify the GraphNode itself.
Member
|
Also see https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-abstract-container regarding the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Graph evaluator caching component from former PR
Graph evaluator caching
The GraphNode struct now has an additional property, the AbstractArray cache, not initialised during object creation.
This enables the result of each node evaluation to be stored and retrieved without the need for a dictionary lookup.
A GraphNode can now also have the constant property set to true during evaluation if it is an operator node with constant operand nodes. In such a case the val property will also be set to the result of the single operation required. This behaviour won't occur in sufficiently optimised expressions, as a subexpression consisting of operators with constant operand nodes could be replaced with a single constant node. This doesn't meaningfully mutate the expression during the evaluation, as the constant property is otherwise meaningless for nodes with degree >0.
In terms of the evaluator itself, there are two implemented versions: one using Base.map, and one using LoopVectorization.vmapnt which is used when the LoopVectorization package is loaded. Some rough tests I did found that, on a graph with no shared subexpressions, the graph evaluator takes 1.4x as long as the corresponding (with or without LoopVectorization) tree evaluator. I might do some more work on reducing that, one method would be to quickly identify whether shared subexpressions exist in the expression and choose a corresponding evaluator. The relative performance of the graph evaluator operating on an expression with shared subexpressions is entirely dependent on the number and size of the shared subexpressions but has a theoretically unbounded performance improvement.