Skip to content
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

[flang][OpenMP] Try to unify induction var privatization for OMP regions. #91116

Merged
merged 36 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
6ad9565
[flang][OpenMP] Try to unify induction var privatization
ergawy May 4, 2024
833b600
Add `assert(!OmpPreDetermined)`
ergawy May 6, 2024
e29c7d4
Undo assert.
ergawy May 6, 2024
1bf0e55
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 7, 2024
d74cb3e
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 7, 2024
fe35620
retain flag setting, check parallel
ergawy May 7, 2024
fd2d53f
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 8, 2024
81f4e77
collect all privatized symbols in one list
ergawy May 8, 2024
cdb92c9
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 9, 2024
894a83e
xxx
ergawy May 10, 2024
dfade68
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 10, 2024
0d24b41
yyy
ergawy May 12, 2024
001c0fe
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 12, 2024
82d8ea0
zzz
ergawy May 12, 2024
b513a79
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 13, 2024
919309e
aaa
ergawy May 13, 2024
27ebcea
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 13, 2024
6985a27
bbb
ergawy May 13, 2024
f77c47f
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 13, 2024
696cde8
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 13, 2024
05c013f
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 14, 2024
2e067c4
handle upstream changes
ergawy May 14, 2024
3abb935
Revert "handle upstream changes"
ergawy May 14, 2024
1023e05
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 15, 2024
0fe21cf
collect pre-determined only for last item in the construct queue
ergawy May 15, 2024
eb20e54
handle some review comments
ergawy May 15, 2024
b4612b3
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 15, 2024
9c909d0
balance braces
ergawy May 15, 2024
cbdb1e5
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 15, 2024
799c616
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 15, 2024
25b8b9d
review comments
ergawy May 15, 2024
33114ee
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 16, 2024
dcc1558
format
ergawy May 16, 2024
9bb2215
handle critical
ergawy May 17, 2024
3e5c63c
Merge remote-tracking branch 'upstream/main' into unify_privatization…
ergawy May 17, 2024
6f1bcee
handle merge changes
ergawy May 17, 2024
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
3 changes: 2 additions & 1 deletion flang/include/flang/Lower/AbstractConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ class AbstractConverter {

/// For a given symbol, check if it is present in the inner-most
/// level of the symbol map.
virtual bool isPresentShallowLookup(Fortran::semantics::Symbol &sym) = 0;
virtual bool
isPresentShallowLookup(const Fortran::semantics::Symbol &sym) = 0;

/// Collect the set of symbols with \p flag in \p eval
/// region if \p collectSymbols is true. Otherwise, collect the
Expand Down
3 changes: 2 additions & 1 deletion flang/lib/Lower/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
return typeConstructionStack;
}

bool isPresentShallowLookup(Fortran::semantics::Symbol &sym) override final {
bool
isPresentShallowLookup(const Fortran::semantics::Symbol &sym) override final {
return bool(shallowLookupSymbol(sym));
}

Expand Down
113 changes: 76 additions & 37 deletions flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ void DataSharingProcessor::processStep1(
collectSymbolsForPrivatization();
collectDefaultSymbols();
collectImplicitSymbols();
collectPreDeterminedSymbols();

privatize(clauseOps, privateSyms);
defaultPrivatize(clauseOps, privateSyms);
implicitPrivatize(clauseOps, privateSyms);

insertBarrier();
}

Expand All @@ -57,7 +58,7 @@ void DataSharingProcessor::processStep2(mlir::Operation *op, bool isLoop) {
}

void DataSharingProcessor::insertDeallocs() {
for (const Fortran::semantics::Symbol *sym : privatizedSymbols)
for (const Fortran::semantics::Symbol *sym : allPrivatizedSymbols)
if (Fortran::semantics::IsAllocatable(sym->GetUltimate())) {
if (!useDelayedPrivatization) {
converter.createHostAssociateVarCloneDealloc(*sym);
Expand Down Expand Up @@ -92,10 +93,6 @@ void DataSharingProcessor::insertDeallocs() {
}

void DataSharingProcessor::cloneSymbol(const Fortran::semantics::Symbol *sym) {
// Privatization for symbols which are pre-determined (like loop index
// variables) happen separately, for everything else privatize here.
if (sym->test(Fortran::semantics::Symbol::Flag::OmpPreDetermined))
return;
bool success = converter.createHostAssociateVarClone(*sym);
(void)success;
assert(success && "Privatization failed due to existing binding");
Expand Down Expand Up @@ -127,20 +124,24 @@ void DataSharingProcessor::collectSymbolsForPrivatization() {
for (const omp::Clause &clause : clauses) {
if (const auto &privateClause =
std::get_if<omp::clause::Private>(&clause.u)) {
collectOmpObjectListSymbol(privateClause->v, privatizedSymbols);
collectOmpObjectListSymbol(privateClause->v, explicitlyPrivatizedSymbols);
} else if (const auto &firstPrivateClause =
std::get_if<omp::clause::Firstprivate>(&clause.u)) {
collectOmpObjectListSymbol(firstPrivateClause->v, privatizedSymbols);
collectOmpObjectListSymbol(firstPrivateClause->v,
explicitlyPrivatizedSymbols);
} else if (const auto &lastPrivateClause =
std::get_if<omp::clause::Lastprivate>(&clause.u)) {
const ObjectList &objects = std::get<ObjectList>(lastPrivateClause->t);
collectOmpObjectListSymbol(objects, privatizedSymbols);
collectOmpObjectListSymbol(objects, explicitlyPrivatizedSymbols);
hasLastPrivateOp = true;
} else if (std::get_if<omp::clause::Collapse>(&clause.u)) {
hasCollapse = true;
}
}

for (auto *sym : explicitlyPrivatizedSymbols)
allPrivatizedSymbols.insert(sym);

if (hasCollapse && hasLastPrivateOp)
TODO(converter.getCurrentLocation(), "Collapse clause with lastprivate");
}
Expand All @@ -150,7 +151,7 @@ bool DataSharingProcessor::needBarrier() {
// initialization of firstprivate variables and post-update of lastprivate
// variables.
// Emit implicit barrier for linear clause. Maybe on somewhere else.
for (const Fortran::semantics::Symbol *sym : privatizedSymbols) {
for (const Fortran::semantics::Symbol *sym : allPrivatizedSymbols) {
if (sym->test(Fortran::semantics::Symbol::Flag::OmpFirstPrivate) &&
sym->test(Fortran::semantics::Symbol::Flag::OmpLastPrivate))
return true;
Expand Down Expand Up @@ -289,12 +290,34 @@ void DataSharingProcessor::collectSymbolsInNestedRegions(
eval.getNestedEvaluations()) {
if (nestedEval.hasNestedEvaluations()) {
if (nestedEval.isConstruct())
// Recursively look for OpenMP constructs within `nestedEval`'s region
collectSymbolsInNestedRegions(nestedEval, flag, symbolsInNestedRegions);
else
converter.collectSymbolSet(nestedEval, symbolsInNestedRegions, flag,
/*collectSymbols=*/true,
/*collectHostAssociatedSymbols=*/false);
else {
bool isOrderedConstruct = [&]() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kiranchandramohan @luporl just to clarify this change:
Since omp ordered does not have its own data-sharing environment, I think we should consider symbols referenced by an omp ordered construct to be separate from the symbols referenced by the parent region.

The changes here make sure that for the following input, i to be collected as of the symbols to be privatized for the omp do ordered construct:

  !$omp do ordered
  do i = 2, 10
    !$omp ordered
    a(i) = a(i-1) + 1
    !$omp end ordered
  end do
  !$omp end do

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear to me why the ordered construct is a special case. Will the same issue be resolved by a fix similar to #90671 ?

Copy link
Member Author

@ergawy ergawy May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can describe the problem in more detail but cannot claim my solution is the proper one.

For the above example program, this is the output of flang-new -fc1 -fopenmp -fdebug-unparse-with-symbols:

!DEF: /foo (Subroutine) Subprogram
subroutine foo
 !DEF: /foo/a ObjectEntity INTEGER(4)
 !DEF: /foo/i ObjectEntity INTEGER(4)
 integer a(10), i
!$omp do  ordered
 !DEF: /foo/OtherConstruct1/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
 do i=2,10
!$omp ordered 
  !REF: /foo/a
  !REF: /foo/OtherConstruct1/i
  a(i) = a(i-1)+1
!$omp end ordered 
 end do
!$omp end do 
end subroutine

So, i is marked as being REFed from within the omp ordered construct (not defined).

However, when you call converter.collectSymbolSet(nestedEval, symbolsInNestedRegions, ...) when nestedEval is the omp ordered construct, i will be one of the symbols collected in that nested region.

This in turn, causes i not to be privatized when privatizing symbols that should be privatized for the omp do ordered construct (i is skipped because it is referenced by a nested region).

Since, omp ordered does not have a data environment of its own (as far as I understand), I thought it would reasonable to not exclude the symbols collected for a nested eval when that nested eval is an ordered directive.

That said, I am not sure this is the proper location for that kind of fix. But a similar fix to what was introduced in #90671 does not seem to work. Tried adding that in bool OmpAttributeVisitor::Pre(const parser::OpenMPBlockConstruct &x); but I get the same problem described above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can fix this separately. Could you check whether the same issue happens with the Critical construct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#90671 fixed symbol handling in semantics, which was enough to fix #78936, but not #75767.

Maybe the issue here is similar to #75767.
In any case, I agree that this can be fixed separately.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks both for the review.

Could you check whether the same issue happens with the Critical construct?

That indeed causes the same issue. I will add a similar "fix" and a test before merging.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a small question. I am not able to map how control-flow is coming to collectSymbolsInNestedRegions and other functionality, which is related to default clause. When I try a simple example as:

program main

  integer :: a(5)
  !$omp do ordered default(private) 
  do i = 2, 10
  end do
  !$omp end do
end program main

I get semantic error as: error: DEFAULT clause is not allowed on the DO directive

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get semantic error as: error: DEFAULT clause is not allowed on the DO directive

I think this error happens earlier in semantics because OMPC_Default is not listed in the allowed clauses of OMP_Do in "llvm/include/llvm/Frontend/OpenMP/OMP.td". Not sure whether it should be allowed or not (making that error expected), since I'm not familiar with that part of the spec.

Copy link
Contributor

@NimishMishra NimishMishra May 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Indeed it is from semantics. I was mainly checking if default privatization logic is being invoked uncharacteristically when it should not (i.e. when default(...) is not specified).

I'm looking into this

if (auto *ompConstruct =
nestedEval.getIf<parser::OpenMPConstruct>()) {
if (auto *ompBlockConstruct =
std::get_if<parser::OpenMPBlockConstruct>(
&ompConstruct->u)) {
const auto &beginBlockDirective =
std::get<Fortran::parser::OmpBeginBlockDirective>(
ompBlockConstruct->t);
const auto origDirective =
std::get<Fortran::parser::OmpBlockDirective>(
beginBlockDirective.t)
.v;

return origDirective == llvm::omp::Directive::OMPD_ordered;
}
}

return false;
}();

if (!isOrderedConstruct)
converter.collectSymbolSet(nestedEval, symbolsInNestedRegions, flag,
/*collectSymbols=*/true,
/*collectHostAssociatedSymbols=*/false);
}
}
}
}
Expand Down Expand Up @@ -330,25 +353,46 @@ void DataSharingProcessor::collectSymbols(
converter.collectSymbolSet(eval, allSymbols, flag,
/*collectSymbols=*/true,
/*collectHostAssociatedSymbols=*/true);

llvm::SetVector<const Fortran::semantics::Symbol *> symbolsInNestedRegions;
collectSymbolsInNestedRegions(eval, flag, symbolsInNestedRegions);
// Filter-out symbols that must not be privatized.
bool collectImplicit = flag == Fortran::semantics::Symbol::Flag::OmpImplicit;
bool collectPreDetermined =
flag == Fortran::semantics::Symbol::Flag::OmpPreDetermined;

auto isPrivatizable = [](const Fortran::semantics::Symbol &sym) -> bool {
return !Fortran::semantics::IsProcedure(sym) &&
!sym.GetUltimate().has<Fortran::semantics::DerivedTypeDetails>() &&
!sym.GetUltimate().has<Fortran::semantics::NamelistDetails>() &&
!Fortran::semantics::IsImpliedDoIndex(sym.GetUltimate());
};

auto shouldCollectSymbol = [&](const Fortran::semantics::Symbol *sym) {
if (collectImplicit &&
sym->test(Fortran::semantics::Symbol::Flag::OmpImplicit) &&
!sym->test(Fortran::semantics::Symbol::Flag::OmpPreDetermined))
return true;

if (collectPreDetermined &&
sym->test(Fortran::semantics::Symbol::Flag::OmpPreDetermined))
return true;

if (!sym->test(Fortran::semantics::Symbol::Flag::OmpImplicit) &&
!sym->test(Fortran::semantics::Symbol::Flag::OmpPreDetermined))
return true;

return false;
};

for (const auto *sym : allSymbols) {
assert(curScope && "couldn't find current scope");
if (isPrivatizable(*sym) && !symbolsInNestedRegions.contains(sym) &&
!privatizedSymbols.contains(sym) &&
!sym->test(Fortran::semantics::Symbol::Flag::OmpPreDetermined) &&
(collectImplicit ||
!sym->test(Fortran::semantics::Symbol::Flag::OmpImplicit)) &&
clauseScopes.contains(&sym->owner()))
!explicitlyPrivatizedSymbols.contains(sym) &&
shouldCollectSymbol(sym) && clauseScopes.contains(&sym->owner())) {
allPrivatizedSymbols.insert(sym);
symbols.insert(sym);
}
}
}

Expand All @@ -365,6 +409,9 @@ void DataSharingProcessor::collectDefaultSymbols() {
defaultSymbols);
}
}

for (auto *sym : defaultSymbols)
allPrivatizedSymbols.insert(sym);
}

void DataSharingProcessor::collectImplicitSymbols() {
Expand All @@ -374,10 +421,16 @@ void DataSharingProcessor::collectImplicitSymbols() {
implicitSymbols);
}

void DataSharingProcessor::collectPreDeterminedSymbols() {
if (shouldCollectPreDeterminedSymbols)
collectSymbols(Fortran::semantics::Symbol::Flag::OmpPreDetermined,
preDeterminedSymbols);
}

void DataSharingProcessor::privatize(
mlir::omp::PrivateClauseOps *clauseOps,
llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *privateSyms) {
for (const Fortran::semantics::Symbol *sym : privatizedSymbols) {
for (const Fortran::semantics::Symbol *sym : allPrivatizedSymbols) {
if (const auto *commonDet =
sym->detailsIf<Fortran::semantics::CommonBlockDetails>()) {
for (const auto &mem : commonDet->objects())
Expand All @@ -389,7 +442,7 @@ void DataSharingProcessor::privatize(

void DataSharingProcessor::copyLastPrivatize(mlir::Operation *op) {
insertLastPrivateCompare(op);
for (const Fortran::semantics::Symbol *sym : privatizedSymbols)
for (const Fortran::semantics::Symbol *sym : allPrivatizedSymbols)
if (const auto *commonDet =
sym->detailsIf<Fortran::semantics::CommonBlockDetails>()) {
for (const auto &mem : commonDet->objects()) {
Expand All @@ -400,20 +453,6 @@ void DataSharingProcessor::copyLastPrivatize(mlir::Operation *op) {
}
}

void DataSharingProcessor::defaultPrivatize(
mlir::omp::PrivateClauseOps *clauseOps,
llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *privateSyms) {
for (const Fortran::semantics::Symbol *sym : defaultSymbols)
doPrivatize(sym, clauseOps, privateSyms);
}

void DataSharingProcessor::implicitPrivatize(
mlir::omp::PrivateClauseOps *clauseOps,
llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *privateSyms) {
for (const Fortran::semantics::Symbol *sym : implicitSymbols)
doPrivatize(sym, clauseOps, privateSyms);
}

void DataSharingProcessor::doPrivatize(
const Fortran::semantics::Symbol *sym,
mlir::omp::PrivateClauseOps *clauseOps,
Expand Down
10 changes: 9 additions & 1 deletion flang/lib/Lower/OpenMP/DataSharingProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,21 @@ class DataSharingProcessor {
mlir::OpBuilder::InsertPoint insPt;
mlir::Value loopIV;
// Symbols in private, firstprivate, and/or lastprivate clauses.
llvm::SetVector<const Fortran::semantics::Symbol *> privatizedSymbols;
llvm::SetVector<const Fortran::semantics::Symbol *>
explicitlyPrivatizedSymbols;
llvm::SetVector<const Fortran::semantics::Symbol *> defaultSymbols;
llvm::SetVector<const Fortran::semantics::Symbol *> implicitSymbols;
llvm::SetVector<const Fortran::semantics::Symbol *> preDeterminedSymbols;
llvm::SetVector<const Fortran::semantics::Symbol *> allPrivatizedSymbols;

llvm::DenseMap<const Fortran::semantics::Symbol *, mlir::omp::PrivateClauseOp>
symToPrivatizer;
Fortran::lower::AbstractConverter &converter;
Fortran::semantics::SemanticsContext &semaCtx;
fir::FirOpBuilder &firOpBuilder;
omp::List<omp::Clause> clauses;
Fortran::lower::pft::Evaluation &eval;
bool shouldCollectPreDeterminedSymbols;
bool useDelayedPrivatization;
Fortran::lower::SymMap *symTable;

Expand All @@ -66,6 +71,7 @@ class DataSharingProcessor {
void insertBarrier();
void collectDefaultSymbols();
void collectImplicitSymbols();
void collectPreDeterminedSymbols();
void privatize(
mlir::omp::PrivateClauseOps *clauseOps,
llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *privateSyms);
Expand Down Expand Up @@ -94,10 +100,12 @@ class DataSharingProcessor {
Fortran::semantics::SemanticsContext &semaCtx,
const List<Clause> &clauses,
Fortran::lower::pft::Evaluation &eval,
bool shouldCollectPreDeterminedSymbols,
bool useDelayedPrivatization = false,
Fortran::lower::SymMap *symTable = nullptr)
: hasLastPrivateOp(false), converter(converter), semaCtx(semaCtx),
firOpBuilder(converter.getFirOpBuilder()), clauses(clauses), eval(eval),
shouldCollectPreDeterminedSymbols(shouldCollectPreDeterminedSymbols),
useDelayedPrivatization(useDelayedPrivatization), symTable(symTable) {}

// Privatisation is split into two steps.
Expand Down
5 changes: 5 additions & 0 deletions flang/lib/Lower/OpenMP/Decomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,9 @@ ConstructQueue buildConstructQueue(

return constructs;
}

bool isLastItemInQueue(ConstructQueue::iterator item,
const ConstructQueue &queue) {
return std::prev(queue.end()) == item;
}
} // namespace Fortran::lower::omp
3 changes: 3 additions & 0 deletions flang/lib/Lower/OpenMP/Decomposer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ ConstructQueue buildConstructQueue(mlir::ModuleOp modOp,
const parser::CharBlock &source,
llvm::omp::Directive compound,
const List<Clause> &clauses);

bool isLastItemInQueue(ConstructQueue::iterator item,
const ConstructQueue &queue);
} // namespace Fortran::lower::omp

#endif // FORTRAN_LOWER_OPENMP_DECOMPOSER_H
28 changes: 18 additions & 10 deletions flang/lib/Lower/OpenMP/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,16 @@ static mlir::Operation *
createAndSetPrivatizedLoopVar(Fortran::lower::AbstractConverter &converter,
mlir::Location loc, mlir::Value indexVal,
const Fortran::semantics::Symbol *sym) {

fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
mlir::OpBuilder::InsertPoint insPt = firOpBuilder.saveInsertionPoint();
firOpBuilder.setInsertionPointToStart(firOpBuilder.getAllocaBlock());

mlir::Type tempTy = converter.genType(*sym);
mlir::Value temp = firOpBuilder.create<fir::AllocaOp>(
loc, tempTy, /*pinned=*/true, /*lengthParams=*/mlir::ValueRange{},
/*shapeParams*/ mlir::ValueRange{},
llvm::ArrayRef<mlir::NamedAttribute>{
fir::getAdaptToByRefAttr(firOpBuilder)});
converter.bindSymbol(*sym, temp);

assert(converter.isPresentShallowLookup(*sym) &&
"Expected symbol to be in symbol table.");

firOpBuilder.restoreInsertionPoint(insPt);
mlir::Value cvtVal = firOpBuilder.createConvert(loc, tempTy, indexVal);
mlir::Operation *storeOp = firOpBuilder.create<fir::StoreOp>(
Expand Down Expand Up @@ -594,7 +593,8 @@ static void createBodyOfOp(mlir::Operation &op, const OpWithBodyGenInfo &info,
std::optional<DataSharingProcessor> tempDsp;
if (privatize) {
if (!info.dsp) {
tempDsp.emplace(info.converter, info.semaCtx, *info.clauses, info.eval);
tempDsp.emplace(info.converter, info.semaCtx, *info.clauses, info.eval,
Fortran::lower::omp::isLastItemInQueue(item, queue));
tempDsp->processStep1();
}
}
Expand Down Expand Up @@ -1362,6 +1362,7 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,

bool privatize = !outerCombined;
DataSharingProcessor dsp(converter, semaCtx, clauses, eval,
Fortran::lower::omp::isLastItemInQueue(item, queue),
/*useDelayedPrivatization=*/true, &symTable);

if (privatize)
Expand Down Expand Up @@ -1439,7 +1440,8 @@ genSectionsOp(Fortran::lower::AbstractConverter &converter,

// Insert privatizations before SECTIONS
symTable.pushScope();
DataSharingProcessor dsp(converter, semaCtx, clauses, eval);
DataSharingProcessor dsp(converter, semaCtx, clauses, eval,
Fortran::lower::omp::isLastItemInQueue(item, queue));
dsp.processStep1();

List<Clause> nonDsaClauses;
Expand Down Expand Up @@ -1511,7 +1513,9 @@ genSimdOp(Fortran::lower::AbstractConverter &converter,
const List<Clause> &clauses, const ConstructQueue &queue,
ConstructQueue::iterator item) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
DataSharingProcessor dsp(converter, semaCtx, clauses, eval);
symTable.pushScope();
DataSharingProcessor dsp(converter, semaCtx, clauses, eval,
Fortran::lower::omp::isLastItemInQueue(item, queue));
dsp.processStep1();

Fortran::lower::StatementContext stmtCtx;
Expand Down Expand Up @@ -1547,6 +1551,7 @@ genSimdOp(Fortran::lower::AbstractConverter &converter,
.setGenRegionEntryCb(ivCallback),
queue, item);

symTable.popScope();
return simdOp;
}

Expand Down Expand Up @@ -1833,7 +1838,9 @@ genWsloopOp(Fortran::lower::AbstractConverter &converter,
const List<Clause> &clauses, const ConstructQueue &queue,
ConstructQueue::iterator item) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
DataSharingProcessor dsp(converter, semaCtx, clauses, eval);
symTable.pushScope();
DataSharingProcessor dsp(converter, semaCtx, clauses, eval,
Fortran::lower::omp::isLastItemInQueue(item, queue));
dsp.processStep1();

Fortran::lower::StatementContext stmtCtx;
Expand Down Expand Up @@ -1874,6 +1881,7 @@ genWsloopOp(Fortran::lower::AbstractConverter &converter,
.setReductions(&reductionSyms, &reductionTypes)
.setGenRegionEntryCb(ivCallback),
queue, item);
symTable.popScope();
return wsloopOp;
}

Expand Down
Loading
Loading