aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-openmp.c
diff options
context:
space:
mode:
authorJulian Brown <julian@codesourcery.com>2020-06-09 15:53:39 -0700
committerJulian Brown <julian@codesourcery.com>2020-07-16 14:12:53 -0700
commit39dda0020801045d9a604575b2a2593c05310015 (patch)
tree32b809bf7d91a985754ef7bc0e33e8c92bff749c /gcc/fortran/trans-openmp.c
parent0f66b8486cea8668020e4bd48f261b760cb579be (diff)
downloadgcc-39dda0020801045d9a604575b2a2593c05310015.zip
gcc-39dda0020801045d9a604575b2a2593c05310015.tar.gz
gcc-39dda0020801045d9a604575b2a2593c05310015.tar.bz2
openacc: Fix standalone attach for Fortran assumed-shape array pointers
This patch makes it so that an "attach" operation for a Fortran pointer with an array descriptor copies that array descriptor to the target, and similarly that detach operations release the array descriptor. 2020-07-16 Julian Brown <julian@codesourcery.com> Thomas Schwinge <thomas@codesourcery.com> gcc/fortran/ * trans-openmp.c (gfc_trans_omp_clauses): Rework OpenACC attach/detach handling for arrays with descriptors. gcc/testsuite/ * gfortran.dg/goacc/attach-descriptor.f90: New test. libgomp/ * testsuite/libgomp.oacc-fortran/attach-descriptor-1.f90: New test. * testsuite/libgomp.oacc-fortran/attach-descriptor-2.f90: New test. Co-Authored-By: Thomas Schwinge <thomas@codesourcery.com>
Diffstat (limited to 'gcc/fortran/trans-openmp.c')
-rw-r--r--gcc/fortran/trans-openmp.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index f35ff41..80929c7 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -2685,9 +2685,7 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
decl = build_fold_indirect_ref (decl);
}
}
- if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (decl))
- && n->u.map_op != OMP_MAP_ATTACH
- && n->u.map_op != OMP_MAP_DETACH)
+ if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (decl)))
{
tree type = TREE_TYPE (decl);
tree ptr = gfc_conv_descriptor_data_get (decl);
@@ -2705,7 +2703,23 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
OMP_CLAUSE_SIZE (node2) = TYPE_SIZE_UNIT (type);
node3 = build_omp_clause (input_location,
OMP_CLAUSE_MAP);
- OMP_CLAUSE_SET_MAP_KIND (node3, GOMP_MAP_POINTER);
+ if (n->u.map_op == OMP_MAP_ATTACH)
+ {
+ /* Standalone attach clauses used with arrays with
+ descriptors must copy the descriptor to the target,
+ else they won't have anything to perform the
+ attachment onto (see OpenACC 2.6, "2.6.3. Data
+ Structures with Pointers"). */
+ OMP_CLAUSE_SET_MAP_KIND (node, GOMP_MAP_ALLOC);
+ OMP_CLAUSE_SET_MAP_KIND (node3, GOMP_MAP_ATTACH);
+ }
+ else if (n->u.map_op == OMP_MAP_DETACH)
+ {
+ OMP_CLAUSE_SET_MAP_KIND (node, GOMP_MAP_RELEASE);
+ OMP_CLAUSE_SET_MAP_KIND (node3, GOMP_MAP_DETACH);
+ }
+ else
+ OMP_CLAUSE_SET_MAP_KIND (node3, GOMP_MAP_POINTER);
if (present)
{
ptr = gfc_conv_descriptor_data_get (decl);