Skip to content

Commit f1ad467

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.target_enter_data` -> `omp.target.enterdata` - `omp.target_exit_data` -> `omp.target.exitdata` - `omp.ordered_region` -> `omp.ordered.region` - `omp.cancellationpoint` -> `omp.cancellation.point` Also, the following MLIR operation classes have been renamed: - `omp::TaskLoopOp` -> `omp::TaskloopOp` - `omp::TaskGroupOp` -> `omp::TaskgroupOp` - `omp::DataOp` -> `omp::TargetDataOp` - `omp::EnterDataOp` -> `omp::TargetEnterDataOp` - `omp::ExitDataOp` -> `omp::TargetExitDataOp` - `omp::UpdateDataOp` -> `omp::TargetUpdateOp`
1 parent 72d85b0 commit f1ad467

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,
468+
mlir::omp::TargetDataOp &dataOp,
469469
const llvm::SmallVector<mlir::Type> &useDeviceTypes,
470470
const llvm::SmallVector<mlir::Location> &useDeviceLocs,
471471
const llvm::SmallVector<const Fortran::semantics::Symbol *>
@@ -779,8 +779,8 @@ genTaskOp(Fortran::lower::AbstractConverter &converter,
779779
dependOperands, allocateOperands, allocatorOperands);
780780
}
781781

782-
static mlir::omp::TaskGroupOp
783-
genTaskGroupOp(Fortran::lower::AbstractConverter &converter,
782+
static mlir::omp::TaskgroupOp
783+
genTaskgroupOp(Fortran::lower::AbstractConverter &converter,
784784
Fortran::semantics::SemanticsContext &semaCtx,
785785
Fortran::lower::pft::Evaluation &eval, bool genNested,
786786
mlir::Location currentLocation,
@@ -790,7 +790,7 @@ genTaskGroupOp(Fortran::lower::AbstractConverter &converter,
790790
cp.processAllocate(allocatorOperands, allocateOperands);
791791
cp.processTODO<Fortran::parser::OmpClause::TaskReduction>(
792792
currentLocation, llvm::omp::Directive::OMPD_taskgroup);
793-
return genOpWithBody<mlir::omp::TaskGroupOp>(
793+
return genOpWithBody<mlir::omp::TaskgroupOp>(
794794
OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
795795
.setGenNested(genNested)
796796
.setClauses(&clauseList),
@@ -850,12 +850,12 @@ static void promoteNonCPtrUseDevicePtrArgsToUseDeviceAddr(
850850
}
851851
}
852852

853-
static mlir::omp::DataOp
854-
genDataOp(Fortran::lower::AbstractConverter &converter,
855-
Fortran::semantics::SemanticsContext &semaCtx,
856-
Fortran::lower::pft::Evaluation &eval, bool genNested,
857-
mlir::Location currentLocation,
858-
const Fortran::parser::OmpClauseList &clauseList) {
853+
static mlir::omp::TargetDataOp
854+
genTargetDataOp(Fortran::lower::AbstractConverter &converter,
855+
Fortran::semantics::SemanticsContext &semaCtx,
856+
Fortran::lower::pft::Evaluation &eval, bool genNested,
857+
mlir::Location currentLocation,
858+
const Fortran::parser::OmpClauseList &clauseList) {
859859
Fortran::lower::StatementContext stmtCtx;
860860
mlir::Value ifClauseOperand, deviceOperand;
861861
llvm::SmallVector<mlir::Value> mapOperands, devicePtrOperands,
@@ -889,7 +889,7 @@ genDataOp(Fortran::lower::AbstractConverter &converter,
889889
cp.processMap(currentLocation, llvm::omp::Directive::OMPD_target_data,
890890
stmtCtx, mapOperands);
891891

892-
auto dataOp = converter.getFirOpBuilder().create<mlir::omp::DataOp>(
892+
auto dataOp = converter.getFirOpBuilder().create<mlir::omp::TargetDataOp>(
893893
currentLocation, ifClauseOperand, deviceOperand, devicePtrOperands,
894894
deviceAddrOperands, mapOperands);
895895
genBodyOfTargetDataOp(converter, semaCtx, eval, genNested, dataOp,
@@ -900,7 +900,7 @@ genDataOp(Fortran::lower::AbstractConverter &converter,
900900

901901
template <typename OpTy>
902902
static OpTy
903-
genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
903+
genTargetEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
904904
Fortran::semantics::SemanticsContext &semaCtx,
905905
mlir::Location currentLocation,
906906
const Fortran::parser::OmpClauseList &clauseList) {
@@ -914,15 +914,15 @@ genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
914914
Fortran::parser::OmpIfClause::DirectiveNameModifier directiveName;
915915
// GCC 9.3.0 emits a (probably) bogus warning about an unused variable.
916916
[[maybe_unused]] llvm::omp::Directive directive;
917-
if constexpr (std::is_same_v<OpTy, mlir::omp::EnterDataOp>) {
917+
if constexpr (std::is_same_v<OpTy, mlir::omp::TargetEnterDataOp>) {
918918
directiveName =
919919
Fortran::parser::OmpIfClause::DirectiveNameModifier::TargetEnterData;
920920
directive = llvm::omp::Directive::OMPD_target_enter_data;
921-
} else if constexpr (std::is_same_v<OpTy, mlir::omp::ExitDataOp>) {
921+
} else if constexpr (std::is_same_v<OpTy, mlir::omp::TargetExitDataOp>) {
922922
directiveName =
923923
Fortran::parser::OmpIfClause::DirectiveNameModifier::TargetExitData;
924924
directive = llvm::omp::Directive::OMPD_target_exit_data;
925-
} else if constexpr (std::is_same_v<OpTy, mlir::omp::UpdateDataOp>) {
925+
} else if constexpr (std::is_same_v<OpTy, mlir::omp::TargetUpdateOp>) {
926926
directiveName =
927927
Fortran::parser::OmpIfClause::DirectiveNameModifier::TargetUpdate;
928928
directive = llvm::omp::Directive::OMPD_target_update;
@@ -936,7 +936,7 @@ genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
936936
cp.processDepend(dependTypeOperands, dependOperands);
937937
cp.processNowait(nowaitAttr);
938938

939-
if constexpr (std::is_same_v<OpTy, mlir::omp::UpdateDataOp>) {
939+
if constexpr (std::is_same_v<OpTy, mlir::omp::TargetUpdateOp>) {
940940
cp.processMotionClauses<Fortran::parser::OmpClause::To>(stmtCtx,
941941
mapOperands);
942942
cp.processMotionClauses<Fortran::parser::OmpClause::From>(stmtCtx,
@@ -1409,19 +1409,19 @@ genOmpSimpleStandalone(Fortran::lower::AbstractConverter &converter,
14091409
firOpBuilder.create<mlir::omp::TaskyieldOp>(currentLocation);
14101410
break;
14111411
case llvm::omp::Directive::OMPD_target_data:
1412-
genDataOp(converter, semaCtx, eval, genNested, currentLocation,
1413-
opClauseList);
1412+
genTargetDataOp(converter, semaCtx, eval, genNested, currentLocation,
1413+
opClauseList);
14141414
break;
14151415
case llvm::omp::Directive::OMPD_target_enter_data:
1416-
genEnterExitUpdateDataOp<mlir::omp::EnterDataOp>(
1416+
genTargetEnterExitUpdateDataOp<mlir::omp::TargetEnterDataOp>(
14171417
converter, semaCtx, currentLocation, opClauseList);
14181418
break;
14191419
case llvm::omp::Directive::OMPD_target_exit_data:
1420-
genEnterExitUpdateDataOp<mlir::omp::ExitDataOp>(
1420+
genTargetEnterExitUpdateDataOp<mlir::omp::TargetExitDataOp>(
14211421
converter, semaCtx, currentLocation, opClauseList);
14221422
break;
14231423
case llvm::omp::Directive::OMPD_target_update:
1424-
genEnterExitUpdateDataOp<mlir::omp::UpdateDataOp>(
1424+
genTargetEnterExitUpdateDataOp<mlir::omp::TargetUpdateOp>(
14251425
converter, semaCtx, currentLocation, opClauseList);
14261426
break;
14271427
case llvm::omp::Directive::OMPD_ordered:
@@ -1907,15 +1907,15 @@ genOMP(Fortran::lower::AbstractConverter &converter,
19071907
beginClauseList, directive.v);
19081908
break;
19091909
case llvm::omp::Directive::OMPD_target_data:
1910-
genDataOp(converter, semaCtx, eval, /*genNested=*/true, currentLocation,
1911-
beginClauseList);
1910+
genTargetDataOp(converter, semaCtx, eval, /*genNested=*/true,
1911+
currentLocation, beginClauseList);
19121912
break;
19131913
case llvm::omp::Directive::OMPD_task:
19141914
genTaskOp(converter, semaCtx, eval, /*genNested=*/true, currentLocation,
19151915
beginClauseList);
19161916
break;
19171917
case llvm::omp::Directive::OMPD_taskgroup:
1918-
genTaskGroupOp(converter, semaCtx, eval, /*genNested=*/true,
1918+
genTaskgroupOp(converter, semaCtx, eval, /*genNested=*/true,
19191919
currentLocation, beginClauseList);
19201920
break;
19211921
case llvm::omp::Directive::OMPD_teams:

0 commit comments

Comments
 (0)