Skip to content

Commit d7d8d9d

Browse files
committed
OpenMP: C front-end support for dispatch + adjust_args
This patch adds support to the C front-end to parse the `dispatch` construct and the `adjust_args` clause. It also includes some common C/C++ bits for pragmas and attributes. Additional common C/C++ testcases are in a later patch in the series. gcc/c-family/ChangeLog: * c-attribs.cc (c_common_gnu_attributes): Add attribute for adjust_args need_device_ptr. * c-omp.cc (c_omp_directives): Uncomment dispatch. * c-pragma.cc (omp_pragmas): Add dispatch. * c-pragma.h (enum pragma_kind): Add PRAGMA_OMP_DISPATCH. (enum pragma_omp_clause): Add PRAGMA_OMP_CLAUSE_NOCONTEXT and PRAGMA_OMP_CLAUSE_NOVARIANTS. gcc/c/ChangeLog: * c-parser.cc (c_parser_omp_dispatch): New function. (c_parser_omp_clause_name): Handle nocontext and novariants clauses. (c_parser_omp_clause_novariants): New function. (c_parser_omp_clause_nocontext): Likewise. (c_parser_omp_all_clauses): Handle nocontext and novariants clauses. (c_parser_omp_dispatch_body): New function adapted from c_parser_expr_no_commas. (OMP_DISPATCH_CLAUSE_MASK): Define. (c_parser_omp_dispatch): New function. (c_finish_omp_declare_variant): Parse adjust_args. (c_parser_omp_construct): Handle PRAGMA_OMP_DISPATCH. * c-typeck.cc (c_finish_omp_clauses): Handle OMP_CLAUSE_NOVARIANTS and OMP_CLAUSE_NOCONTEXT. gcc/testsuite/ChangeLog: * gcc.dg/gomp/adjust-args-1.c: New test. * gcc.dg/gomp/dispatch-1.c: New test. * gcc.dg/gomp/dispatch-2.c: New test. * gcc.dg/gomp/dispatch-3.c: New test. * gcc.dg/gomp/dispatch-4.c: New test. * gcc.dg/gomp/dispatch-5.c: New test.
1 parent 084ea8a commit d7d8d9d

File tree

12 files changed

+614
-57
lines changed

12 files changed

+614
-57
lines changed

gcc/c-family/c-attribs.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,9 @@ const struct attribute_spec c_common_gnu_attributes[] =
572572
handle_omp_declare_variant_attribute, NULL },
573573
{ "omp declare variant variant", 0, -1, true, false, false, false,
574574
handle_omp_declare_variant_attribute, NULL },
575+
{ "omp declare variant adjust_args need_device_ptr", 0, -1, true, false,
576+
false, false,
577+
handle_omp_declare_variant_attribute, NULL },
575578
{ "simd", 0, 1, true, false, false, false,
576579
handle_simd_attribute, NULL },
577580
{ "omp declare target", 0, -1, true, false, false, false,

gcc/c-family/c-omp.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4300,8 +4300,8 @@ const struct c_omp_directive c_omp_directives[] = {
43004300
C_OMP_DIR_DECLARATIVE, false },
43014301
{ "depobj", nullptr, nullptr, PRAGMA_OMP_DEPOBJ,
43024302
C_OMP_DIR_STANDALONE, false },
4303-
/* { "dispatch", nullptr, nullptr, PRAGMA_OMP_DISPATCH,
4304-
C_OMP_DIR_CONSTRUCT, false }, */
4303+
{ "dispatch", nullptr, nullptr, PRAGMA_OMP_DISPATCH,
4304+
C_OMP_DIR_DECLARATIVE, false },
43054305
{ "distribute", nullptr, nullptr, PRAGMA_OMP_DISTRIBUTE,
43064306
C_OMP_DIR_CONSTRUCT, true },
43074307
{ "end", "assumes", nullptr, PRAGMA_OMP_END,

gcc/c-family/c-pragma.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,6 +1525,7 @@ static const struct omp_pragma_def omp_pragmas[] = {
15251525
{ "cancellation", PRAGMA_OMP_CANCELLATION_POINT },
15261526
{ "critical", PRAGMA_OMP_CRITICAL },
15271527
{ "depobj", PRAGMA_OMP_DEPOBJ },
1528+
{ "dispatch", PRAGMA_OMP_DISPATCH },
15281529
{ "error", PRAGMA_OMP_ERROR },
15291530
{ "end", PRAGMA_OMP_END },
15301531
{ "flush", PRAGMA_OMP_FLUSH },

gcc/c-family/c-pragma.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ enum pragma_kind {
5555
PRAGMA_OMP_CRITICAL,
5656
PRAGMA_OMP_DECLARE,
5757
PRAGMA_OMP_DEPOBJ,
58+
PRAGMA_OMP_DISPATCH,
5859
PRAGMA_OMP_DISTRIBUTE,
5960
PRAGMA_OMP_ERROR,
6061
PRAGMA_OMP_END,
@@ -135,9 +136,11 @@ enum pragma_omp_clause {
135136
PRAGMA_OMP_CLAUSE_LINK,
136137
PRAGMA_OMP_CLAUSE_MAP,
137138
PRAGMA_OMP_CLAUSE_MERGEABLE,
139+
PRAGMA_OMP_CLAUSE_NOCONTEXT,
138140
PRAGMA_OMP_CLAUSE_NOGROUP,
139141
PRAGMA_OMP_CLAUSE_NONTEMPORAL,
140142
PRAGMA_OMP_CLAUSE_NOTINBRANCH,
143+
PRAGMA_OMP_CLAUSE_NOVARIANTS,
141144
PRAGMA_OMP_CLAUSE_NOWAIT,
142145
PRAGMA_OMP_CLAUSE_NUM_TASKS,
143146
PRAGMA_OMP_CLAUSE_NUM_TEAMS,

0 commit comments

Comments
 (0)