Skip to content

Commit ad2a302

Browse files
author
Razvan Lupusoru
committed
Remove construct recipes and fix all tests
1 parent c2e5eb0 commit ad2a302

File tree

16 files changed

+476
-496
lines changed

16 files changed

+476
-496
lines changed

flang/lib/Lower/OpenACC.cpp

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,6 @@ static void genPrivatizationRecipes(
13231323
Fortran::semantics::SemanticsContext &semanticsContext,
13241324
Fortran::lower::StatementContext &stmtCtx,
13251325
llvm::SmallVectorImpl<mlir::Value> &dataOperands,
1326-
llvm::SmallVector<mlir::Attribute> &privatizationRecipes,
13271326
llvm::ArrayRef<mlir::Value> async,
13281327
llvm::ArrayRef<mlir::Attribute> asyncDeviceTypes,
13291328
llvm::ArrayRef<mlir::Attribute> asyncOnlyDeviceTypes) {
@@ -1377,8 +1376,6 @@ static void genPrivatizationRecipes(
13771376
recipe.getSymName().str()));
13781377
dataOperands.push_back(op.getAccVar());
13791378
}
1380-
privatizationRecipes.push_back(mlir::SymbolRefAttr::get(
1381-
builder.getContext(), recipe.getSymName().str()));
13821379
}
13831380
}
13841381

@@ -1757,7 +1754,6 @@ genReductions(const Fortran::parser::AccObjectListWithReduction &objectList,
17571754
Fortran::semantics::SemanticsContext &semanticsContext,
17581755
Fortran::lower::StatementContext &stmtCtx,
17591756
llvm::SmallVectorImpl<mlir::Value> &reductionOperands,
1760-
llvm::SmallVector<mlir::Attribute> &reductionRecipes,
17611757
llvm::ArrayRef<mlir::Value> async,
17621758
llvm::ArrayRef<mlir::Attribute> asyncDeviceTypes,
17631759
llvm::ArrayRef<mlir::Attribute> asyncOnlyDeviceTypes) {
@@ -1811,8 +1807,6 @@ genReductions(const Fortran::parser::AccObjectListWithReduction &objectList,
18111807
builder, recipeName, operandLocation, ty, mlirOp, bounds);
18121808
op.setRecipeAttr(mlir::SymbolRefAttr::get(builder.getContext(),
18131809
recipe.getSymName().str()));
1814-
reductionRecipes.push_back(mlir::SymbolRefAttr::get(
1815-
builder.getContext(), recipe.getSymName().str()));
18161810
reductionOperands.push_back(op.getAccVar());
18171811
}
18181812
}
@@ -2024,7 +2018,6 @@ privatizeIv(Fortran::lower::AbstractConverter &converter,
20242018
llvm::SmallVector<mlir::Location> &ivLocs,
20252019
llvm::SmallVector<mlir::Value> &privateOperands,
20262020
llvm::SmallVector<mlir::Value> &ivPrivate,
2027-
llvm::SmallVector<mlir::Attribute> &privatizationRecipes,
20282021
bool isDoConcurrent = false) {
20292022
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
20302023

@@ -2067,8 +2060,6 @@ privatizeIv(Fortran::lower::AbstractConverter &converter,
20672060
privateOp = op.getOperation();
20682061

20692062
privateOperands.push_back(op.getAccVar());
2070-
privatizationRecipes.push_back(mlir::SymbolRefAttr::get(
2071-
builder.getContext(), recipe.getSymName().str()));
20722063
}
20732064

20742065
// Map the new private iv to its symbol for the scope of the loop. bindSymbol
@@ -2161,7 +2152,6 @@ static mlir::acc::LoopOp createLoopOp(
21612152
llvm::SmallVector<mlir::Value> tileOperands, privateOperands, ivPrivate,
21622153
reductionOperands, cacheOperands, vectorOperands, workerNumOperands,
21632154
gangOperands, lowerbounds, upperbounds, steps;
2164-
llvm::SmallVector<mlir::Attribute> privatizationRecipes, reductionRecipes;
21652155
llvm::SmallVector<int32_t> tileOperandsSegments, gangOperandsSegments;
21662156
llvm::SmallVector<int64_t> collapseValues;
21672157

@@ -2284,13 +2274,13 @@ static mlir::acc::LoopOp createLoopOp(
22842274
&clause.u)) {
22852275
genPrivatizationRecipes<mlir::acc::PrivateRecipeOp>(
22862276
privateClause->v, converter, semanticsContext, stmtCtx,
2287-
privateOperands, privatizationRecipes, /*async=*/{},
2277+
privateOperands, /*async=*/{},
22882278
/*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{});
22892279
} else if (const auto *reductionClause =
22902280
std::get_if<Fortran::parser::AccClause::Reduction>(
22912281
&clause.u)) {
22922282
genReductions(reductionClause->v, converter, semanticsContext, stmtCtx,
2293-
reductionOperands, reductionRecipes, /*async=*/{},
2283+
reductionOperands, /*async=*/{},
22942284
/*asyncDeviceTypes=*/{}, /*asyncOnlyDeviceTypes=*/{});
22952285
} else if (std::get_if<Fortran::parser::AccClause::Seq>(&clause.u)) {
22962286
for (auto crtDeviceTypeAttr : crtDeviceTypes)
@@ -2368,7 +2358,7 @@ static mlir::acc::LoopOp createLoopOp(
23682358

23692359
const auto &name = std::get<Fortran::parser::Name>(control.t);
23702360
privatizeIv(converter, *name.symbol, currentLocation, ivTypes, ivLocs,
2371-
privateOperands, ivPrivate, privatizationRecipes,
2361+
privateOperands, ivPrivate,
23722362
isDoConcurrent);
23732363

23742364
inclusiveBounds.push_back(true);
@@ -2407,7 +2397,7 @@ static mlir::acc::LoopOp createLoopOp(
24072397
Fortran::semantics::Symbol &ivSym =
24082398
bounds->name.thing.symbol->GetUltimate();
24092399
privatizeIv(converter, ivSym, currentLocation, ivTypes, ivLocs,
2410-
privateOperands, ivPrivate, privatizationRecipes);
2400+
privateOperands, ivPrivate);
24112401

24122402
inclusiveBounds.push_back(true);
24132403

@@ -2489,14 +2479,6 @@ static mlir::acc::LoopOp createLoopOp(
24892479
if (!autoDeviceTypes.empty())
24902480
loopOp.setAuto_Attr(builder.getArrayAttr(autoDeviceTypes));
24912481

2492-
if (!privatizationRecipes.empty())
2493-
loopOp.setPrivatizationRecipesAttr(
2494-
mlir::ArrayAttr::get(builder.getContext(), privatizationRecipes));
2495-
2496-
if (!reductionRecipes.empty())
2497-
loopOp.setReductionRecipesAttr(
2498-
mlir::ArrayAttr::get(builder.getContext(), reductionRecipes));
2499-
25002482
if (!collapseValues.empty())
25012483
loopOp.setCollapseAttr(builder.getI64ArrayAttr(collapseValues));
25022484
if (!collapseDeviceTypes.empty())
@@ -2618,8 +2600,6 @@ static Op createComputeOp(
26182600

26192601
llvm::SmallVector<mlir::Value> reductionOperands, privateOperands,
26202602
firstprivateOperands;
2621-
llvm::SmallVector<mlir::Attribute> privatizationRecipes,
2622-
firstPrivatizationRecipes, reductionRecipes;
26232603

26242604
// Self clause has optional values but can be present with
26252605
// no value as well. When there is no value, the op has an attribute to
@@ -2827,14 +2807,14 @@ static Op createComputeOp(
28272807
if (!combinedConstructs)
28282808
genPrivatizationRecipes<mlir::acc::PrivateRecipeOp>(
28292809
privateClause->v, converter, semanticsContext, stmtCtx,
2830-
privateOperands, privatizationRecipes, async, asyncDeviceTypes,
2810+
privateOperands, async, asyncDeviceTypes,
28312811
asyncOnlyDeviceTypes);
28322812
} else if (const auto *firstprivateClause =
28332813
std::get_if<Fortran::parser::AccClause::Firstprivate>(
28342814
&clause.u)) {
28352815
genPrivatizationRecipes<mlir::acc::FirstprivateRecipeOp>(
28362816
firstprivateClause->v, converter, semanticsContext, stmtCtx,
2837-
firstprivateOperands, firstPrivatizationRecipes, async,
2817+
firstprivateOperands, async,
28382818
asyncDeviceTypes, asyncOnlyDeviceTypes);
28392819
} else if (const auto *reductionClause =
28402820
std::get_if<Fortran::parser::AccClause::Reduction>(
@@ -2846,7 +2826,7 @@ static Op createComputeOp(
28462826
// instead.
28472827
if (!combinedConstructs) {
28482828
genReductions(reductionClause->v, converter, semanticsContext, stmtCtx,
2849-
reductionOperands, reductionRecipes, async,
2829+
reductionOperands, async,
28502830
asyncDeviceTypes, asyncOnlyDeviceTypes);
28512831
} else {
28522832
auto crtDataStart = dataClauseOperands.size();
@@ -2938,18 +2918,6 @@ static Op createComputeOp(
29382918
if (!waitOnlyDeviceTypes.empty())
29392919
computeOp.setWaitOnlyAttr(builder.getArrayAttr(waitOnlyDeviceTypes));
29402920

2941-
if constexpr (!std::is_same_v<Op, mlir::acc::KernelsOp>) {
2942-
if (!privatizationRecipes.empty())
2943-
computeOp.setPrivatizationRecipesAttr(
2944-
mlir::ArrayAttr::get(builder.getContext(), privatizationRecipes));
2945-
if (!reductionRecipes.empty())
2946-
computeOp.setReductionRecipesAttr(
2947-
mlir::ArrayAttr::get(builder.getContext(), reductionRecipes));
2948-
if (!firstPrivatizationRecipes.empty())
2949-
computeOp.setFirstprivatizationRecipesAttr(mlir::ArrayAttr::get(
2950-
builder.getContext(), firstPrivatizationRecipes));
2951-
}
2952-
29532921
if (combinedConstructs)
29542922
computeOp.setCombinedAttr(builder.getUnitAttr());
29552923

flang/test/Lower/OpenACC/acc-kernels-loop.f90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,7 +704,9 @@ subroutine acc_kernels_loop
704704
! CHECK: %[[COPYINREDR:.*]] = acc.copyin varPtr(%{{.*}} : !fir.ref<f32>) -> !fir.ref<f32> {dataClause = #acc<data_clause acc_reduction>, implicit = true, name = "reduction_r"}
705705
! CHECK: %[[COPYINREDI:.*]] = acc.copyin varPtr(%{{.*}} : !fir.ref<i32>) -> !fir.ref<i32> {dataClause = #acc<data_clause acc_reduction>, implicit = true, name = "reduction_i"}
706706
! CHECK: acc.kernels {{.*}} dataOperands(%[[COPYINREDR]], %[[COPYINREDI]] : !fir.ref<f32>, !fir.ref<i32>) {
707-
! CHECK: acc.loop {{.*}} reduction(@reduction_add_ref_f32 -> %{{.*}} : !fir.ref<f32>, @reduction_mul_ref_i32 -> %{{.*}} : !fir.ref<i32>) {{.*}} {
707+
! CHECK: %[[REDUCTION_R:.*]] = acc.reduction varPtr(%{{.*}} : !fir.ref<f32>) recipe(@reduction_add_ref_f32) -> !fir.ref<f32> {name = "reduction_r"}
708+
! CHECK: %[[REDUCTION_I:.*]] = acc.reduction varPtr(%{{.*}} : !fir.ref<i32>) recipe(@reduction_mul_ref_i32) -> !fir.ref<i32> {name = "reduction_i"}
709+
! CHECK: acc.loop {{.*}} reduction(%[[REDUCTION_R]], %[[REDUCTION_I]] : !fir.ref<f32>, !fir.ref<i32>) {{.*}} {
708710
! CHECK: acc.yield
709711
! CHECK-NEXT: }{{$}}
710712
! CHECK: acc.terminator

0 commit comments

Comments
 (0)