[clang] [OpenMP 6.0 ]Codegen for Reduction over private variables with reduction clause (PR #134709)

CHANDRA GHALE via cfe-commits cfe-commits at lists.llvm.org
Wed May 7 09:54:27 PDT 2025


================
@@ -4899,6 +4899,234 @@ void CGOpenMPRuntime::emitSingleReductionCombiner(CodeGenFunction &CGF,
   }
 }
 
+void CGOpenMPRuntime::emitPrivateReduction(
+    CodeGenFunction &CGF, SourceLocation Loc, ArrayRef<const Expr *> Privates,
+    ArrayRef<const Expr *> LHSExprs, ArrayRef<const Expr *> RHSExprs,
+    ArrayRef<const Expr *> ReductionOps) {
+  if (LHSExprs.empty() || Privates.empty() || ReductionOps.empty())
+    return;
+
+  if (LHSExprs.size() != Privates.size() ||
+      LHSExprs.size() != ReductionOps.size())
+    return;
+
+  //  Create a shared global variable (__shared_reduction_var) to accumulate the
+  //  final result.
+  //
+  //  Call __kmpc_barrier to synchronize threads before initialization.
----------------
chandraghale wrote:

Agreed , Done !!

https://github.com/llvm/llvm-project/pull/134709


More information about the cfe-commits mailing list