Skip to content

Commit 9bf5093

Browse files
[flang][openmp] Parallel reduction FIR lowering
This patch extends the logic for lowering loop construct reductions to parallel block reductions. Reviewed By: kiranchandramohan Differential Revision: https://reviews.llvm.org/D154182
1 parent 60bb4ba commit 9bf5093

File tree

4 files changed

+408
-297
lines changed

4 files changed

+408
-297
lines changed

flang/lib/Lower/Bridge.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2172,6 +2172,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {
21722172

21732173
const Fortran::parser::OpenMPLoopConstruct *ompLoop =
21742174
std::get_if<Fortran::parser::OpenMPLoopConstruct>(&omp.u);
2175+
const Fortran::parser::OpenMPBlockConstruct *ompBlock =
2176+
std::get_if<Fortran::parser::OpenMPBlockConstruct>(&omp.u);
21752177

21762178
// If loop is part of an OpenMP Construct then the OpenMP dialect
21772179
// workshare loop operation has already been created. Only the
@@ -2196,8 +2198,15 @@ class FirConverter : public Fortran::lower::AbstractConverter {
21962198
for (Fortran::lower::pft::Evaluation &e : curEval->getNestedEvaluations())
21972199
genFIR(e);
21982200

2199-
if (ompLoop)
2201+
if (ompLoop) {
22002202
genOpenMPReduction(*this, *loopOpClauseList);
2203+
} else if (ompBlock) {
2204+
const auto &blockStart =
2205+
std::get<Fortran::parser::OmpBeginBlockDirective>(ompBlock->t);
2206+
const auto &blockClauses =
2207+
std::get<Fortran::parser::OmpClauseList>(blockStart.t);
2208+
genOpenMPReduction(*this, blockClauses);
2209+
}
22012210

22022211
localSymbols.popScope();
22032212
builder->restoreInsertionPoint(insertPt);

0 commit comments

Comments
 (0)