summaryrefslogtreecommitdiff
path: root/mlir/test/Transforms/single-parallel-loop-collapsing.mlir
AgeCommit message (Collapse)Author
2024-09-27[mlir][SCF] Use Affine ops for indexing math. (#108450)MaheshRavishankar
For index type of induction variable, the indexing math is better represented using affine ops such as `affine.delinearize_index`. This also further demonstrates that some of these `affine` ops might need to move to a different dialect. For one these ops only support `IndexType` when they should be able to work with any integer type. This change also includes some canonicalization patterns for `affine.delinearize_index` operation to 1) Drop unit `basis` values 2) Remove the `delinearize_index` op when the `linear_index` is a loop induction variable of a normalized loop and the `basis` is of size 1 and is also the upper bound of the normalized loop. --------- Signed-off-by: MaheshRavishankar <mahesh.ravishankar@gmail.com>
2024-04-04[mlir][SCF] Modernize `coalesceLoops` method to handle `scf.for` loops with ↵MaheshRavishankar
iter_args (#87019) As part of this extension this change also does some general cleanup 1) Make all the methods take `RewriterBase` as arguments instead of creating their own builders that tend to crash when used within pattern rewrites 2) Split `coalesePerfectlyNestedLoops` into two separate methods, one for `scf.for` and other for `affine.for`. The templatization didnt seem to be buying much there. Also general clean up of tests.
2023-12-20[mlir][SCF] `scf.parallel`: Make reductions part of the terminator (#75314)Matthias Springer
This commit makes reductions part of the terminator. Instead of `scf.yield`, `scf.reduce` now terminates the body of `scf.parallel` ops. `scf.reduce` may contain an arbitrary number of reductions, with one region per reduction. Example: ```mlir %init = arith.constant 0.0 : f32 %r:2 = scf.parallel (%iv) = (%lb) to (%ub) step (%step) init (%init, %init) -> f32, f32 { %elem_to_reduce1 = load %buffer1[%iv] : memref<100xf32> %elem_to_reduce2 = load %buffer2[%iv] : memref<100xf32> scf.reduce(%elem_to_reduce1, %elem_to_reduce2 : f32, f32) { ^bb0(%lhs : f32, %rhs: f32): %res = arith.addf %lhs, %rhs : f32 scf.reduce.return %res : f32 }, { ^bb0(%lhs : f32, %rhs: f32): %res = arith.mulf %lhs, %rhs : f32 scf.reduce.return %res : f32 } } ``` `scf.reduce` operations can no longer be interleaved with other ops in the body of `scf.parallel`. This simplifies the op and makes it possible to assign the `RecursiveMemoryEffects` trait to `scf.reduce`. (This was not possible before because the op was not a terminator, causing the op to be DCE'd.)
2023-04-05[MLIR] Clarify (test-scf-)parallel-loop-collapsingTres Popp
1. parallel-loop-collapsing is renamed to test-scf-parallel-loop-collapsing. 2. The pass adds various checks to provide error messages instead of hitting assert failures. 3. Testing is added to verify these error messages This is roughly an NFC. The name changes, but all checked behavior previously would have resulted in an assertion failure. Almost no new support is added, so this pass is still limited in scope to testing the transform behaves correctly with input arguments that perfectly match the ParallelLoop's iterator arg set. The one new piece of functionality is that invalid operations will now be skipped with an error messages instead of producing an assertion failure, so the pass can be used with expected failures for pieces of the IR not cared about with a specific RUN command. Differential Revision: https://reviews.llvm.org/D147514
2022-11-03[mlir][Pass] Include anchor op in -pass-pipelinerkayaith
In D134622 the printed form of a pass manager is changed to include the name of the op that the pass manager is anchored on. This updates the `-pass-pipeline` argument format to include the anchor op as well, so that the printed form of a pipeline can be directly passed to `-pass-pipeline`. In most cases this requires updating `-pass-pipeline='pipeline'` to `-pass-pipeline='builtin.module(pipeline)'`. This also fixes an outdated assert that prevented running a `PassManager` anchored on `'any'`. Reviewed By: rriddle Differential Revision: https://reviews.llvm.org/D134900
2022-04-20[mlir][NFC] Update textual references of `func` to `func.func` in Transform ↵River Riddle
tests The special case parsing of `func` operations is being removed.
2022-03-16[mlir] Move the Builtin FuncOp to the Func dialectRiver Riddle
This commit moves FuncOp out of the builtin dialect, and into the Func dialect. This move has been planned in some capacity from the moment we made FuncOp an operation (years ago). This commit handles the functional aspects of the move, but various aspects are left untouched to ease migration: func::FuncOp is re-exported into mlir to reduce the actual API churn, the assembly format still accepts the unqualified `func`. These temporary measures will remain for a little while to simplify migration before being removed. Differential Revision: https://reviews.llvm.org/D121266
2022-01-31[MLIR][NFC] Update SCF pass cmd line names to prefix scfUday Bondhugula
Update SCF pass cmd line names to prefix `scf`. This is consistent with guidelines/convention on how to name dialect passes. This also avoids ambiguity on the context given the multiple `for` operations in the tree. NFC. Differential Revision: https://reviews.llvm.org/D118564
2021-10-13[MLIR] Replace std ops with arith dialect opsMogball
Precursor: https://reviews.llvm.org/D110200 Removed redundant ops from the standard dialect that were moved to the `arith` or `math` dialects. Renamed all instances of operations in the codebase and in tests. Reviewed By: rriddle, jpienaar Differential Revision: https://reviews.llvm.org/D110797
2021-07-28[mlir] Set the namespace of the BuiltinDialect to 'builtin'River Riddle
Historically the builtin dialect has had an empty namespace. This has unfortunately created a very awkward situation, where many utilities either have to special case the empty namespace, or just don't work at all right now. This revision adds a namespace to the builtin dialect, and starts to cleanup some of the utilities to no longer handle empty namespaces. For now, the assembly form of builtin operations does not require the `builtin.` prefix. (This should likely be re-evaluated though) Differential Revision: https://reviews.llvm.org/D105149
2021-03-19[testsuite] Make testsuite more stable vs canonicalization change. NFC.Chris Lattner
Differential Revision: https://reviews.llvm.org/D98998
2021-03-15Revert "[Canonicalizer] Process regions top-down instead of bottom up & ↵Alex Zinenko
reuse existing constants." This reverts commit b5d9a3c92358349d5444ab28de8ab5b2bee33a01. The commit introduced a memory error in canonicalization/operation walking that is exposed when compiled with ASAN. It leads to crashes in some "release" configurations.
2021-03-14[Canonicalizer] Process regions top-down instead of bottom up & reuse ↵Chris Lattner
existing constants. Two changes: 1) Change the canonicalizer to walk the function in top-down order instead of bottom-up order. This composes well with the "top down" nature of constant folding and simplification, reducing iterations and re-evaluation of ops in simple cases. 2) Explicitly enter existing constants into the OperationFolder table before canonicalizing. Previously we would "constant fold" them and rematerialize them, wastefully recreating a bunch fo constants, which lead to pointless memory traffic. Both changes together provide a 33% speedup for canonicalize on some mid-size CIRCT examples. One artifact of this change is that the constants generated in normal pattern application get inserted at the top of the function as the patterns are applied. Because of this, we get "inverted" constants more often, which is an aethetic change to the IR but does permute some testcases. Differential Revision: https://reviews.llvm.org/D98609
2021-01-29[mlir] Preserve lexicographic order after loop collapsing.Alexander Belyaev
Currently, for a scf.parallel (i,j,k) after the loop collapsing to 1D is done, the IVs would be traversed as for an scf.parallel(k,j,i). Differential Revision: https://reviews.llvm.org/D95693
2020-06-26[mlir] fix off-by-one error in collapseParallelLoopsTobias Gysi
Summary: The patch fixes an off by one error in the method collapseParallelLoops. It ensures the same normalized bound is used for the computation of the division and the remainder. Reviewers: herhut Reviewed By: herhut Subscribers: mehdi_amini, rriddle, jpienaar, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, stephenneuendorffer, Joonsoo, grosul1, Kayjukh, jurahul, msifontes Tags: #mlir Differential Revision: https://reviews.llvm.org/D82634
2020-05-13[mlir] Change dialect namespace loop->scfAlex Zinenko
All ops of the SCF dialect now use the `scf.` prefix instead of `loop.`. This is a part of dialect renaming. Differential Revision: https://reviews.llvm.org/D79844
2020-04-01[MLIR] Rename collapsePLoops -> collapseParallelLoopsTres Popp
Summary: Additionally, NFC code cleanups were done. This is to address additional comments on https://reviews.llvm.org/D76363 Differential Revision: https://reviews.llvm.org/D77052
2020-03-30Add a flag on the context to protect against creation of operations in ↵Mehdi Amini
unregistered dialects Differential Revision: https://reviews.llvm.org/D76903
2020-03-26[MLIR] Add parallel loop collapsing.Tres Popp
This allows conversion of a ParallelLoop from N induction variables to some nuber of induction variables less than N. The first intended use of this is for the GPUDialect to convert ParallelLoops to iterate over 3 dimensions so they can be launched as GPU Kernels. To implement this: - Normalize each iteration space of the ParallelLoop - Use the same induction variable in a new ParallelLoop for multiple original iterations. - Split the new induction variable back into the original set of values inside the body of the ParallelLoop. Subscribers: mgorny, mehdi_amini, rriddle, jpienaar, burmako, shauheen, antiagainst, nicolasvasilache, arpith-jacob, mgester, lucyrfox, aartbik, liufengdb, Joonsoo, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D76363