Skip to content

[mlir][OpenMP] Pack task private variables into a heap-allocated context struct #125307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Feb 27, 2025
2 changes: 1 addition & 1 deletion flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ void DataSharingProcessor::doPrivatize(const semantics::Symbol *sym,
sym, cannotHaveNonDefaultLowerBounds);
// TODO: currently there are false positives from dead uses of the mold
// arg
if (!result.getInitMoldArg().getUses().empty())
if (result.initReadsFromMold())
mightHaveReadHostSym.insert(sym);
}

Expand Down
15 changes: 13 additions & 2 deletions mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,24 @@ def PrivateClauseOp : OpenMP_Op<"private", [IsolatedFromAbove, RecipeInterface]>
return region.empty() ? nullptr : region.getArgument(0);
}

/// Returns true if the init region might read from the mold argument
bool initReadsFromMold() {
BlockArgument moldArg = getInitMoldArg();
return moldArg && !moldArg.use_empty();
}

/// Returns true if any region of this privatizer might read from the mold
/// argument
bool readsFromMold() {
return initReadsFromMold() || !getCopyRegion().empty();
}

/// needsMap returns true if the value being privatized should additionally
/// be mapped to the target region using a MapInfoOp. This is most common
/// when an allocatable is privatized. In such cases, the descriptor is used
/// in privatization and needs to be mapped on to the device.
bool needsMap() {
BlockArgument moldArg = getInitMoldArg();
return moldArg ? !moldArg.use_empty() : false;
return initReadsFromMold();
}

/// Get the type for arguments to nested regions. This should
Expand Down
Loading
Loading