Skip to content

Commit

Permalink
[flang][openmp] Parallel reduction FIR lowering
Browse files Browse the repository at this point in the history
This patch extends the logic for lowering loop construct reductions to parallel block reductions.

Reviewed By: kiranchandramohan

Differential Revision: https://reviews.llvm.org/D154182
  • Loading branch information
EthanLuisMcDonough committed Jun 30, 2023
1 parent 60bb4ba commit 9bf5093
Show file tree
Hide file tree
Showing 4 changed files with 408 additions and 297 deletions.
11 changes: 10 additions & 1 deletion flang/lib/Lower/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,8 @@ class FirConverter : public Fortran::lower::AbstractConverter {

const Fortran::parser::OpenMPLoopConstruct *ompLoop =
std::get_if<Fortran::parser::OpenMPLoopConstruct>(&omp.u);
const Fortran::parser::OpenMPBlockConstruct *ompBlock =
std::get_if<Fortran::parser::OpenMPBlockConstruct>(&omp.u);

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

if (ompLoop)
if (ompLoop) {
genOpenMPReduction(*this, *loopOpClauseList);
} else if (ompBlock) {
const auto &blockStart =
std::get<Fortran::parser::OmpBeginBlockDirective>(ompBlock->t);
const auto &blockClauses =
std::get<Fortran::parser::OmpClauseList>(blockStart.t);
genOpenMPReduction(*this, blockClauses);
}

localSymbols.popScope();
builder->restoreInsertionPoint(insertPt);
Expand Down

0 comments on commit 9bf5093

Please sign in to comment.