Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion clang/lib/CodeGen/CGOpenMPRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9582,6 +9582,20 @@ static void genMapInfo(const OMPExecutableDirective &D, CodeGenFunction &CGF,
MappedVarSet, CombinedInfo);
genMapInfo(MEHandler, CGF, CombinedInfo, OMPBuilder, MappedVarSet);
}

static void emitNumTeamsForBareTargetDirective(
CodeGenFunction &CGF, const OMPExecutableDirective &D,
llvm::SmallVectorImpl<llvm::Value *> &NumTeams) {
const auto *C = D.getSingleClause<OMPNumTeamsClause>();
assert(!C->varlist_empty() && "ompx_bare requires explicit num_teams");
CodeGenFunction::RunCleanupsScope NumTeamsScope(CGF);
for (auto *E : C->getNumTeams()) {
llvm::Value *V = CGF.EmitScalarExpr(E);
NumTeams.push_back(
CGF.Builder.CreateIntCast(V, CGF.Int32Ty, /*isSigned=*/true));
}
}

static void emitTargetCallKernelLaunch(
CGOpenMPRuntime *OMPRuntime, llvm::Function *OutlinedFn,
const OMPExecutableDirective &D,
Expand Down Expand Up @@ -9651,8 +9665,14 @@ static void emitTargetCallKernelLaunch(
return CGF.Builder.saveIP();
};

bool IsBare = D.hasClausesOfKind<OMPXBareClause>();
SmallVector<llvm::Value *, 3> NumTeams;
if (IsBare)
emitNumTeamsForBareTargetDirective(CGF, D, NumTeams);
else
NumTeams.push_back(OMPRuntime->emitNumTeamsForTargetDirective(CGF, D));

llvm::Value *DeviceID = emitDeviceID(Device, CGF);
llvm::Value *NumTeams = OMPRuntime->emitNumTeamsForTargetDirective(CGF, D);
llvm::Value *NumThreads =
OMPRuntime->emitNumThreadsForTargetDirective(CGF, D);
llvm::Value *RTLoc = OMPRuntime->emitUpdateLocation(CGF, D.getBeginLoc());
Expand Down
Loading
Loading