[Mlir-commits] [mlir] [mlir][SCF] `scf.parallel`: Make reductions part of the terminator (PR #75314)
Ivan Butygin
llvmlistbot at llvm.org
Tue Dec 19 15:22:21 PST 2023
Hardcode84 wrote:
> This might make it difficult for frontends to directly lower to scf.parallel, since frontend reductions like in OpenMP do not require the reduction to be the last operation.
That's a good point, but I think this is solvable in frontends, and having a clean semantics on middle level is important.
E.g. in our python compiler we support code like this:
```
sum = 0
for i in prange(size): # parallel loop
... some code
sum += a[i]
... some more code
print(sum)
```
We are gradually uplifting `cf -> scf.while -> scf.for -> scf.parallel` and during this `scf.for -> scf.parallel` uplifting we are transforming `sum +=` to `scf.reduce` and move it to the end of the block.
And if user is doing something really weird with `sum`, we will just leave it at `scf.for` level.
https://github.com/llvm/llvm-project/pull/75314
More information about the Mlir-commits
mailing list