As mentioned here <https://gcc.gnu.org/ml/gcc-patches/2018-10/msg01641.html>, this patch series adds support for the new attach / detach clauses introduced in OpenACC 2.6 to the C and C++ front ends.
There is one notable difference between this patch and the one I posted for trunk. This patch tweaks GOMP_MAP_DEEP_COPY because OG8 has a lot of other map types for acc declare and dynamic arrays. I suspect that change would be required for trunk too, eventually. I've committed this patch to openacc-gcc-8-branch. Cesar
2018-10-30 Cesar Philippidis <ce...@codesourcery.com> gcc/ * gimplify.c (gimplify_adjust_omp_clauses): Filter out GOMP_MAP_STRUCT for acc exit data. (gimplify_omp_target_update): Promote GOMP_MAP_DETACH to GOMP_MAP_FORCE_DETACH when the finalize clause is present. * omp-low.c (lower_omp_target): Add support for GOMP_MAP_{ATTACH, DETACH, FORCE_DETACH}. * tree-pretty-print.c (dump_omp_clause): Likewise. gcc/c-family/ * c-pragma.h (enum pragma_omp_clause): Define PRAGMA_OACC_CLAUSE_{ATTACH,DETACH}. include/ * gomp-constants.h (GOMP_MAP_DEEP_COPY): Define. (enum gomp_map_kind): Add GOMP_MAP_{ATTACH, DETACH, FORCE_DETACH}. --- gcc/c-family/c-pragma.h | 2 ++ gcc/gimplify.c | 12 +++++++++--- gcc/omp-low.c | 3 +++ gcc/tree-pretty-print.c | 9 +++++++++ include/gomp-constants.h | 9 +++++++++ 5 files changed, 32 insertions(+), 3 deletions(-) diff --git a/gcc/c-family/c-pragma.h b/gcc/c-family/c-pragma.h index 8b392486615..bce915187c1 100644 --- a/gcc/c-family/c-pragma.h +++ b/gcc/c-family/c-pragma.h @@ -131,12 +131,14 @@ enum pragma_omp_clause { /* Clauses for OpenACC. */ PRAGMA_OACC_CLAUSE_ASYNC, + PRAGMA_OACC_CLAUSE_ATTACH, PRAGMA_OACC_CLAUSE_AUTO, PRAGMA_OACC_CLAUSE_BIND, 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_DEVICE_TYPE, diff --git a/gcc/gimplify.c b/gcc/gimplify.c index fda0d69caf7..9be0b70fc7f 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -9468,7 +9468,8 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, gimple_seq body, tree *list_p, } } else if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_STRUCT - && code == OMP_TARGET_EXIT_DATA) + && (code == OMP_TARGET_EXIT_DATA + || code == OACC_EXIT_DATA)) remove = true; else if (DECL_SIZE (decl) && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST @@ -11156,8 +11157,9 @@ gimplify_omp_target_update (tree *expr_p, gimple_seq *pre_p) && omp_find_clause (OMP_STANDALONE_CLAUSES (expr), OMP_CLAUSE_FINALIZE)) { - /* Use GOMP_MAP_DELETE/GOMP_MAP_FORCE_FROM to denote that "finalize" - semantics apply to all mappings of this OpenACC directive. */ + /* Use GOMP_MAP_DELETE, GOMP_MAP_FORCE_DETACH, and + GOMP_MAP_FORCE_FROM to denote that "finalize" semantics apply + to all mappings of this OpenACC directive. */ bool finalize_marked = false; for (tree c = OMP_STANDALONE_CLAUSES (expr); c; c = OMP_CLAUSE_CHAIN (c)) if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP) @@ -11171,6 +11173,10 @@ gimplify_omp_target_update (tree *expr_p, gimple_seq *pre_p) OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_DELETE); finalize_marked = true; break; + case GOMP_MAP_DETACH: + OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_FORCE_DETACH); + finalize_marked = true; + break; default: /* Check consistency: libgomp relies on the very first data mapping clause being marked, so make sure we did that before diff --git a/gcc/omp-low.c b/gcc/omp-low.c index a219b825488..e559211f413 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -8185,6 +8185,9 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx) case GOMP_MAP_DYNAMIC_ARRAY_FORCE_ALLOC: case GOMP_MAP_DYNAMIC_ARRAY_FORCE_PRESENT: case GOMP_MAP_LINK: + case GOMP_MAP_ATTACH: + case GOMP_MAP_DETACH: + case GOMP_MAP_FORCE_DETACH: gcc_assert (is_gimple_omp_oacc (stmt)); break; default: diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index 05a163d8956..ecbb51646b0 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -778,6 +778,15 @@ dump_omp_clause (pretty_printer *pp, tree clause, int spc, dump_flags_t flags) case GOMP_MAP_DECLARE_DEALLOCATE: pp_string (pp, "declare_deallocate"); break; + case GOMP_MAP_ATTACH: + pp_string (pp, "attach"); + break; + case GOMP_MAP_DETACH: + pp_string (pp, "detach"); + break; + case GOMP_MAP_FORCE_DETACH: + pp_string (pp, "force_detach"); + break; default: gcc_unreachable (); } diff --git a/include/gomp-constants.h b/include/gomp-constants.h index 9ef51c04994..c6cd48805e0 100644 --- a/include/gomp-constants.h +++ b/include/gomp-constants.h @@ -44,6 +44,8 @@ #define GOMP_MAP_FLAG_SPECIAL_4 (1 << 6) #define GOMP_MAP_FLAG_SPECIAL (GOMP_MAP_FLAG_SPECIAL_1 \ | GOMP_MAP_FLAG_SPECIAL_0) +#define GOMP_MAP_DEEP_COPY (GOMP_MAP_FLAG_SPECIAL_4 \ + | GOMP_MAP_FLAG_SPECIAL_2) /* Flag to force a specific behavior (or else, trigger a run-time error). */ #define GOMP_MAP_FLAG_FORCE (1 << 7) @@ -156,6 +158,13 @@ enum gomp_map_kind | GOMP_MAP_FORCE_TO), GOMP_MAP_DECLARE_DEALLOCATE = (GOMP_MAP_DECLARE | GOMP_MAP_FORCE_FROM), + /* In OpenACC, attach a pointer to a mapped struct field. */ + GOMP_MAP_ATTACH = (GOMP_MAP_DEEP_COPY | 0), + /* In OpenACC, detach a pointer to a mapped struct field. */ + GOMP_MAP_DETACH = (GOMP_MAP_DEEP_COPY | 1), + /* In OpenACC, detach a pointer to a mapped struct field. */ + GOMP_MAP_FORCE_DETACH = (GOMP_MAP_DEEP_COPY + | GOMP_MAP_FLAG_FORCE | 1), /* Internal to GCC, not used in libgomp. */ /* Do not map, but pointer assign a pointer instead. */ -- 2.17.2