Skip to content

Commit d4be8bc

Browse files
committed
[Clang][OMPX] Add the code generation for multi-dim num_teams
1 parent fefe6d3 commit d4be8bc

File tree

4 files changed

+1269
-640
lines changed

4 files changed

+1269
-640
lines changed

clang/lib/CodeGen/CGOpenMPRuntime.cpp

+21-1
Original file line numberDiff line numberDiff line change
@@ -9576,6 +9576,20 @@ static void genMapInfo(const OMPExecutableDirective &D, CodeGenFunction &CGF,
95769576
MappedVarSet, CombinedInfo);
95779577
genMapInfo(MEHandler, CGF, CombinedInfo, OMPBuilder, MappedVarSet);
95789578
}
9579+
9580+
static void emitNumTeamsForBareTargetDirective(
9581+
CodeGenFunction &CGF, const OMPExecutableDirective &D,
9582+
llvm::SmallVectorImpl<llvm::Value *> &NumTeams) {
9583+
const auto *C = D.getSingleClause<OMPNumTeamsClause>();
9584+
assert(!C->varlist_empty() && "ompx_bare requires explicit num_teams");
9585+
CodeGenFunction::RunCleanupsScope NumTeamsScope(CGF);
9586+
for (auto *E : C->getNumTeams()) {
9587+
llvm::Value *V = CGF.EmitScalarExpr(E);
9588+
NumTeams.push_back(
9589+
CGF.Builder.CreateIntCast(V, CGF.Int32Ty, /*isSigned=*/true));
9590+
}
9591+
}
9592+
95799593
static void emitTargetCallKernelLaunch(
95809594
CGOpenMPRuntime *OMPRuntime, llvm::Function *OutlinedFn,
95819595
const OMPExecutableDirective &D,
@@ -9645,8 +9659,14 @@ static void emitTargetCallKernelLaunch(
96459659
return CGF.Builder.saveIP();
96469660
};
96479661

9662+
bool IsBare = D.hasClausesOfKind<OMPXBareClause>();
9663+
SmallVector<llvm::Value *, 3> NumTeams;
9664+
if (IsBare)
9665+
emitNumTeamsForBareTargetDirective(CGF, D, NumTeams);
9666+
else
9667+
NumTeams.push_back(OMPRuntime->emitNumTeamsForTargetDirective(CGF, D));
9668+
96489669
llvm::Value *DeviceID = emitDeviceID(Device, CGF);
9649-
llvm::Value *NumTeams = OMPRuntime->emitNumTeamsForTargetDirective(CGF, D);
96509670
llvm::Value *NumThreads =
96519671
OMPRuntime->emitNumThreadsForTargetDirective(CGF, D);
96529672
llvm::Value *RTLoc = OMPRuntime->emitUpdateLocation(CGF, D.getBeginLoc());

0 commit comments

Comments
 (0)