[Mlir-commits] [mlir] [mlir][OpenMP] implement SIMD reduction (PR #146671)
Sergio Afonso
llvmlistbot at llvm.org
Wed Jul 2 05:55:38 PDT 2025
================
@@ -2921,6 +2948,50 @@ convertOmpSimd(Operation &opInst, llvm::IRBuilderBase &builder,
: nullptr,
order, simdlen, safelen);
+ // We now need to reduce the per-simd-lane reduction variable into the
+ // original variable. This works a bit differently to other reductions (e.g.
+ // wsloop) because we don't need to call into the OpenMP runtime to handle
+ // threads: everything happened in this one thread.
+ for (auto [i, tuple] : llvm::enumerate(
+ llvm::zip(reductionDecls, isByRef, simdOp.getReductionVars(),
+ privateReductionVariables))) {
+ auto [decl, byRef, reductionVar, privateReductionVar] = tuple;
+
+ OwningReductionGen gen = makeReductionGen(decl, builder, moduleTranslation);
+ llvm::Value *originalVariable = moduleTranslation.lookupValue(reductionVar);
+ llvm::Type *reductionType = moduleTranslation.convertType(decl.getType());
+
+ // We have one less load for by-ref case because that load is now inside of
+ // the reduction region
----------------
skatrak wrote:
```suggestion
// the reduction region.
```
https://github.com/llvm/llvm-project/pull/146671
More information about the Mlir-commits
mailing list