[Mlir-commits] [flang] [llvm] [mlir] [Flang][OpenMP] Implement DEPEND clause for TASKWAIT directive (PR #193568)
Tom Eccles
llvmlistbot at llvm.org
Fri May 8 09:37:11 PDT 2026
================
@@ -2037,6 +2018,56 @@ static Value *emitTaskDependencies(
return DepArray;
}
+void OpenMPIRBuilder::emitTaskwaitImpl(const LocationDescription &Loc) {
+ // Build call kmp_int32 __kmpc_omp_taskwait(ident_t *loc, kmp_int32
+ // global_tid);
+ uint32_t SrcLocStrSize;
+ Constant *SrcLocStr = getOrCreateSrcLocStr(Loc, SrcLocStrSize);
+ Value *Ident = getOrCreateIdent(SrcLocStr, SrcLocStrSize);
+ Value *Args[] = {Ident, getOrCreateThreadID(Ident)};
+
+ // Ignore return result until untied tasks are supported.
+ createRuntimeFunctionCall(
+ getOrCreateRuntimeFunctionPtr(OMPRTL___kmpc_omp_taskwait), Args);
+}
+
+void OpenMPIRBuilder::createTaskwait(const LocationDescription &Loc,
+ SmallVector<DependData> Dependencies) {
+ if (!updateToLocation(Loc))
+ return;
+
+ if (Dependencies.size()) {
+ Builder.SetInsertPoint(
+ &Builder.GetInsertBlock()->getParent()->getEntryBlock());
+
+ Value *DepArray = nullptr;
+ Type *DepArrayTy = ArrayType::get(DependInfo, Dependencies.size());
+ DepArray = Builder.CreateAlloca(DepArrayTy, nullptr, ".dep.arr.addr");
+ for (const auto &[DepIdx, Dep] : enumerate(Dependencies)) {
+ Value *Base =
+ Builder.CreateConstInBoundsGEP2_64(DepArrayTy, DepArray, 0, DepIdx);
+ this->emitTaskDependency(Builder, Base, Dep);
+ }
+ uint32_t SrcLocStrSize;
+ Constant *SrcLocStr = getOrCreateSrcLocStr(Loc, SrcLocStrSize);
+ Value *Ident = getOrCreateIdent(SrcLocStr, SrcLocStrSize);
+ Value *Args[] = {
+ Ident,
+ getOrCreateThreadID(Ident),
+ Builder.getInt32(Dependencies.size()),
+ DepArray,
+ ConstantInt::get(Builder.getInt32Ty(), 0),
+ ConstantPointerNull::get(PointerType::getUnqual(M.getContext())),
+ ConstantInt::get(Builder.getInt32Ty(), false)};
+ createRuntimeFunctionCall(
----------------
tblah wrote:
Isn't the insert point still in the function entry block? I think only the alloca should be in the entry block
https://github.com/llvm/llvm-project/pull/193568
More information about the Mlir-commits
mailing list