[Mlir-commits] [llvm] [mlir] [OMPIRBuilder] - Make offloading input data persist for deferred target tasks (PR #133499)
Sergio Afonso
llvmlistbot at llvm.org
Thu May 8 05:50:53 PDT 2025
================
@@ -7291,15 +7400,56 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::emitTargetTask(
emitBlock(OI.ExitBB, Builder.GetInsertBlock()->getParent(),
/*IsFinished=*/true);
- OI.PostOutlineCB = [this, ToBeDeleted, Dependencies, HasNoWait,
- DeviceID](Function &OutlinedFn) mutable {
+ SmallVector<Value *, 2> OffloadingArraysToPrivatize;
+ if (DeviceID && HasNoWait) {
+ for (auto *V :
+ {RTArgs.BasePointersArray, RTArgs.PointersArray, RTArgs.MappersArray,
+ RTArgs.MapNamesArray, RTArgs.MapTypesArray, RTArgs.MapTypesArrayEnd,
+ RTArgs.SizesArray}) {
+ if (V && !isa<ConstantPointerNull>(V) && !isa<GlobalVariable>(V)) {
+ OffloadingArraysToPrivatize.push_back(V);
+ OI.ExcludeArgsFromAggregate.push_back(V);
+ }
+ }
+ }
+ OI.PostOutlineCB = [this, ToBeDeleted, Dependencies, HasNoWait, DeviceID,
+ OffloadingArraysToPrivatize](
+ Function &OutlinedFn) mutable {
assert(OutlinedFn.getNumUses() == 1 &&
"there must be a single user for the outlined function");
CallInst *StaleCI = cast<CallInst>(OutlinedFn.user_back());
- bool HasShareds = StaleCI->arg_size() > 1;
- Function *ProxyFn = emitTargetTaskProxyFunction(*this, Builder, StaleCI);
+ // The first argument of StaleCI is always the thread id.
+ // The next few arguments are the pointers to offloading arrays
+ // if any. (See OffloadingArraysToPrivatize)
----------------
skatrak wrote:
```suggestion
// if any (see OffloadingArraysToPrivatize).
```
https://github.com/llvm/llvm-project/pull/133499
More information about the Mlir-commits
mailing list