Skip to content

Commit

Permalink
[Flang][OpenMP] Disable lowering of omp.simd reductions in composites (
Browse files Browse the repository at this point in the history
…llvm#112686)

Currently, the `omp.simd` operation is ignored during MLIR to LLVM IR
translation when it takes part in a composite construct. One consequence
of this limitation is that any entry block arguments defined by that
operation will trigger a compiler crash if they are used anywhere, as
they are not bound to an LLVM IR value.

A previous PR introducing support for the `reduction` clause resulted in
the creation and use of entry block arguments attached to the `omp.simd`
operation, causing compiler crashes on 'do simd reduction(...)'
constructs.

This patch disables Flang lowering of simd reductions in 'do simd'
constructs to avoid triggering these errors while translation to LLVM IR
is still incomplete.
  • Loading branch information
skatrak authored Oct 21, 2024
1 parent ecfeacd commit c44860c
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions flang/lib/Lower/OpenMP/OpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2209,6 +2209,12 @@ static void genCompositeDistributeParallelDoSimd(
genSimdClauses(converter, semaCtx, simdItem->clauses, loc, simdClauseOps,
simdReductionSyms);

// TODO: Remove this after omp.simd reductions on composite constructs are
// supported.
simdClauseOps.reductionVars.clear();
simdClauseOps.reductionByref.clear();
simdClauseOps.reductionSyms.clear();

mlir::omp::LoopNestOperands loopNestClauseOps;
llvm::SmallVector<const semantics::Symbol *> iv;
genLoopNestClauses(converter, semaCtx, eval, simdItem->clauses, loc,
Expand All @@ -2230,9 +2236,7 @@ static void genCompositeDistributeParallelDoSimd(
wsloopOp.setComposite(/*val=*/true);

EntryBlockArgs simdArgs;
// TODO: Add private syms and vars.
simdArgs.reduction.syms = simdReductionSyms;
simdArgs.reduction.vars = simdClauseOps.reductionVars;
// TODO: Add private and reduction syms and vars.
auto simdOp =
genWrapperOp<mlir::omp::SimdOp>(converter, loc, simdClauseOps, simdArgs);
simdOp.setComposite(/*val=*/true);
Expand Down Expand Up @@ -2325,6 +2329,12 @@ static void genCompositeDoSimd(lower::AbstractConverter &converter,
genSimdClauses(converter, semaCtx, simdItem->clauses, loc, simdClauseOps,
simdReductionSyms);

// TODO: Remove this after omp.simd reductions on composite constructs are
// supported.
simdClauseOps.reductionVars.clear();
simdClauseOps.reductionByref.clear();
simdClauseOps.reductionSyms.clear();

// TODO: Support delayed privatization.
DataSharingProcessor dsp(converter, semaCtx, simdItem->clauses, eval,
/*shouldCollectPreDeterminedSymbols=*/true,
Expand All @@ -2348,9 +2358,7 @@ static void genCompositeDoSimd(lower::AbstractConverter &converter,
wsloopOp.setComposite(/*val=*/true);

EntryBlockArgs simdArgs;
// TODO: Add private syms and vars.
simdArgs.reduction.syms = simdReductionSyms;
simdArgs.reduction.vars = simdClauseOps.reductionVars;
// TODO: Add private and reduction syms and vars.
auto simdOp =
genWrapperOp<mlir::omp::SimdOp>(converter, loc, simdClauseOps, simdArgs);
simdOp.setComposite(/*val=*/true);
Expand Down

0 comments on commit c44860c

Please sign in to comment.