diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2023-10-20 14:47:58 +0200 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2023-10-25 11:02:27 +0200 |
commit | c92509d9fd98e02d17ab1610f696c88f606dcdf4 (patch) | |
tree | bf09f4a59da22fd7f265c21fa59f410deddcf085 /gcc/c | |
parent | 76cc5463227308c4dd2b70ccfe04d2b5361db0fe (diff) | |
download | gcc-c92509d9fd98e02d17ab1610f696c88f606dcdf4.zip gcc-c92509d9fd98e02d17ab1610f696c88f606dcdf4.tar.gz gcc-c92509d9fd98e02d17ab1610f696c88f606dcdf4.tar.bz2 |
Disentangle handling of OpenACC 'host', 'self' pragma tokens
'gcc/c-family/c-pragma.h:pragma_omp_clause' already defines
'PRAGMA_OACC_CLAUSE_SELF', but it has no longer been used for the 'update'
directive's 'self' clause as of 2018
commit 829c6349e96c5bfa8603aaef8858b38e237a2f33 (Subversion r261813)
"Update OpenACC data clause semantics to the 2.5 behavior". That one instead
mapped the 'self' pragma token to the 'host' one (same semantics). That means
that we're later not able to tell whether originally we had seen 'self' or
'host', which was OK as long as only the 'update' directive had a 'self'
clause. However, as of recent commit 3a3596389c2e539cb8fd5dc5784a4e2afe193a2a
"OpenACC 2.7: Implement self clause for compute constructs", also OpenACC
compute constructs may have a 'self' clause -- with different semantics. That
means, we need to know which OpenACC directive we're parsing clauses for, which
can be done in a simpler way than in that commit, similar to how the OpenMP
'to' clause is handled.
While at that, clarify that (already in OpenACC 2.0a)
"The 'host' clause is a synonym for the 'self' clause." -- not the other way
round.
gcc/c/
* c-parser.cc (c_parser_omp_clause_name): Return
'PRAGMA_OACC_CLAUSE_SELF' for "self".
(c_parser_oacc_data_clause, OACC_UPDATE_CLAUSE_MASK): Adjust.
(c_parser_oacc_all_clauses): Remove 'bool compute_p' formal
parameter, and instead locally determine whether we're called for
an OpenACC compute construct or OpenACC 'update' directive.
(c_parser_oacc_compute): Adjust.
gcc/cp/
* parser.cc (cp_parser_omp_clause_name): Return
'PRAGMA_OACC_CLAUSE_SELF' for "self".
(cp_parser_oacc_data_clause, OACC_UPDATE_CLAUSE_MASK): Adjust.
(cp_parser_oacc_all_clauses): Remove 'bool compute_p' formal
parameter, and instead locally determine whether we're called for
an OpenACC compute construct or OpenACC 'update' directive.
(cp_parser_oacc_compute): Adjust.
gcc/fortran/
* openmp.cc (omp_mask2): Split 'OMP_CLAUSE_HOST_SELF' into
'OMP_CLAUSE_SELF', 'OMP_CLAUSE_HOST'.
(gfc_match_omp_clauses, OACC_UPDATE_CLAUSES): Adjust.
Diffstat (limited to 'gcc/c')
-rw-r--r-- | gcc/c/c-parser.cc | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc index a82f5af..5213a57 100644 --- a/gcc/c/c-parser.cc +++ b/gcc/c/c-parser.cc @@ -14061,8 +14061,8 @@ c_parser_omp_clause_name (c_parser *parser) result = PRAGMA_OMP_CLAUSE_SCHEDULE; else if (!strcmp ("sections", p)) result = PRAGMA_OMP_CLAUSE_SECTIONS; - else if (!strcmp ("self", p)) /* "self" is a synonym for "host". */ - result = PRAGMA_OACC_CLAUSE_HOST; + else if (!strcmp ("self", p)) + result = PRAGMA_OACC_CLAUSE_SELF; else if (!strcmp ("seq", p)) result = PRAGMA_OACC_CLAUSE_SEQ; else if (!strcmp ("shared", p)) @@ -14583,9 +14583,6 @@ c_parser_oacc_data_clause (c_parser *parser, pragma_omp_clause c_kind, case PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT: kind = GOMP_MAP_DEVICE_RESIDENT; break; - case PRAGMA_OACC_CLAUSE_HOST: - kind = GOMP_MAP_FORCE_FROM; - break; case PRAGMA_OACC_CLAUSE_LINK: kind = GOMP_MAP_LINK; break; @@ -14595,6 +14592,11 @@ c_parser_oacc_data_clause (c_parser *parser, pragma_omp_clause c_kind, case PRAGMA_OACC_CLAUSE_PRESENT: kind = GOMP_MAP_FORCE_PRESENT; break; + case PRAGMA_OACC_CLAUSE_SELF: + /* "The 'host' clause is a synonym for the 'self' clause." */ + case PRAGMA_OACC_CLAUSE_HOST: + kind = GOMP_MAP_FORCE_FROM; + break; default: gcc_unreachable (); } @@ -18083,8 +18085,7 @@ c_parser_omp_clause_detach (c_parser *parser, tree list) static tree c_parser_oacc_all_clauses (c_parser *parser, omp_clause_mask mask, - const char *where, bool finish_p = true, - bool compute_p = false) + const char *where, bool finish_p = true) { tree clauses = NULL; bool first = true; @@ -18100,18 +18101,7 @@ c_parser_oacc_all_clauses (c_parser *parser, omp_clause_mask mask, c_parser_consume_token (parser); here = c_parser_peek_token (parser)->location; - - /* For OpenACC compute directives */ - if (compute_p - && c_parser_next_token_is (parser, CPP_NAME) - && !strcmp (IDENTIFIER_POINTER (c_parser_peek_token (parser)->value), - "self")) - { - c_kind = PRAGMA_OACC_CLAUSE_SELF; - c_parser_consume_token (parser); - } - else - c_kind = c_parser_omp_clause_name (parser); + c_kind = c_parser_omp_clause_name (parser); switch (c_kind) { @@ -18244,7 +18234,12 @@ c_parser_oacc_all_clauses (c_parser *parser, omp_clause_mask mask, c_name = "reduction"; break; case PRAGMA_OACC_CLAUSE_SELF: - clauses = c_parser_oacc_compute_clause_self (parser, clauses); + if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_HOST)) == 0) + /* OpenACC compute construct */ + clauses = c_parser_oacc_compute_clause_self (parser, clauses); + else + /* OpenACC 'update' directive */ + clauses = c_parser_oacc_data_clause (parser, c_kind, clauses); c_name = "self"; break; case PRAGMA_OACC_CLAUSE_SEQ: @@ -19166,7 +19161,7 @@ c_parser_oacc_compute (location_t loc, c_parser *parser, } } - tree clauses = c_parser_oacc_all_clauses (parser, mask, p_name, true, true); + tree clauses = c_parser_oacc_all_clauses (parser, mask, p_name); tree block = c_begin_omp_parallel (); add_stmt (c_parser_omp_structured_block (parser, if_p)); @@ -19366,6 +19361,7 @@ c_finish_oacc_routine (struct oacc_routine_data *data, tree fndecl, | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_HOST) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_IF_PRESENT) \ + | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_SELF) \ | (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WAIT) ) static void |