Skip to content

Commit 9484bb1

Browse files
committed
[MLIR][OpenMP] NFC: Uniformize OpenMP ops names
This patch proposes the renaming of certain OpenMP dialect operations with the goal of improving readability and following a uniform naming convention for MLIR operations and associated classes. In particular, the following operations are renamed: - `omp.map_info` -> `omp.map.info` - `omp.target_update_data` -> `omp.target_update` - `omp.ordered_region` -> `omp.ordered.region` - `omp.cancellationpoint` -> `omp.cancellation_point` - `omp.bounds` -> `omp.map.bounds` - `omp.reduction.declare` -> `omp.declare_reduction` Also, the following MLIR operation classes have been renamed: - `omp::TaskLoopOp` -> `omp::TaskloopOp` - `omp::TaskGroupOp` -> `omp::TaskgroupOp` - `omp::DataBoundsOp` -> `omp::MapBoundsOp` - `omp::DataOp` -> `omp::TargetDataOp` - `omp::EnterDataOp` -> `omp::TargetEnterDataOp` - `omp::ExitDataOp` -> `omp::TargetExitDataOp` - `omp::UpdateDataOp` -> `omp::TargetUpdateOp` - `omp::ReductionDeclareOp` -> `omp::DeclareReductionOp` - `omp::WsLoopOp` -> `omp::WsloopOp`
1 parent fe2119a commit 9484bb1

39 files changed

+501
-498
lines changed

flang/docs/OpenMP-descriptor-management.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,16 @@ the lowering to FIR/HLFIR has been performed an OpenMP dialect specific pass for
4949
mappings, with one extra per pointer member in the descriptor that is supported on top of the original
5050
descriptor map operation. These pointers members are linked to the parent descriptor by adding them to
5151
the member field of the original descriptor map operation, they are then inserted into the relevant map
52-
owning operation's (`omp.TargetOp`, `omp.DataOp` etc.) map operand list and in cases where the owning operation
53-
is `IsolatedFromAbove`, it also inserts them as `BlockArgs` to canonicalize the mappings and simplify lowering.
52+
owning operation's (`omp.TargetOp`, `omp.TargetDataOp` etc.) map operand list and in cases where the owning
53+
operation is `IsolatedFromAbove`, it also inserts them as `BlockArgs` to canonicalize the mappings and
54+
simplify lowering.
5455
5556
An example transformation by the `OMPDescriptorMapInfoGenPass`:
5657
5758
```
5859

5960
...
60-
%12 = omp.map_info var_ptr(%1#1 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.box<!fir.ptr<!fir.array<?xi32>>>) map_clauses(tofrom) capture(ByRef) bounds(%11) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> {name = "arg_alloc"}
61+
%12 = omp.map.info var_ptr(%1#1 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.box<!fir.ptr<!fir.array<?xi32>>>) map_clauses(tofrom) capture(ByRef) bounds(%11) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> {name = "arg_alloc"}
6162
...
6263
omp.target map_entries(%12 -> %arg1, %13 -> %arg2 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.ref<i32>) {
6364
^bb0(%arg1: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, %arg2: !fir.ref<i32>):
@@ -67,8 +68,8 @@ omp.target map_entries(%12 -> %arg1, %13 -> %arg2 : !fir.ref<!fir.box<!fir.ptr<!
6768

6869
...
6970
%12 = fir.box_offset %1#1 base_addr : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) -> !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>>
70-
%13 = omp.map_info var_ptr(%1#1 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.array<?xi32>) var_ptr_ptr(%12 : !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>>) map_clauses(tofrom) capture(ByRef) bounds(%11) -> !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>> {name = ""}
71-
%14 = omp.map_info var_ptr(%1#1 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.box<!fir.ptr<!fir.array<?xi32>>>) map_clauses(tofrom) capture(ByRef) members(%13 : !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>>) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> {name = "arg_alloc"}
71+
%13 = omp.map.info var_ptr(%1#1 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.array<?xi32>) var_ptr_ptr(%12 : !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>>) map_clauses(tofrom) capture(ByRef) bounds(%11) -> !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>> {name = ""}
72+
%14 = omp.map.info var_ptr(%1#1 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.box<!fir.ptr<!fir.array<?xi32>>>) map_clauses(tofrom) capture(ByRef) members(%13 : !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>>) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> {name = "arg_alloc"}
7273
...
7374
omp.target map_entries(%13 -> %arg1, %14 -> %arg2, %15 -> %arg3 : !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>>, !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.ref<i32>) {
7475
^bb0(%arg1: !fir.llvm_ptr<!fir.ref<!fir.array<?xi32>>>, %arg2: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, %arg3: !fir.ref<i32>):

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ static void genBodyOfTargetDataOp(
465465
Fortran::lower::AbstractConverter &converter,
466466
Fortran::semantics::SemanticsContext &semaCtx,
467467
Fortran::lower::pft::Evaluation &eval, bool genNested,
468-
mlir::omp::DataOp &dataOp, llvm::ArrayRef<mlir::Type> useDeviceTypes,
468+
mlir::omp::TargetDataOp &dataOp, llvm::ArrayRef<mlir::Type> useDeviceTypes,
469469
llvm::ArrayRef<mlir::Location> useDeviceLocs,
470470
llvm::ArrayRef<const Fortran::semantics::Symbol *> useDeviceSymbols,
471471
const mlir::Location &currentLocation) {
@@ -775,8 +775,8 @@ genTaskOp(Fortran::lower::AbstractConverter &converter,
775775
dependOperands, allocateOperands, allocatorOperands);
776776
}
777777

778-
static mlir::omp::TaskGroupOp
779-
genTaskGroupOp(Fortran::lower::AbstractConverter &converter,
778+
static mlir::omp::TaskgroupOp
779+
genTaskgroupOp(Fortran::lower::AbstractConverter &converter,
780780
Fortran::semantics::SemanticsContext &semaCtx,
781781
Fortran::lower::pft::Evaluation &eval, bool genNested,
782782
mlir::Location currentLocation,
@@ -786,7 +786,7 @@ genTaskGroupOp(Fortran::lower::AbstractConverter &converter,
786786
cp.processAllocate(allocatorOperands, allocateOperands);
787787
cp.processTODO<Fortran::parser::OmpClause::TaskReduction>(
788788
currentLocation, llvm::omp::Directive::OMPD_taskgroup);
789-
return genOpWithBody<mlir::omp::TaskGroupOp>(
789+
return genOpWithBody<mlir::omp::TaskgroupOp>(
790790
OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
791791
.setGenNested(genNested)
792792
.setClauses(&clauseList),
@@ -847,12 +847,12 @@ static void promoteNonCPtrUseDevicePtrArgsToUseDeviceAddr(
847847
}
848848
}
849849

850-
static mlir::omp::DataOp
851-
genDataOp(Fortran::lower::AbstractConverter &converter,
852-
Fortran::semantics::SemanticsContext &semaCtx,
853-
Fortran::lower::pft::Evaluation &eval, bool genNested,
854-
mlir::Location currentLocation,
855-
const Fortran::parser::OmpClauseList &clauseList) {
850+
static mlir::omp::TargetDataOp
851+
genTargetDataOp(Fortran::lower::AbstractConverter &converter,
852+
Fortran::semantics::SemanticsContext &semaCtx,
853+
Fortran::lower::pft::Evaluation &eval, bool genNested,
854+
mlir::Location currentLocation,
855+
const Fortran::parser::OmpClauseList &clauseList) {
856856
Fortran::lower::StatementContext stmtCtx;
857857
mlir::Value ifClauseOperand, deviceOperand;
858858
llvm::SmallVector<mlir::Value> mapOperands, devicePtrOperands,
@@ -885,7 +885,7 @@ genDataOp(Fortran::lower::AbstractConverter &converter,
885885
cp.processMap(currentLocation, llvm::omp::Directive::OMPD_target_data,
886886
stmtCtx, mapOperands);
887887

888-
auto dataOp = converter.getFirOpBuilder().create<mlir::omp::DataOp>(
888+
auto dataOp = converter.getFirOpBuilder().create<mlir::omp::TargetDataOp>(
889889
currentLocation, ifClauseOperand, deviceOperand, devicePtrOperands,
890890
deviceAddrOperands, mapOperands);
891891
genBodyOfTargetDataOp(converter, semaCtx, eval, genNested, dataOp,
@@ -896,7 +896,7 @@ genDataOp(Fortran::lower::AbstractConverter &converter,
896896

897897
template <typename OpTy>
898898
static OpTy
899-
genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
899+
genTargetEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
900900
Fortran::semantics::SemanticsContext &semaCtx,
901901
mlir::Location currentLocation,
902902
const Fortran::parser::OmpClauseList &clauseList) {
@@ -910,13 +910,13 @@ genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
910910
clause::If::DirectiveNameModifier directiveName;
911911
// GCC 9.3.0 emits a (probably) bogus warning about an unused variable.
912912
[[maybe_unused]] llvm::omp::Directive directive;
913-
if constexpr (std::is_same_v<OpTy, mlir::omp::EnterDataOp>) {
913+
if constexpr (std::is_same_v<OpTy, mlir::omp::TargetEnterDataOp>) {
914914
directiveName = clause::If::DirectiveNameModifier::TargetEnterData;
915915
directive = llvm::omp::Directive::OMPD_target_enter_data;
916-
} else if constexpr (std::is_same_v<OpTy, mlir::omp::ExitDataOp>) {
916+
} else if constexpr (std::is_same_v<OpTy, mlir::omp::TargetExitDataOp>) {
917917
directiveName = clause::If::DirectiveNameModifier::TargetExitData;
918918
directive = llvm::omp::Directive::OMPD_target_exit_data;
919-
} else if constexpr (std::is_same_v<OpTy, mlir::omp::UpdateDataOp>) {
919+
} else if constexpr (std::is_same_v<OpTy, mlir::omp::TargetUpdateOp>) {
920920
directiveName = clause::If::DirectiveNameModifier::TargetUpdate;
921921
directive = llvm::omp::Directive::OMPD_target_update;
922922
} else {
@@ -929,7 +929,7 @@ genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
929929
cp.processDepend(dependTypeOperands, dependOperands);
930930
cp.processNowait(nowaitAttr);
931931

932-
if constexpr (std::is_same_v<OpTy, mlir::omp::UpdateDataOp>) {
932+
if constexpr (std::is_same_v<OpTy, mlir::omp::TargetUpdateOp>) {
933933
cp.processMotionClauses<Fortran::parser::OmpClause::To>(stmtCtx,
934934
mapOperands);
935935
cp.processMotionClauses<Fortran::parser::OmpClause::From>(stmtCtx,
@@ -1401,19 +1401,19 @@ genOmpSimpleStandalone(Fortran::lower::AbstractConverter &converter,
14011401
firOpBuilder.create<mlir::omp::TaskyieldOp>(currentLocation);
14021402
break;
14031403
case llvm::omp::Directive::OMPD_target_data:
1404-
genDataOp(converter, semaCtx, eval, genNested, currentLocation,
1405-
opClauseList);
1404+
genTargetDataOp(converter, semaCtx, eval, genNested, currentLocation,
1405+
opClauseList);
14061406
break;
14071407
case llvm::omp::Directive::OMPD_target_enter_data:
1408-
genEnterExitUpdateDataOp<mlir::omp::EnterDataOp>(
1408+
genTargetEnterExitUpdateDataOp<mlir::omp::TargetEnterDataOp>(
14091409
converter, semaCtx, currentLocation, opClauseList);
14101410
break;
14111411
case llvm::omp::Directive::OMPD_target_exit_data:
1412-
genEnterExitUpdateDataOp<mlir::omp::ExitDataOp>(
1412+
genTargetEnterExitUpdateDataOp<mlir::omp::TargetExitDataOp>(
14131413
converter, semaCtx, currentLocation, opClauseList);
14141414
break;
14151415
case llvm::omp::Directive::OMPD_target_update:
1416-
genEnterExitUpdateDataOp<mlir::omp::UpdateDataOp>(
1416+
genTargetEnterExitUpdateDataOp<mlir::omp::TargetUpdateOp>(
14171417
converter, semaCtx, currentLocation, opClauseList);
14181418
break;
14191419
case llvm::omp::Directive::OMPD_ordered:
@@ -1898,15 +1898,15 @@ genOMP(Fortran::lower::AbstractConverter &converter,
18981898
beginClauseList, directive.v);
18991899
break;
19001900
case llvm::omp::Directive::OMPD_target_data:
1901-
genDataOp(converter, semaCtx, eval, /*genNested=*/true, currentLocation,
1902-
beginClauseList);
1901+
genTargetDataOp(converter, semaCtx, eval, /*genNested=*/true,
1902+
currentLocation, beginClauseList);
19031903
break;
19041904
case llvm::omp::Directive::OMPD_task:
19051905
genTaskOp(converter, semaCtx, eval, /*genNested=*/true, currentLocation,
19061906
beginClauseList);
19071907
break;
19081908
case llvm::omp::Directive::OMPD_taskgroup:
1909-
genTaskGroupOp(converter, semaCtx, eval, /*genNested=*/true,
1909+
genTaskgroupOp(converter, semaCtx, eval, /*genNested=*/true,
19101910
currentLocation, beginClauseList);
19111911
break;
19121912
case llvm::omp::Directive::OMPD_teams:

0 commit comments

Comments
 (0)