Skip to content

Commit 99f125e

Browse files
committed
Enable stand-alone tiling, but it gives a warning and converting to simd.
1 parent dc9506e commit 99f125e

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,6 +2267,39 @@ static void genUnrollOp(Fortran::lower::AbstractConverter &converter,
22672267
// Apply unrolling to it
22682268
auto cli = canonLoop.getCli();
22692269
mlir::omp::UnrollHeuristicOp::create(firOpBuilder, loc, cli);
2270+
2271+
static mlir::omp::LoopOp
2272+
genTiledLoopOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
2273+
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
2274+
mlir::Location loc, const ConstructQueue &queue,
2275+
ConstructQueue::const_iterator item) {
2276+
mlir::omp::LoopOperands loopClauseOps;
2277+
llvm::SmallVector<const semantics::Symbol *> loopReductionSyms;
2278+
genLoopClauses(converter, semaCtx, item->clauses, loc, loopClauseOps,
2279+
loopReductionSyms);
2280+
2281+
DataSharingProcessor dsp(converter, semaCtx, item->clauses, eval,
2282+
/*shouldCollectPreDeterminedSymbols=*/true,
2283+
/*useDelayedPrivatization=*/true, symTable);
2284+
dsp.processStep1(&loopClauseOps);
2285+
2286+
mlir::omp::LoopNestOperands loopNestClauseOps;
2287+
llvm::SmallVector<const semantics::Symbol *> iv;
2288+
genLoopNestClauses(converter, semaCtx, eval, item->clauses, loc,
2289+
loopNestClauseOps, iv);
2290+
2291+
EntryBlockArgs loopArgs;
2292+
loopArgs.priv.syms = dsp.getDelayedPrivSymbols();
2293+
loopArgs.priv.vars = loopClauseOps.privateVars;
2294+
loopArgs.reduction.syms = loopReductionSyms;
2295+
loopArgs.reduction.vars = loopClauseOps.reductionVars;
2296+
2297+
auto loopOp =
2298+
genWrapperOp<mlir::omp::LoopOp>(converter, loc, loopClauseOps, loopArgs);
2299+
genLoopNestOp(converter, symTable, semaCtx, eval, loc, queue, item,
2300+
loopNestClauseOps, iv, {{loopOp, loopArgs}},
2301+
llvm::omp::Directive::OMPD_loop, dsp);
2302+
return loopOp;
22702303
}
22712304

22722305
static mlir::omp::MaskedOp
@@ -3487,13 +3520,10 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
34873520
newOp = genTeamsOp(converter, symTable, stmtCtx, semaCtx, eval, loc, queue,
34883521
item);
34893522
break;
3490-
case llvm::omp::Directive::OMPD_tile: {
3491-
unsigned version = semaCtx.langOptions().OpenMPVersion;
3492-
if (!semaCtx.langOptions().OpenMPSimd)
3493-
TODO(loc, "Unhandled loop directive (" +
3494-
llvm::omp::getOpenMPDirectiveName(dir, version) + ")");
3523+
case llvm::omp::Directive::OMPD_tile:
3524+
newOp =
3525+
genTiledLoopOp(converter, symTable, semaCtx, eval, loc, queue, item);
34953526
break;
3496-
}
34973527
case llvm::omp::Directive::OMPD_unroll:
34983528
genUnrollOp(converter, symTable, stmtCtx, semaCtx, eval, loc, queue, item);
34993529
break;

flang/test/Lower/OpenMP/wsloop-collapse.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ program wsloop_collapse
5757
!CHECK: %[[VAL_31:.*]] = fir.load %[[VAL_11]]#0 : !fir.ref<i32>
5858
!CHECK: %[[VAL_32:.*]] = arith.constant 1 : i32
5959
!CHECK: omp.wsloop private(@{{.*}} %{{.*}}#0 -> %[[VAL_4:.*]], @{{.*}} %{{.*}}#0 -> %[[VAL_2:.*]], @{{.*}} %{{.*}}#0 -> %[[VAL_0:.*]] : !fir.ref<i32>, !fir.ref<i32>, !fir.ref<i32>) {
60-
!CHECK-NEXT: omp.loop_nest (%[[VAL_33:.*]], %[[VAL_34:.*]], %[[VAL_35:.*]]) : i32 = (%[[VAL_24]], %[[VAL_27]], %[[VAL_30]]) to (%[[VAL_25]], %[[VAL_28]], %[[VAL_31]]) inclusive step (%[[VAL_26]], %[[VAL_29]], %[[VAL_32]]) {
60+
!CHECK-NEXT: omp.loop_nest (%[[VAL_33:.*]], %[[VAL_34:.*]], %[[VAL_35:.*]]) : i32 = (%[[VAL_24]], %[[VAL_27]], %[[VAL_30]]) to (%[[VAL_25]], %[[VAL_28]], %[[VAL_31]]) inclusive step (%[[VAL_26]], %[[VAL_29]], %[[VAL_32]]) collapse(3) {
6161
!$omp do collapse(3)
6262
do i = 1, a
6363
do j= 1, b

0 commit comments

Comments
 (0)