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 1 commit
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
5 changes: 3 additions & 2 deletions flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,9 @@ void DataSharingProcessor::collectImplicitSymbols() {
}

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

void DataSharingProcessor::privatize(
Expand Down
3 changes: 3 additions & 0 deletions flang/lib/Lower/OpenMP/DataSharingProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class DataSharingProcessor {
fir::FirOpBuilder &firOpBuilder;
omp::List<omp::Clause> clauses;
Fortran::lower::pft::Evaluation &eval;
bool shouldCollectPreDeterminedSymbols;
bool useDelayedPrivatization;
Fortran::lower::SymMap *symTable;

Expand Down Expand Up @@ -99,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
13 changes: 9 additions & 4 deletions flang/lib/Lower/OpenMP/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,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 @@ -1361,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 @@ -1438,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 +1514,8 @@ genSimdOp(Fortran::lower::AbstractConverter &converter,
ConstructQueue::iterator item) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
symTable.pushScope();
DataSharingProcessor dsp(converter, semaCtx, clauses, eval);
DataSharingProcessor dsp(converter, semaCtx, clauses, eval,
Fortran::lower::omp::isLastItemInQueue(item, queue));
dsp.processStep1();

Fortran::lower::StatementContext stmtCtx;
Expand Down Expand Up @@ -1835,7 +1839,8 @@ genWsloopOp(Fortran::lower::AbstractConverter &converter,
ConstructQueue::iterator item) {
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
symTable.pushScope();
DataSharingProcessor dsp(converter, semaCtx, clauses, eval);
DataSharingProcessor dsp(converter, semaCtx, clauses, eval,
Fortran::lower::omp::isLastItemInQueue(item, queue));
dsp.processStep1();

Fortran::lower::StatementContext stmtCtx;
Expand Down
Loading