Add more patterns to loop unroll pass#2596
Conversation
…op-unroll-additional-opts Signed-off-by: Anna Gringauze <agringauze@nvidia.com>
Signed-off-by: Anna Gringauze <agringauze@nvidia.com>
Signed-off-by: Anna Gringauze <agringauze@nvidia.com>
Signed-off-by: Anna Gringauze <agringauze@nvidia.com>
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
Signed-off-by: Anna Gringauze <agringauze@nvidia.com>
…op-unroll-additional-opts Signed-off-by: Anna Gringauze <agringauze@nvidia.com>
I, Anna Gringauze <agringauze@nvidia.com>, hereby add my Signed-off-by to this commit: f08502e Signed-off-by: Anna Gringauze <agringauze@nvidia.com>
Signed-off-by: Anna Gringauze <agringauze@nvidia.com>
…op-unroll-additional-opts Signed-off-by: Anna Gringauze <agringauze@nvidia.com>
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
I, Anna Gringauze <agringauze@nvidia.com>, hereby add my Signed-off-by to this commit: 3d3597d Signed-off-by: Anna Gringauze <agringauze@nvidia.com>
…grin/cuda-quantum into loop-unroll-additional-opts Signed-off-by: Anna Gringauze <agringauze@nvidia.com>
…op-unroll-additional-opts Signed-off-by: Anna Gringauze <agringauze@nvidia.com>
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
Signed-off-by: Anna Gringauze <agringauze@nvidia.com>
|
CUDA Quantum Docs Bot: A preview of the documentation can be found here. |
| pm.addNestedPass<func::FuncOp>(cudaq::opt::createClassicalMemToReg()); | ||
| pm.addNestedPass<func::FuncOp>(createCanonicalizerPass()); | ||
| cudaq::opt::LoopNormalizeOptions lno{allowClosedInterval, allowBreak}; | ||
| pm.addNestedPass<func::FuncOp>(cudaq::opt::createLoopNormalize(lno)); |
There was a problem hiding this comment.
Removing loop normalization doesn't look correct.
There was a problem hiding this comment.
I added loop normalization pattern into the LoopUnroll pass itself so it is no longer needed here. I've run into a scenario where loop normalization was needed during the loop unroll fix point for it to fully succeed.
There was a problem hiding this comment.
I am thinking - given that I also needed to add something similar to the lift-array-alloc pass (in #2601) - instead of modifying the cc-loop-unroll and lift-array-alloc passes, would it be better to create a new classical-optimization-pipeline that would run the following:
classical-optimization-pipeline:
- memtoreg=quantum=0
- classical-optimization
- cse
- classical-optimization
(Note: after we update the llvm version we could run cse inside the fixpoint ofclassical-optimization, so we would not need to run it twice here and would be able to compile more code)
Where classical-optimizations pass runs the following patterns as a part of single fix point (same as the cc-loop-unroll pass in current PR, but run them on code that does not contain loops as well):
- write-after-write-elimination
- lift-array-alloc
- canonicalize
- loop-normalize patterns
- simplifyRegions
- original loop unrolling patterns
We would use classical-optimization-pipeline instead of the initial set of opts in quantum config files:
func.func(const-prop-complex,canonicalize,cse,lift-array-alloc)
And later again after the following passes:
apply-op-specialization,aggressive-early-inlining,expand-measurements
There was a problem hiding this comment.
So, as an example, the new pipeline for Ionq would look like:
"func.func(classical-optimization-pipeline), globalize-array-values,func.func(state-prep),unitary-synthesis,canonicalize, apply-op-specialization,aggressive-early-inlining,expand-measurements, func.func(classical-optimization-pipeline), decomposition{enable-patterns=U3ToRotations}, func.func(lower-to-cfg,canonicalize,multicontrol-decomposition), ionq-gate-set-mapping"
|
Replaced by #2605 |
Description
Add more patterns to loop unroll pass
To be able to optimize away loops with boundaries that are computed from array storage, other loops, conditions, and more, we need to run a bunch of optimizations together in the loop unroll pass.
Added following optimizations to
cc-loop-unroll:LoopOptpattern fromcc-loop-normalize(to keep normalizing loops in loop unrolling iterations)RewriteIffromlower-to-cfg(to const-prop if statements)SimplifyWritesAnalysisfromwrite-after-write-elimination(remove multiple writes to the same location on the stack)simplifyRegions(to remove dead code)AllocaPatternfromlift-array-alloc(to lift constant arrays, helps const prop)Added tests.