diff options
author | Julian Brown <julian@codesourcery.com> | 2019-12-20 01:20:38 +0000 |
---|---|---|
committer | Julian Brown <jules@gcc.gnu.org> | 2019-12-20 01:20:38 +0000 |
commit | 519d7496beac32c26448c1d0eea176c90f543702 (patch) | |
tree | 20537e9c463b72f2dca5a286adbe9d39ae91beea /gcc/c-family | |
parent | 4fd872bc0c6b4d48141f7d7e884c20b8e5e3979d (diff) | |
download | gcc-519d7496beac32c26448c1d0eea176c90f543702.zip gcc-519d7496beac32c26448c1d0eea176c90f543702.tar.gz gcc-519d7496beac32c26448c1d0eea176c90f543702.tar.bz2 |
OpenACC 2.6 deep copy: C and C++ front-end parts
gcc/c-family/
* c-common.h (c_omp_map_clause_name): Add prototype.
* c-omp.c (c_omp_map_clause_name): New function.
* c-pragma.h (pragma_omp_clause): Add PRAGMA_OACC_CLAUSE_ATTACH and
PRAGMA_OACC_CLAUSE_DETACH.
gcc/c/
* c-parser.c (c_parser_omp_clause_name): Add parsing of attach and
detach clauses.
(c_parser_omp_variable_list): Add ALLOW_DEREF optional parameter.
Allow deref (->) in variable lists if true.
(c_parser_omp_var_list_parens): Add ALLOW_DEREF optional parameter.
Pass to c_parser_omp_variable_list.
(c_parser_oacc_data_clause): Support attach and detach clauses. Update
call to c_parser_omp_variable_list.
(c_parser_oacc_all_clauses): Support attach and detach clauses.
(OACC_DATA_CLAUSE_MASK, OACC_ENTER_DATA_CLAUSE_MASK,
OACC_KERNELS_CLAUSE_MASK, OACC_PARALLEL_CLAUSE_MASK,
OACC_SERIAL_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_ATTACH.
(OACC_EXIT_DATA_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_DETACH.
* c-typeck.c (handle_omp_array_sections_1): Reject subarrays for attach
and detach. Support deref.
(handle_omp_array_sections): Use GOMP_MAP_ATTACH_DETACH instead of
GOMP_MAP_ALWAYS_POINTER for OpenACC.
(c_oacc_check_attachments): New function.
(c_finish_omp_clauses): Check attach/detach arguments for being
pointers using above. Support deref.
gcc/cp/
* parser.c (cp_parser_omp_clause_name): Support attach and detach
clauses.
(cp_parser_omp_var_list_no_open): Add ALLOW_DEREF optional parameter.
Parse deref if true.
(cp_parser_omp_var_list): Add ALLOW_DEREF optional parameter. Pass to
cp_parser_omp_var_list_no_open.
(cp_parser_oacc_data_clause): Support attach and detach clauses.
Update call to cp_parser_omp_var_list_no_open.
(cp_parser_oacc_all_clauses): Support attach and detach.
(OACC_DATA_CLAUSE_MASK, OACC_ENTER_DATA_CLAUSE_MASK,
OACC_KERNELS_CLAUSE_MASK, OACC_PARALLEL_CLAUSE_MASK,
OACC_SERIAL_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_ATTACH.
(OACC_EXIT_DATA_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_DETACH.
* semantics.c (handle_omp_array_sections_1): Reject subarrays for
attach and detach.
(handle_omp_array_sections): Use GOMP_MAP_ATTACH_DETACH instead of
GOMP_MAP_ALWAYS_POINTER for OpenACC.
(cp_oacc_check_attachments): New function.
(finish_omp_clauses): Use above function. Allow structure fields and
class members to appear in OpenACC data clauses. Support
GOMP_MAP_ATTACH_DETACH. Support deref.
gcc/testsuite/
* c-c++-common/goacc/deep-copy-arrayofstruct.c: New test.
* c-c++-common/goacc/mdc-1.c: New test.
* c-c++-common/goacc/mdc-2.c: New test.
* gcc.dg/goacc/mdc.C: New test.
Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com>
From-SVN: r279627
Diffstat (limited to 'gcc/c-family')
-rw-r--r-- | gcc/c-family/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 1 | ||||
-rw-r--r-- | gcc/c-family/c-omp.c | 33 | ||||
-rw-r--r-- | gcc/c-family/c-pragma.h | 2 |
4 files changed, 43 insertions, 0 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index 77d928a..30cbc13 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -1,4 +1,11 @@ 2019-12-19 Julian Brown <julian@codesourcery.com> + + * c-common.h (c_omp_map_clause_name): Add prototype. + * c-omp.c (c_omp_map_clause_name): New function. + * c-pragma.h (pragma_omp_clause): Add PRAGMA_OACC_CLAUSE_ATTACH and + PRAGMA_OACC_CLAUSE_DETACH. + +2019-12-19 Julian Brown <julian@codesourcery.com> Maciej W. Rozycki <macro@codesourcery.com> Tobias Burnus <tobias@codesourcery.com> Thomas Schwinge <thomas@codesourcery.com> diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 2bcb54f..2d89451 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -1205,6 +1205,7 @@ extern bool c_omp_predefined_variable (tree); extern enum omp_clause_default_kind c_omp_predetermined_sharing (tree); extern tree c_omp_check_context_selector (location_t, tree); extern void c_omp_mark_declare_variant (location_t, tree, tree); +extern const char *c_omp_map_clause_name (tree, bool); /* Return next tree in the chain for chain_next walking of tree nodes. */ static inline tree diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c index a4be2d6..04f2c0b 100644 --- a/gcc/c-family/c-omp.c +++ b/gcc/c-family/c-omp.c @@ -2259,3 +2259,36 @@ c_omp_mark_declare_variant (location_t loc, tree variant, tree construct) error_at (loc, "%qD used as a variant with incompatible %<construct%> " "selector sets", variant); } + +/* For OpenACC, the OMP_CLAUSE_MAP_KIND of an OMP_CLAUSE_MAP is used internally + to distinguish clauses as seen by the user. Return the "friendly" clause + name for error messages etc., where possible. See also + c/c-parser.c:c_parser_oacc_data_clause and + cp/parser.c:cp_parser_oacc_data_clause. */ + +const char * +c_omp_map_clause_name (tree clause, bool oacc) +{ + if (oacc && OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_MAP) + switch (OMP_CLAUSE_MAP_KIND (clause)) + { + case GOMP_MAP_FORCE_ALLOC: + case GOMP_MAP_ALLOC: return "create"; + case GOMP_MAP_FORCE_TO: + case GOMP_MAP_TO: return "copyin"; + case GOMP_MAP_FORCE_FROM: + case GOMP_MAP_FROM: return "copyout"; + case GOMP_MAP_FORCE_TOFROM: + case GOMP_MAP_TOFROM: return "copy"; + case GOMP_MAP_RELEASE: return "delete"; + case GOMP_MAP_FORCE_PRESENT: return "present"; + case GOMP_MAP_ATTACH: return "attach"; + case GOMP_MAP_FORCE_DETACH: + case GOMP_MAP_DETACH: return "detach"; + case GOMP_MAP_DEVICE_RESIDENT: return "device_resident"; + case GOMP_MAP_LINK: return "link"; + case GOMP_MAP_FORCE_DEVICEPTR: return "deviceptr"; + default: break; + } + return omp_clause_code_name[OMP_CLAUSE_CODE (clause)]; +} diff --git a/gcc/c-family/c-pragma.h b/gcc/c-family/c-pragma.h index 3754c5f..bf57d3d 100644 --- a/gcc/c-family/c-pragma.h +++ b/gcc/c-family/c-pragma.h @@ -143,11 +143,13 @@ enum pragma_omp_clause { /* Clauses for OpenACC. */ PRAGMA_OACC_CLAUSE_ASYNC, + PRAGMA_OACC_CLAUSE_ATTACH, PRAGMA_OACC_CLAUSE_AUTO, PRAGMA_OACC_CLAUSE_COPY, PRAGMA_OACC_CLAUSE_COPYOUT, PRAGMA_OACC_CLAUSE_CREATE, PRAGMA_OACC_CLAUSE_DELETE, + PRAGMA_OACC_CLAUSE_DETACH, PRAGMA_OACC_CLAUSE_DEVICEPTR, PRAGMA_OACC_CLAUSE_DEVICE_RESIDENT, PRAGMA_OACC_CLAUSE_FINALIZE, |