'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.
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))
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;
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 ();
}
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;
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)
{
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:
}
}
- 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));
| (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
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))
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;
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 ();
}
static tree
cp_parser_oacc_all_clauses (cp_parser *parser, omp_clause_mask mask,
const char *where, cp_token *pragma_tok,
- bool finish_p = true, bool compute_p = false)
+ bool finish_p = true)
{
tree clauses = NULL;
bool first = true;
cp_lexer_consume_token (parser->lexer);
here = cp_lexer_peek_token (parser->lexer)->location;
-
- /* For OpenACC compute directives */
- if (compute_p
- && cp_lexer_next_token_is (parser->lexer, CPP_NAME)
- && !strcmp (IDENTIFIER_POINTER
- (cp_lexer_peek_token (parser->lexer)->u.value),
- "self"))
- {
- c_kind = PRAGMA_OACC_CLAUSE_SELF;
- cp_lexer_consume_token (parser->lexer);
- }
- else
- c_kind = cp_parser_omp_clause_name (parser);
+ c_kind = cp_parser_omp_clause_name (parser);
switch (c_kind)
{
c_name = "reduction";
break;
case PRAGMA_OACC_CLAUSE_SELF:
- clauses = cp_parser_oacc_compute_clause_self (parser, clauses);
+ if ((mask & (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_HOST)) == 0)
+ /* OpenACC compute construct */
+ clauses = cp_parser_oacc_compute_clause_self (parser, clauses);
+ else
+ /* OpenACC 'update' directive */
+ clauses = cp_parser_oacc_data_clause (parser, c_kind, clauses);
c_name = "self";
break;
case PRAGMA_OACC_CLAUSE_SEQ:
}
}
- tree clauses = cp_parser_oacc_all_clauses (parser, mask, p_name, pragma_tok,
- true, true);
+ tree clauses = cp_parser_oacc_all_clauses (parser, mask, p_name, pragma_tok);
tree block = begin_omp_parallel ();
unsigned int save = cp_parser_begin_omp_structured_block (parser);
| (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 tree
OMP_CLAUSE_INDEPENDENT,
OMP_CLAUSE_USE_DEVICE,
OMP_CLAUSE_DEVICE_RESIDENT,
- OMP_CLAUSE_HOST_SELF,
+ OMP_CLAUSE_SELF,
+ OMP_CLAUSE_HOST,
OMP_CLAUSE_WAIT,
OMP_CLAUSE_DELETE,
OMP_CLAUSE_AUTO,
OMP_CLAUSE_DOACROSS, /* OpenMP 5.2 */
OMP_CLAUSE_ASSUMPTIONS, /* OpenMP 5.1. */
OMP_CLAUSE_USES_ALLOCATORS, /* OpenMP 5.0 */
- OMP_CLAUSE_SELF, /* OpenACC 2.7 */
/* This must come last. */
OMP_MASK2_LAST
};
that should work. */
bool allow_derived = (openacc
&& ((mask & OMP_CLAUSE_ATTACH)
- || (mask & OMP_CLAUSE_DETACH)
- || (mask & OMP_CLAUSE_HOST_SELF)));
+ || (mask & OMP_CLAUSE_DETACH)));
gcc_checking_assert (OMP_MASK1_LAST <= 64 && OMP_MASK2_LAST <= 64);
*cp = NULL;
&& gfc_match ("device ( ") == MATCH_YES
&& gfc_match_omp_map_clause (&c->lists[OMP_LIST_MAP],
OMP_MAP_FORCE_TO, true,
- allow_derived))
+ /* allow_derived = */ true))
continue;
if ((mask & OMP_CLAUSE_DEVICEPTR)
&& gfc_match ("deviceptr ( ") == MATCH_YES
c->assume->holds = el;
continue;
}
- if ((mask & OMP_CLAUSE_HOST_SELF)
+ if ((mask & OMP_CLAUSE_HOST)
&& gfc_match ("host ( ") == MATCH_YES
&& gfc_match_omp_map_clause (&c->lists[OMP_LIST_MAP],
OMP_MAP_FORCE_FROM, true,
- allow_derived))
+ /* allow_derived = */ true))
continue;
break;
case 'i':
gfc_current_locus = old_loc;
}
if ((mask & OMP_CLAUSE_SELF)
+ && !(mask & OMP_CLAUSE_HOST) /* OpenACC compute construct */
&& (m = gfc_match_dupl_check (!c->self_expr, "self"))
!= MATCH_NO)
{
- gcc_assert (!(mask & OMP_CLAUSE_HOST_SELF));
if (m == MATCH_ERROR)
goto error;
m = gfc_match (" ( %e )", &c->self_expr);
}
continue;
}
- if ((mask & OMP_CLAUSE_HOST_SELF)
+ if ((mask & OMP_CLAUSE_SELF)
+ && (mask & OMP_CLAUSE_HOST) /* OpenACC 'update' directive */
&& gfc_match ("self ( ") == MATCH_YES
&& gfc_match_omp_map_clause (&c->lists[OMP_LIST_MAP],
OMP_MAP_FORCE_FROM, true,
- allow_derived))
+ /* allow_derived = */ true))
continue;
if ((mask & OMP_CLAUSE_SEQ)
&& (m = gfc_match_dupl_check (!c->seq, "seq")) != MATCH_NO)
| OMP_CLAUSE_CREATE | OMP_CLAUSE_DEVICEPTR | OMP_CLAUSE_DEVICE_RESIDENT \
| OMP_CLAUSE_PRESENT \
| OMP_CLAUSE_LINK)
-#define OACC_UPDATE_CLAUSES \
- (omp_mask (OMP_CLAUSE_IF) | OMP_CLAUSE_ASYNC | OMP_CLAUSE_HOST_SELF \
- | OMP_CLAUSE_DEVICE | OMP_CLAUSE_WAIT | OMP_CLAUSE_IF_PRESENT)
+#define OACC_UPDATE_CLAUSES \
+ (omp_mask (OMP_CLAUSE_IF) | OMP_CLAUSE_ASYNC | OMP_CLAUSE_HOST \
+ | OMP_CLAUSE_DEVICE | OMP_CLAUSE_WAIT | OMP_CLAUSE_IF_PRESENT \
+ | OMP_CLAUSE_SELF)
#define OACC_ENTER_DATA_CLAUSES \
(omp_mask (OMP_CLAUSE_IF) | OMP_CLAUSE_ASYNC | OMP_CLAUSE_WAIT \
| OMP_CLAUSE_COPYIN | OMP_CLAUSE_CREATE | OMP_CLAUSE_ATTACH)