Skip to content

Commit 0651bbb

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 2f2f16f commit 0651bbb

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
@@ -447,7 +447,7 @@ static void genBodyOfTargetDataOp(
447447
Fortran::lower::AbstractConverter &converter,
448448
Fortran::semantics::SemanticsContext &semaCtx,
449449
Fortran::lower::pft::Evaluation &eval, bool genNested,
450-
mlir::omp::DataOp &dataOp, llvm::ArrayRef<mlir::Type> useDeviceTypes,
450+
mlir::omp::TargetDataOp &dataOp, llvm::ArrayRef<mlir::Type> useDeviceTypes,
451451
llvm::ArrayRef<mlir::Location> useDeviceLocs,
452452
llvm::ArrayRef<const Fortran::semantics::Symbol *> useDeviceSymbols,
453453
const mlir::Location &currentLocation) {
@@ -753,8 +753,8 @@ genTaskOp(Fortran::lower::AbstractConverter &converter,
753753
dependOperands, allocateOperands, allocatorOperands);
754754
}
755755

756-
static mlir::omp::TaskGroupOp
757-
genTaskGroupOp(Fortran::lower::AbstractConverter &converter,
756+
static mlir::omp::TaskgroupOp
757+
genTaskgroupOp(Fortran::lower::AbstractConverter &converter,
758758
Fortran::semantics::SemanticsContext &semaCtx,
759759
Fortran::lower::pft::Evaluation &eval, bool genNested,
760760
mlir::Location currentLocation,
@@ -764,7 +764,7 @@ genTaskGroupOp(Fortran::lower::AbstractConverter &converter,
764764
cp.processAllocate(allocatorOperands, allocateOperands);
765765
cp.processTODO<Fortran::parser::OmpClause::TaskReduction>(
766766
currentLocation, llvm::omp::Directive::OMPD_taskgroup);
767-
return genOpWithBody<mlir::omp::TaskGroupOp>(
767+
return genOpWithBody<mlir::omp::TaskgroupOp>(
768768
OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
769769
.setGenNested(genNested)
770770
.setClauses(&clauseList),
@@ -825,12 +825,12 @@ static void promoteNonCPtrUseDevicePtrArgsToUseDeviceAddr(
825825
}
826826
}
827827

828-
static mlir::omp::DataOp
829-
genDataOp(Fortran::lower::AbstractConverter &converter,
830-
Fortran::semantics::SemanticsContext &semaCtx,
831-
Fortran::lower::pft::Evaluation &eval, bool genNested,
832-
mlir::Location currentLocation,
833-
const Fortran::parser::OmpClauseList &clauseList) {
828+
static mlir::omp::TargetDataOp
829+
genTargetDataOp(Fortran::lower::AbstractConverter &converter,
830+
Fortran::semantics::SemanticsContext &semaCtx,
831+
Fortran::lower::pft::Evaluation &eval, bool genNested,
832+
mlir::Location currentLocation,
833+
const Fortran::parser::OmpClauseList &clauseList) {
834834
Fortran::lower::StatementContext stmtCtx;
835835
mlir::Value ifClauseOperand, deviceOperand;
836836
llvm::SmallVector<mlir::Value> mapOperands, devicePtrOperands,
@@ -863,7 +863,7 @@ genDataOp(Fortran::lower::AbstractConverter &converter,
863863
cp.processMap(currentLocation, llvm::omp::Directive::OMPD_target_data,
864864
stmtCtx, mapOperands);
865865

866-
auto dataOp = converter.getFirOpBuilder().create<mlir::omp::DataOp>(
866+
auto dataOp = converter.getFirOpBuilder().create<mlir::omp::TargetDataOp>(
867867
currentLocation, ifClauseOperand, deviceOperand, devicePtrOperands,
868868
deviceAddrOperands, mapOperands);
869869
genBodyOfTargetDataOp(converter, semaCtx, eval, genNested, dataOp,
@@ -874,7 +874,7 @@ genDataOp(Fortran::lower::AbstractConverter &converter,
874874

875875
template <typename OpTy>
876876
static OpTy
877-
genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
877+
genTargetEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
878878
Fortran::semantics::SemanticsContext &semaCtx,
879879
mlir::Location currentLocation,
880880
const Fortran::parser::OmpClauseList &clauseList) {
@@ -888,13 +888,13 @@ genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
888888
clause::If::DirectiveNameModifier directiveName;
889889
// GCC 9.3.0 emits a (probably) bogus warning about an unused variable.
890890
[[maybe_unused]] llvm::omp::Directive directive;
891-
if constexpr (std::is_same_v<OpTy, mlir::omp::EnterDataOp>) {
891+
if constexpr (std::is_same_v<OpTy, mlir::omp::TargetEnterDataOp>) {
892892
directiveName = clause::If::DirectiveNameModifier::TargetEnterData;
893893
directive = llvm::omp::Directive::OMPD_target_enter_data;
894-
} else if constexpr (std::is_same_v<OpTy, mlir::omp::ExitDataOp>) {
894+
} else if constexpr (std::is_same_v<OpTy, mlir::omp::TargetExitDataOp>) {
895895
directiveName = clause::If::DirectiveNameModifier::TargetExitData;
896896
directive = llvm::omp::Directive::OMPD_target_exit_data;
897-
} else if constexpr (std::is_same_v<OpTy, mlir::omp::UpdateDataOp>) {
897+
} else if constexpr (std::is_same_v<OpTy, mlir::omp::TargetUpdateOp>) {
898898
directiveName = clause::If::DirectiveNameModifier::TargetUpdate;
899899
directive = llvm::omp::Directive::OMPD_target_update;
900900
} else {
@@ -907,7 +907,7 @@ genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
907907
cp.processDepend(dependTypeOperands, dependOperands);
908908
cp.processNowait(nowaitAttr);
909909

910-
if constexpr (std::is_same_v<OpTy, mlir::omp::UpdateDataOp>) {
910+
if constexpr (std::is_same_v<OpTy, mlir::omp::TargetUpdateOp>) {
911911
cp.processMotionClauses<Fortran::parser::OmpClause::To>(stmtCtx,
912912
mapOperands);
913913
cp.processMotionClauses<Fortran::parser::OmpClause::From>(stmtCtx,
@@ -1379,19 +1379,19 @@ genOmpSimpleStandalone(Fortran::lower::AbstractConverter &converter,
13791379
firOpBuilder.create<mlir::omp::TaskyieldOp>(currentLocation);
13801380
break;
13811381
case llvm::omp::Directive::OMPD_target_data:
1382-
genDataOp(converter, semaCtx, eval, genNested, currentLocation,
1383-
opClauseList);
1382+
genTargetDataOp(converter, semaCtx, eval, genNested, currentLocation,
1383+
opClauseList);
13841384
break;
13851385
case llvm::omp::Directive::OMPD_target_enter_data:
1386-
genEnterExitUpdateDataOp<mlir::omp::EnterDataOp>(
1386+
genTargetEnterExitUpdateDataOp<mlir::omp::TargetEnterDataOp>(
13871387
converter, semaCtx, currentLocation, opClauseList);
13881388
break;
13891389
case llvm::omp::Directive::OMPD_target_exit_data:
1390-
genEnterExitUpdateDataOp<mlir::omp::ExitDataOp>(
1390+
genTargetEnterExitUpdateDataOp<mlir::omp::TargetExitDataOp>(
13911391
converter, semaCtx, currentLocation, opClauseList);
13921392
break;
13931393
case llvm::omp::Directive::OMPD_target_update:
1394-
genEnterExitUpdateDataOp<mlir::omp::UpdateDataOp>(
1394+
genTargetEnterExitUpdateDataOp<mlir::omp::TargetUpdateOp>(
13951395
converter, semaCtx, currentLocation, opClauseList);
13961396
break;
13971397
case llvm::omp::Directive::OMPD_ordered:
@@ -1844,15 +1844,15 @@ genOMP(Fortran::lower::AbstractConverter &converter,
18441844
beginClauseList, directive.v);
18451845
break;
18461846
case llvm::omp::Directive::OMPD_target_data:
1847-
genDataOp(converter, semaCtx, eval, /*genNested=*/true, currentLocation,
1848-
beginClauseList);
1847+
genTargetDataOp(converter, semaCtx, eval, /*genNested=*/true,
1848+
currentLocation, beginClauseList);
18491849
break;
18501850
case llvm::omp::Directive::OMPD_task:
18511851
genTaskOp(converter, semaCtx, eval, /*genNested=*/true, currentLocation,
18521852
beginClauseList);
18531853
break;
18541854
case llvm::omp::Directive::OMPD_taskgroup:
1855-
genTaskGroupOp(converter, semaCtx, eval, /*genNested=*/true,
1855+
genTaskgroupOp(converter, semaCtx, eval, /*genNested=*/true,
18561856
currentLocation, beginClauseList);
18571857
break;
18581858
case llvm::omp::Directive::OMPD_teams:

0 commit comments

Comments
 (0)