Skip to content

Commit 608f4ae

Browse files
authored
[flang][OpenMP] Rename some Type members in OpenMP clauses (#117784)
The intent is to keep names in sync with the terminology from the OpenMP spec: ``` OmpBindClause::Type -> Binding OmpDefaultClause::Type -> DataSharingAttribute OmpDeviceTypeClause::Type -> DeviceTypeDescription OmpProcBindClause::Type -> AffinityPolicy ``` Add more comments with references to the OpenMP specs.
1 parent 4ad4d34 commit 608f4ae

File tree

14 files changed

+146
-85
lines changed

14 files changed

+146
-85
lines changed

flang/examples/FeatureList/FeatureList.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ struct NodeVisitor {
465465
READ_FEATURE(OmpDeclareTargetWithClause)
466466
READ_FEATURE(OmpDeclareTargetWithList)
467467
READ_FEATURE(OmpDefaultClause)
468-
READ_FEATURE(OmpDefaultClause::Type)
468+
READ_FEATURE(OmpDefaultClause::DataSharingAttribute)
469469
READ_FEATURE(OmpDefaultmapClause)
470470
READ_FEATURE(OmpDefaultmapClause::ImplicitBehavior)
471471
READ_FEATURE(OmpVariableCategory::Value)
@@ -508,7 +508,7 @@ struct NodeVisitor {
508508
READ_FEATURE(OmpOrderModifier)
509509
READ_FEATURE(OmpOrderModifier::Value)
510510
READ_FEATURE(OmpProcBindClause)
511-
READ_FEATURE(OmpProcBindClause::Type)
511+
READ_FEATURE(OmpProcBindClause::AffinityPolicy)
512512
READ_FEATURE(OmpReductionClause)
513513
READ_FEATURE(OmpInReductionClause)
514514
READ_FEATURE(OmpReductionCombiner)
@@ -526,7 +526,7 @@ struct NodeVisitor {
526526
READ_FEATURE(OmpDeviceClause)
527527
READ_FEATURE(OmpDeviceClause::DeviceModifier)
528528
READ_FEATURE(OmpDeviceTypeClause)
529-
READ_FEATURE(OmpDeviceTypeClause::Type)
529+
READ_FEATURE(OmpDeviceTypeClause::DeviceTypeDescription)
530530
READ_FEATURE(OmpChunkModifier)
531531
READ_FEATURE(OmpChunkModifier::Value)
532532
READ_FEATURE(OmpOrderingModifier)

flang/examples/FlangOmpReport/FlangOmpReportVisitor.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,17 @@ void OpenMPCounterVisitor::PostConstructsCommon() {
190190
delete curConstruct;
191191
}
192192

193-
void OpenMPCounterVisitor::Post(const OmpProcBindClause::Type &c) {
193+
void OpenMPCounterVisitor::Post(const OmpProcBindClause::AffinityPolicy &c) {
194194
clauseDetails +=
195195
"type=" + std::string{OmpProcBindClause::EnumToString(c)} + ";";
196196
}
197-
void OpenMPCounterVisitor::Post(const OmpDefaultClause::Type &c) {
197+
void OpenMPCounterVisitor::Post(
198+
const OmpDefaultClause::DataSharingAttribute &c) {
198199
clauseDetails +=
199200
"type=" + std::string{OmpDefaultClause::EnumToString(c)} + ";";
200201
}
201-
void OpenMPCounterVisitor::Post(const OmpDeviceTypeClause::Type &c) {
202+
void OpenMPCounterVisitor::Post(
203+
const OmpDeviceTypeClause::DeviceTypeDescription &c) {
202204
clauseDetails +=
203205
"type=" + std::string{OmpDeviceTypeClause::EnumToString(c)} + ";";
204206
}

flang/examples/FlangOmpReport/FlangOmpReportVisitor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,11 @@ struct OpenMPCounterVisitor {
6666
void Post(const OpenMPConstruct &);
6767
void PostConstructsCommon();
6868

69-
void Post(const OmpProcBindClause::Type &c);
70-
void Post(const OmpDefaultClause::Type &c);
69+
void Post(const OmpProcBindClause::AffinityPolicy &c);
70+
void Post(const OmpDefaultClause::DataSharingAttribute &c);
7171
void Post(const OmpDefaultmapClause::ImplicitBehavior &c);
7272
void Post(const OmpVariableCategory::Value &c);
73-
void Post(const OmpDeviceTypeClause::Type &c);
73+
void Post(const OmpDeviceTypeClause::DeviceTypeDescription &c);
7474
void Post(const OmpChunkModifier::Value &c);
7575
void Post(const OmpLinearModifier::Value &c);
7676
void Post(const OmpOrderingModifier::Value &c);

flang/include/flang/Parser/dump-parse-tree.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ class ParseTreeDumper {
515515
NODE(parser, OmpDeclareTargetWithList)
516516
NODE(parser, OmpDeclareMapperSpecifier)
517517
NODE(parser, OmpDefaultClause)
518-
NODE_ENUM(OmpDefaultClause, Type)
518+
NODE_ENUM(OmpDefaultClause, DataSharingAttribute)
519519
NODE(parser, OmpVariableCategory)
520520
NODE_ENUM(OmpVariableCategory, Value)
521521
NODE(parser, OmpDefaultmapClause)
@@ -575,9 +575,9 @@ class ParseTreeDumper {
575575
NODE(parser, OmpNumTasksClause)
576576
NODE_ENUM(OmpNumTasksClause, Prescriptiveness)
577577
NODE(parser, OmpBindClause)
578-
NODE_ENUM(OmpBindClause, Type)
578+
NODE_ENUM(OmpBindClause, Binding)
579579
NODE(parser, OmpProcBindClause)
580-
NODE_ENUM(OmpProcBindClause, Type)
580+
NODE_ENUM(OmpProcBindClause, AffinityPolicy)
581581
NODE(parser, OmpReductionModifier)
582582
NODE_ENUM(OmpReductionModifier, Value)
583583
NODE(parser, OmpReductionClause)
@@ -598,7 +598,7 @@ class ParseTreeDumper {
598598
NODE(parser, OmpDeviceClause)
599599
NODE_ENUM(OmpDeviceClause, DeviceModifier)
600600
NODE(parser, OmpDeviceTypeClause)
601-
NODE_ENUM(OmpDeviceTypeClause, Type)
601+
NODE_ENUM(OmpDeviceTypeClause, DeviceTypeDescription)
602602
NODE(parser, OmpUpdateClause)
603603
NODE(parser, OmpChunkModifier)
604604
NODE_ENUM(OmpChunkModifier, Value)

flang/include/flang/Parser/parse-tree.h

Lines changed: 93 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -3686,21 +3686,51 @@ struct OmpAllocateClause {
36863686
std::tuple<MODIFIERS(), OmpObjectList> t;
36873687
};
36883688

3689-
// OMP 5.0 2.4 atomic-default-mem-order-clause ->
3690-
// ATOMIC_DEFAULT_MEM_ORDER (SEQ_CST | ACQ_REL |
3691-
// RELAXED)
3689+
// Ref: [5.0:60-63], [5.1:83-86], [5.2:210-213]
3690+
//
3691+
// atomic-default-mem-order-clause ->
3692+
// ATOMIC_DEFAULT_MEM_ORDER(memory-order) // since 5.0
3693+
// memory-order ->
3694+
// SEQ_CST | ACQ_REL | RELAXED | // since 5.0
3695+
// ACQUIRE | RELEASE // since 5.2
36923696
struct OmpAtomicDefaultMemOrderClause {
3693-
WRAPPER_CLASS_BOILERPLATE(
3694-
OmpAtomicDefaultMemOrderClause, common::OmpAtomicDefaultMemOrderType);
3697+
using MemoryOrder = common::OmpAtomicDefaultMemOrderType;
3698+
WRAPPER_CLASS_BOILERPLATE(OmpAtomicDefaultMemOrderClause, MemoryOrder);
3699+
};
3700+
3701+
// Ref: [5.0:128-131], [5.1:151-154], [5.2:258-259]
3702+
//
3703+
// bind-clause ->
3704+
// BIND(binding) // since 5.0
3705+
// binding ->
3706+
// TEAMS | PARALLEL | THREAD // since 5.0
3707+
struct OmpBindClause {
3708+
ENUM_CLASS(Binding, Parallel, Teams, Thread)
3709+
WRAPPER_CLASS_BOILERPLATE(OmpBindClause, Binding);
36953710
};
36963711

3697-
// 2.15.3.1 default-clause -> DEFAULT (PRIVATE | FIRSTPRIVATE | SHARED | NONE)
3712+
// Ref: [4.5:46-50], [5.0:74-78], [5.1:92-96], [5.2:109]
3713+
//
3714+
// default-clause ->
3715+
// DEFAULT(data-sharing-attribute) // since 4.5
3716+
// data-sharing-attribute ->
3717+
// SHARED | NONE | // since 4.5
3718+
// PRIVATE | FIRSTPRIVATE // since 5.0
36983719
struct OmpDefaultClause {
3699-
ENUM_CLASS(Type, Private, Firstprivate, Shared, None)
3700-
WRAPPER_CLASS_BOILERPLATE(OmpDefaultClause, Type);
3720+
ENUM_CLASS(DataSharingAttribute, Private, Firstprivate, Shared, None)
3721+
WRAPPER_CLASS_BOILERPLATE(OmpDefaultClause, DataSharingAttribute);
37013722
};
37023723

3703-
// 2.15.5.2 defaultmap -> DEFAULTMAP (implicit-behavior[:variable-category])
3724+
// Ref: [4.5:103-107], [5.0:324-325], [5.1:357-358], [5.2:161-162]
3725+
//
3726+
// defaultmap-clause ->
3727+
// DEFAULTMAP(implicit-behavior
3728+
// [: variable-category]) // since 5.0
3729+
// implicit-behavior ->
3730+
// TOFROM | // since 4.5
3731+
// ALLOC | TO | FROM | FIRSTPRIVATE | NONE |
3732+
// DEFAULT | // since 5.0
3733+
// PRESENT // since 5.1
37043734
struct OmpDefaultmapClause {
37053735
TUPLE_CLASS_BOILERPLATE(OmpDefaultmapClause);
37063736
ENUM_CLASS(
@@ -3709,23 +3739,35 @@ struct OmpDefaultmapClause {
37093739
std::tuple<ImplicitBehavior, MODIFIERS()> t;
37103740
};
37113741

3712-
// 2.13.9 iteration-offset -> +/- non-negative-constant
3742+
// Ref: [4.5:169-172], [5.0:255-259], [5.1:288-292], [5.2:91-93]
3743+
//
3744+
// iteration-offset ->
3745+
// +|- non-negative-constant // since 4.5
37133746
struct OmpIterationOffset {
37143747
TUPLE_CLASS_BOILERPLATE(OmpIterationOffset);
37153748
std::tuple<DefinedOperator, ScalarIntConstantExpr> t;
37163749
};
37173750

3718-
// 2.13.9 iteration -> induction-variable [iteration-offset]
3751+
// Ref: [4.5:169-172], [5.0:255-259], [5.1:288-292], [5.2:91-93]
3752+
//
3753+
// iteration ->
3754+
// induction-variable [iteration-offset] // since 4.5
37193755
struct OmpIteration {
37203756
TUPLE_CLASS_BOILERPLATE(OmpIteration);
37213757
std::tuple<Name, std::optional<OmpIterationOffset>> t;
37223758
};
37233759

3760+
// Ref: [4.5:169-172], [5.0:255-259], [5.1:288-292], [5.2:91-93]
3761+
//
3762+
// iteration-vector ->
3763+
// [iteration...] // since 4.5
37243764
WRAPPER_CLASS(OmpIterationVector, std::list<OmpIteration>);
37253765

37263766
// Extract this into a separate structure (instead of having it directly in
37273767
// OmpDoacrossClause), so that the context in TYPE_CONTEXT_PARSER can be set
37283768
// separately for OmpDependClause and OmpDoacrossClause.
3769+
//
3770+
// See: depend-clause, doacross-clause
37293771
struct OmpDoacross {
37303772
OmpDependenceType::Value GetDepType() const;
37313773

@@ -3735,15 +3777,15 @@ struct OmpDoacross {
37353777
std::variant<Sink, Source> u;
37363778
};
37373779

3738-
// Ref: [4.5:169-170], [5.0:255-256], [5.1:288-289], [5.2:323-324]
3780+
// Ref: [4.5:169-172], [5.0:255-259], [5.1:288-292], [5.2:323-326]
37393781
//
37403782
// depend-clause ->
3741-
// DEPEND(SOURCE) | // since 4.5, until 5.1
3742-
// DEPEND(SINK: iteration-vector) | // since 4.5, until 5.1
3783+
// DEPEND(SOURCE) | // since 4.5, until 5.1
3784+
// DEPEND(SINK: iteration-vector) | // since 4.5, until 5.1
37433785
// DEPEND([depend-modifier,]
3744-
// task-dependence-type: locator-list) // since 4.5
3786+
// task-dependence-type: locator-list) // since 4.5
37453787
//
3746-
// depend-modifier -> iterator-modifier // since 5.0
3788+
// depend-modifier -> iterator-modifier // since 5.0
37473789
struct OmpDependClause {
37483790
UNION_CLASS_BOILERPLATE(OmpDependClause);
37493791
struct TaskDep {
@@ -3755,6 +3797,10 @@ struct OmpDependClause {
37553797
std::variant<TaskDep, OmpDoacross> u;
37563798
};
37573799

3800+
// Ref: [5.2:326-328]
3801+
//
3802+
// doacross-clause ->
3803+
// DOACROSS(dependence-type: iteration-vector) // since 5.2
37583804
WRAPPER_CLASS(OmpDoacrossClause, OmpDoacross);
37593805

37603806
// Ref: [5.0:254-255], [5.1:287-288], [5.2:73]
@@ -3764,25 +3810,41 @@ WRAPPER_CLASS(OmpDoacrossClause, OmpDoacross);
37643810
// DESTROY(variable) // since 5.2
37653811
WRAPPER_CLASS(OmpDestroyClause, OmpObject);
37663812

3767-
// device([ device-modifier :] scalar-integer-expression)
3813+
// Ref: [5.0:135-140], [5.1:161-166], [5.2:265-266]
3814+
//
3815+
// detach-clause ->
3816+
// DETACH(event-handle) // since 5.0
3817+
struct OmpDetachClause {
3818+
WRAPPER_CLASS_BOILERPLATE(OmpDetachClause, OmpObject);
3819+
};
3820+
3821+
// Ref: [4.5:103-107], [5.0:170-176], [5.1:197-205], [5.2:276-277]
3822+
//
3823+
// device-clause ->
3824+
// DEVICE(scalar-integer-expression) | // since 4.5
3825+
// DEVICE([device-modifier:]
3826+
// scalar-integer-expression) // since 5.0
37683827
struct OmpDeviceClause {
37693828
TUPLE_CLASS_BOILERPLATE(OmpDeviceClause);
37703829
ENUM_CLASS(DeviceModifier, Ancestor, Device_Num)
37713830
std::tuple<std::optional<DeviceModifier>, ScalarIntExpr> t;
37723831
};
37733832

3774-
// device_type(any | host | nohost)
3833+
// Ref: [5.0:180-185], [5.1:210-216], [5.2:275]
3834+
//
3835+
// device-type-clause ->
3836+
// DEVICE_TYPE(ANY | HOST | NOHOST) // since 5.0
37753837
struct OmpDeviceTypeClause {
3776-
ENUM_CLASS(Type, Any, Host, Nohost)
3777-
WRAPPER_CLASS_BOILERPLATE(OmpDeviceTypeClause, Type);
3838+
ENUM_CLASS(DeviceTypeDescription, Any, Host, Nohost)
3839+
WRAPPER_CLASS_BOILERPLATE(OmpDeviceTypeClause, DeviceTypeDescription);
37783840
};
37793841

37803842
// Ref: [4.5:107-109], [5.0:176-180], [5.1:205-210], [5.2:167-168]
37813843
//
37823844
// from-clause ->
37833845
// FROM(locator-list) |
3784-
// FROM(mapper-modifier: locator-list) | // since 5.0
3785-
// FROM(motion-modifier[,] ...: locator-list) // since 5.1
3846+
// FROM(mapper-modifier: locator-list) | // since 5.0
3847+
// FROM(motion-modifier[,] ...: locator-list) // since 5.1
37863848
// motion-modifier ->
37873849
// PRESENT | mapper-modifier | iterator-modifier
37883850
struct OmpFromClause {
@@ -3806,11 +3868,6 @@ struct OmpIfClause {
38063868
std::tuple<std::optional<DirectiveNameModifier>, ScalarLogicalExpr> t;
38073869
};
38083870

3809-
// OpenMPv5.2 12.5.2 detach-clause -> DETACH (event-handle)
3810-
struct OmpDetachClause {
3811-
WRAPPER_CLASS_BOILERPLATE(OmpDetachClause, OmpObject);
3812-
};
3813-
38143871
// OMP 5.0 2.19.5.6 in_reduction-clause -> IN_REDUCTION (reduction-identifier:
38153872
// variable-name-list)
38163873
struct OmpInReductionClause {
@@ -3878,10 +3935,16 @@ struct OmpOrderClause {
38783935
std::tuple<MODIFIERS(), Ordering> t;
38793936
};
38803937

3881-
// 2.5 proc-bind-clause -> PROC_BIND (MASTER | CLOSE | SPREAD)
3938+
// Ref: [4.5:46-50], [5.0:74-78], [5.1:92-96], [5.2:229-230]
3939+
//
3940+
// proc-bind-clause ->
3941+
// PROC_BIND(affinity-policy) // since 4.5
3942+
// affinity-policy ->
3943+
// CLOSE | PRIMARY | SPREAD | // since 4.5
3944+
// MASTER // since 4.5, until 5.2
38823945
struct OmpProcBindClause {
3883-
ENUM_CLASS(Type, Close, Master, Spread, Primary)
3884-
WRAPPER_CLASS_BOILERPLATE(OmpProcBindClause, Type);
3946+
ENUM_CLASS(AffinityPolicy, Close, Master, Spread, Primary)
3947+
WRAPPER_CLASS_BOILERPLATE(OmpProcBindClause, AffinityPolicy);
38853948
};
38863949

38873950
// Ref: [4.5:201-207], [5.0:300-302], [5.1:332-334], [5.2:134-137]
@@ -3945,13 +4008,6 @@ struct OmpUpdateClause {
39454008
std::variant<OmpDependenceType, OmpTaskDependenceType> u;
39464009
};
39474010

3948-
// OMP 5.2 11.7.1 bind-clause ->
3949-
// BIND( PARALLEL | TEAMS | THREAD )
3950-
struct OmpBindClause {
3951-
ENUM_CLASS(Type, Parallel, Teams, Thread)
3952-
WRAPPER_CLASS_BOILERPLATE(OmpBindClause, Type);
3953-
};
3954-
39554011
// OpenMP Clauses
39564012
struct OmpClause {
39574013
UNION_CLASS_BOILERPLATE(OmpClause);

flang/lib/Lower/OpenMP/Clauses.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ Bind make(const parser::OmpClause::Bind &inp,
478478
using wrapped = parser::OmpBindClause;
479479

480480
CLAUSET_ENUM_CONVERT( //
481-
convert, wrapped::Type, Bind::Binding,
481+
convert, wrapped::Binding, Bind::Binding,
482482
// clang-format off
483483
MS(Teams, Teams)
484484
MS(Parallel, Parallel)
@@ -523,7 +523,7 @@ Default make(const parser::OmpClause::Default &inp,
523523
using wrapped = parser::OmpDefaultClause;
524524

525525
CLAUSET_ENUM_CONVERT( //
526-
convert, wrapped::Type, Default::DataSharingAttribute,
526+
convert, wrapped::DataSharingAttribute, Default::DataSharingAttribute,
527527
// clang-format off
528528
MS(Firstprivate, Firstprivate)
529529
MS(None, None)
@@ -680,7 +680,8 @@ DeviceType make(const parser::OmpClause::DeviceType &inp,
680680
using wrapped = parser::OmpDeviceTypeClause;
681681

682682
CLAUSET_ENUM_CONVERT( //
683-
convert, wrapped::Type, DeviceType::DeviceTypeDescription,
683+
convert, wrapped::DeviceTypeDescription,
684+
DeviceType::DeviceTypeDescription,
684685
// clang-format off
685686
MS(Any, Any)
686687
MS(Host, Host)
@@ -1142,7 +1143,7 @@ ProcBind make(const parser::OmpClause::ProcBind &inp,
11421143
using wrapped = parser::OmpProcBindClause;
11431144

11441145
CLAUSET_ENUM_CONVERT( //
1145-
convert, wrapped::Type, ProcBind::AffinityPolicy,
1146+
convert, wrapped::AffinityPolicy, ProcBind::AffinityPolicy,
11461147
// clang-format off
11471148
MS(Close, Close)
11481149
MS(Master, Master)

0 commit comments

Comments
 (0)