-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang][OpenMP] Fix construct privatization in default clause #72510
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -302,21 +302,38 @@ void DataSharingProcessor::insertLastPrivateCompare(mlir::Operation *op) { | |
} | ||
} | ||
|
||
void DataSharingProcessor::collectSymbolsInNestedRegions( | ||
Fortran::lower::pft::Evaluation &eval, | ||
Fortran::semantics::Symbol::Flag flag, | ||
llvm::SetVector<const Fortran::semantics::Symbol *> | ||
&symbolsInNestedRegions) { | ||
for (Fortran::lower::pft::Evaluation &nestedEval : | ||
eval.getNestedEvaluations()) { | ||
if (nestedEval.hasNestedEvaluations()) { | ||
luporl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (nestedEval.isConstruct()) | ||
// Recursively look for OpenMP constructs within `nestedEval`'s region | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean look for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, we want to capture symbols within nested OpenMP constructs in In this case, the current evaluation is a non-OpenMP construct (like |
||
collectSymbolsInNestedRegions(nestedEval, flag, symbolsInNestedRegions); | ||
else | ||
converter.collectSymbolSet(nestedEval, symbolsInNestedRegions, flag, | ||
/*collectSymbols=*/true, | ||
/*collectHostAssociatedSymbols=*/false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes that is correct. |
||
} | ||
} | ||
} | ||
|
||
// Collect symbols to be default privatized in two steps. | ||
// In step 1, collect all symbols in `eval` that match `flag` into | ||
// `defaultSymbols`. In step 2, for nested constructs (if any), if and only if | ||
// the nested construct is an OpenMP construct, collect those nested | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean if it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For non-OpenMP constructs, we skip collecting any symbols in |
||
// symbols skipping host associated symbols into `symbolsInNestedRegions`. | ||
// Later, in current context, all symbols in the set | ||
// `defaultSymbols` - `symbolsInNestedRegions` will be privatized. | ||
void DataSharingProcessor::collectSymbols( | ||
Fortran::semantics::Symbol::Flag flag) { | ||
converter.collectSymbolSet(eval, defaultSymbols, flag, | ||
/*collectSymbols=*/true, | ||
/*collectHostAssociatedSymbols=*/true); | ||
Comment on lines
333
to
335
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be folded into collectSymbolsInNestedRegions? I see the value of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, that might not work. |
||
for (Fortran::lower::pft::Evaluation &e : eval.getNestedEvaluations()) { | ||
if (e.hasNestedEvaluations()) | ||
converter.collectSymbolSet(e, symbolsInNestedRegions, flag, | ||
/*collectSymbols=*/true, | ||
/*collectHostAssociatedSymbols=*/false); | ||
else | ||
converter.collectSymbolSet(e, symbolsInParentRegions, flag, | ||
/*collectSymbols=*/false, | ||
/*collectHostAssociatedSymbols=*/true); | ||
} | ||
collectSymbolsInNestedRegions(eval, flag, symbolsInNestedRegions); | ||
} | ||
|
||
void DataSharingProcessor::collectDefaultSymbols() { | ||
|
@@ -367,7 +384,6 @@ void DataSharingProcessor::defaultPrivatize( | |
!sym->GetUltimate().has<Fortran::semantics::NamelistDetails>() && | ||
!Fortran::semantics::IsImpliedDoIndex(sym->GetUltimate()) && | ||
!symbolsInNestedRegions.contains(sym) && | ||
!symbolsInParentRegions.contains(sym) && | ||
!privatizedSymbols.contains(sym)) | ||
doPrivatize(sym, clauseOps, privateSyms); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.