Skip to content

Commit 9a7895d

Browse files
sameeran joshiSameeranjoshi
authored andcommitted
[Flang][openmp][5.0] Add task_reduction clause.
See OMP-5.0 2.19.5.5 task_reduction Clause. To add a positive test case we need `taskgroup` directive which is not added hence skipping the test. This is a dependency for `taskgroup` construct. Reviewed By: clementval Differential Revision: https://reviews.llvm.org/D93105
1 parent 8eec729 commit 9a7895d

File tree

7 files changed

+13
-5
lines changed

7 files changed

+13
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3415,7 +3415,7 @@ struct OmpReductionOperator {
34153415
// variable-name-list)
34163416
struct OmpReductionClause {
34173417
TUPLE_CLASS_BOILERPLATE(OmpReductionClause);
3418-
std::tuple<OmpReductionOperator, std::list<Designator>> t;
3418+
std::tuple<OmpReductionOperator, OmpObjectList> t;
34193419
};
34203420

34213421
// OMP 5.0 2.11.4 allocate-clause -> ALLOCATE ([allocator:] variable-name-list)

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ TYPE_PARSER(construct<OmpReductionOperator>(Parser<DefinedOperator>{}) ||
102102
construct<OmpReductionOperator>(Parser<ProcedureDesignator>{}))
103103

104104
TYPE_PARSER(construct<OmpReductionClause>(
105-
Parser<OmpReductionOperator>{} / ":", nonemptyList(designator)))
105+
Parser<OmpReductionOperator>{} / ":", Parser<OmpObjectList>{}))
106106

107107
// OMP 5.0 2.11.4 ALLOCATE ([allocator:] variable-name-list)
108108
TYPE_PARSER(construct<OmpAllocateClause>(
@@ -220,6 +220,9 @@ TYPE_PARSER(
220220
parenthesized(Parser<OmpProcBindClause>{}))) ||
221221
"REDUCTION" >>
222222
construct<OmpClause>(parenthesized(Parser<OmpReductionClause>{})) ||
223+
"TASK_REDUCTION" >>
224+
construct<OmpClause>(construct<OmpClause::TaskReduction>(
225+
parenthesized(Parser<OmpReductionClause>{}))) ||
223226
"RELAXED" >> construct<OmpClause>(construct<OmpClause::Relaxed>()) ||
224227
"RELEASE" >> construct<OmpClause>(construct<OmpClause::Release>()) ||
225228
"SAFELEN" >> construct<OmpClause>(construct<OmpClause::Safelen>(

flang/lib/Parser/unparse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@ class UnparseVisitor {
20162016
Word("REDUCTION(");
20172017
Walk(std::get<OmpReductionOperator>(x.t));
20182018
Put(":");
2019-
Walk(std::get<std::list<Designator>>(x.t), ",");
2019+
Walk(std::get<OmpObjectList>(x.t));
20202020
Put(")");
20212021
}
20222022
void Unparse(const OmpAllocateClause &x) {

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ CHECK_SIMPLE_CLAUSE(Mergeable, OMPC_mergeable)
419419
CHECK_SIMPLE_CLAUSE(Nogroup, OMPC_nogroup)
420420
CHECK_SIMPLE_CLAUSE(Notinbranch, OMPC_notinbranch)
421421
CHECK_SIMPLE_CLAUSE(Nowait, OMPC_nowait)
422+
CHECK_SIMPLE_CLAUSE(TaskReduction, OMPC_task_reduction)
422423
CHECK_SIMPLE_CLAUSE(To, OMPC_to)
423424
CHECK_SIMPLE_CLAUSE(Uniform, OMPC_uniform)
424425
CHECK_SIMPLE_CLAUSE(Untied, OMPC_untied)

flang/lib/Semantics/check-omp-structure.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class OmpStructureChecker
155155
void Enter(const parser::OmpClause::Safelen &);
156156
void Enter(const parser::OmpClause::Shared &);
157157
void Enter(const parser::OmpClause::Simdlen &);
158+
void Enter(const parser::OmpClause::TaskReduction &);
158159
void Enter(const parser::OmpClause::ThreadLimit &);
159160
void Enter(const parser::OmpClause::To &);
160161
void Enter(const parser::OmpClause::Link &);

flang/test/Semantics/omp-clause-validity01.f90

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,8 @@
349349
! collapse-clause
350350

351351
a = 0.0
352-
!$omp simd private(b) reduction(+:a)
352+
!ERROR: TASK_REDUCTION clause is not allowed on the SIMD directive
353+
!$omp simd private(b) reduction(+:a) task_reduction(+:a)
353354
do i = 1, N
354355
a = a + b + 3.14
355356
enddo
@@ -449,7 +450,8 @@
449450
enddo
450451

451452
!ERROR: At most one NUM_TASKS clause can appear on the TASKLOOP directive
452-
!$omp taskloop num_tasks(3) num_tasks(2)
453+
!ERROR: TASK_REDUCTION clause is not allowed on the TASKLOOP directive
454+
!$omp taskloop num_tasks(3) num_tasks(2) task_reduction(*:a)
453455
do i = 1,N
454456
a = 3.14
455457
enddo

llvm/include/llvm/Frontend/OpenMP/OMP.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ def OMPC_IsDevicePtr : Clause<"is_device_ptr"> {
231231
}
232232
def OMPC_TaskReduction : Clause<"task_reduction"> {
233233
let clangClass = "OMPTaskReductionClause";
234+
let flangClassValue = "OmpReductionClause";
234235
}
235236
def OMPC_InReduction : Clause<"in_reduction"> {
236237
let clangClass = "OMPInReductionClause";

0 commit comments

Comments
 (0)