[clang] [llvm] [clang][OpenMP] Add no-loop SPMD kernel promotion (PR #224041)
Nicole Aschenbrenner via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 8 08:06:07 PDT 2026
================
@@ -3934,6 +3961,55 @@ emitInnerParallelForWhenCombined(CodeGenFunction &CGF,
HasCancel = D->hasCancel();
}
CodeGenFunction::OMPCancelStackRAII CancelRegion(CGF, EKind, HasCancel);
+
+ CodeGenModule &CGM = CGF.CGM;
+ if (CGM.getOpenMPRuntime().canPromoteToNoLoop()) {
+ // Prepare the loop variables and their privatization.
+ emitLoopIterationspaceVars(CGF, S);
+ OMPLoopScope PreInitScope(CGF, S);
+
+ CodeGenFunction::OMPPrivateScope PrivateScope(CGF);
+ CGF.EmitOMPPrivateClause(S, PrivateScope);
----------------
nicebert wrote:
> I think we talked about this already at some point, but why doesn't firstprivate need to be handled here, too?
It does not. firstprivate is already handled at the distribute level for SPMD kernels.
> I still think that everything would be simpler if there would be a clean split between loop (structure) emitting and loop body emitting. This way, you always need to sync and keep up with EmitOMPWorksharingLoop. But maybe I'm missing something
I think that's a design preference. This PR follows how the loop emission is structured today and I think separating it is its own refactor.
https://github.com/llvm/llvm-project/pull/224041
More information about the cfe-commits
mailing list