aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJulian Brown <julian@codesourcery.com>2023-06-15 19:12:57 +0000
committerJulian Brown <julian@codesourcery.com>2023-06-19 22:15:31 +0000
commita138b0e1e32ca425ea8ab3b5abb68f91a00eb14d (patch)
tree93f4fa3bc5d082ee94bf108bfe8dd6a4bd88c6a5 /gcc
parent1394fbcfe614958a969fcc6cdc6f3b53c5bcb6da (diff)
downloadgcc-a138b0e1e32ca425ea8ab3b5abb68f91a00eb14d.zip
gcc-a138b0e1e32ca425ea8ab3b5abb68f91a00eb14d.tar.gz
gcc-a138b0e1e32ca425ea8ab3b5abb68f91a00eb14d.tar.bz2
Revert "Fix implicit mapping for array slices on lexically-enclosing data constructs (PR70828)"
This reverts commit a84b89b8f070f1efe86ea347e98d57e6bc32ae2d. Relevant tests are temporarily disabled or XFAILed. 2023-06-16 Julian Brown <julian@codesourcery.com> gcc/ Revert: * gimplify.cc (oacc_array_mapping_info): New struct. (gimplify_omp_ctx): Add decl_data_clause hash map. (new_omp_context): Zero-initialise above. (delete_omp_context): Delete above if allocated. (gimplify_scan_omp_clauses): Scan for array mappings on data constructs, and record in above map. (gomp_oacc_needs_data_present): New function. (gimplify_adjust_omp_clauses_1): Handle data mappings (e.g. array slices) declared in lexically-enclosing data constructs. * omp-low.cc (lower_omp_target): Allow decl for bias not to be present in OpenACC context. gcc/fortran/ Revert: * trans-openmp.cc: Handle implicit "present". gcc/testsuite/ * c-c++-common/goacc/acc-data-chain.c: Partly disable test. * gfortran.dg/goacc/pr70828.f90: Likewise. libgomp/ * testsuite/libgomp.oacc-c-c++-common/pr70828.c: XFAIL test. * testsuite/libgomp.oacc-c-c++-common/pr70828-2.c: XFAIL test. * testsuite/libgomp.oacc-fortran/pr70828.f90: XFAIL test. * testsuite/libgomp.oacc-fortran/pr70828-2.f90: XFAIL test. * testsuite/libgomp.oacc-fortran/pr70828-3.f90: XFAIL test. * testsuite/libgomp.oacc-fortran/pr70828-4.f90: XFAIL test. * testsuite/libgomp.oacc-fortran/pr70828-5.f90: XFAIL test. * testsuite/libgomp.oacc-fortran/pr70828-6.f90: XFAIL test.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog.omp18
-rw-r--r--gcc/fortran/ChangeLog.omp5
-rw-r--r--gcc/fortran/trans-openmp.cc10
-rw-r--r--gcc/gimplify.cc143
-rw-r--r--gcc/omp-low.cc10
-rw-r--r--gcc/testsuite/ChangeLog.omp5
-rw-r--r--gcc/testsuite/c-c++-common/goacc/acc-data-chain.c4
-rw-r--r--gcc/testsuite/gfortran.dg/goacc/pr70828.f903
8 files changed, 40 insertions, 158 deletions
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 36bb919..fade77e 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,6 +1,24 @@
2023-06-19 Julian Brown <julian@codesourcery.com>
Revert:
+ 2018-08-28 Julian Brown <julian@codesourcery.com>
+ Cesar Philippidis <cesar@codesourcery.com>
+
+ * gimplify.cc (oacc_array_mapping_info): New struct.
+ (gimplify_omp_ctx): Add decl_data_clause hash map.
+ (new_omp_context): Zero-initialise above.
+ (delete_omp_context): Delete above if allocated.
+ (gimplify_scan_omp_clauses): Scan for array mappings on data constructs,
+ and record in above map.
+ (gomp_oacc_needs_data_present): New function.
+ (gimplify_adjust_omp_clauses_1): Handle data mappings (e.g. array
+ slices) declared in lexically-enclosing data constructs.
+ * omp-low.cc (lower_omp_target): Allow decl for bias not to be present
+ in OpenACC context.
+
+2023-06-19 Julian Brown <julian@codesourcery.com>
+
+ Revert:
2019-05-19 Julian Brown <julian@codesourcery.com>
* gimplify.cc (oacc_array_mapping_info): Add REF field.
diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 0f430b1..16982e3 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,6 +1,11 @@
2023-06-19 Julian Brown <julian@codesourcery.com>
Revert:
+ * trans-openmp.cc: Handle implicit "present".
+
+2023-06-19 Julian Brown <julian@codesourcery.com>
+
+ Revert:
2019-05-19 Julian Brown <julian@codesourcery.com>
* trans-openmp.cc (gfc_omp_finish_clause): Guard addition of clauses for
diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc
index 96e91a3..809b96b 100644
--- a/gcc/fortran/trans-openmp.cc
+++ b/gcc/fortran/trans-openmp.cc
@@ -1587,13 +1587,9 @@ gfc_omp_finish_clause (tree c, gimple_seq *pre_p, bool openacc)
tree decl = OMP_CLAUSE_DECL (c);
- /* Assumed-size arrays can't be mapped implicitly, they have to be mapped
- explicitly using array sections. An exception is if the array is
- mapped explicitly in an enclosing data construct for OpenACC, in which
- case we see GOMP_MAP_FORCE_PRESENT here and do not need to raise an
- error. */
- if (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FORCE_PRESENT
- && TREE_CODE (decl) == PARM_DECL
+ /* Assumed-size arrays can't be mapped implicitly, they have to be
+ mapped explicitly using array sections. */
+ if (TREE_CODE (decl) == PARM_DECL
&& GFC_ARRAY_TYPE_P (TREE_TYPE (decl))
&& GFC_TYPE_ARRAY_AKIND (TREE_TYPE (decl)) == GFC_ARRAY_UNKNOWN
&& GFC_TYPE_ARRAY_UBOUND (TREE_TYPE (decl),
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 80f1f3a..e3384c7 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -218,17 +218,6 @@ enum gimplify_defaultmap_kind
GDMK_POINTER
};
-/* Used to record clauses representing array slices on data directives that
- may affect implicit mapping semantics on enclosed OpenACC parallel/kernels
- regions. PSET is used for Fortran array slices with array descriptors,
- or NULL otherwise. */
-struct oacc_array_mapping_info
-{
- tree mapping;
- tree pset;
- tree pointer;
-};
-
struct gimplify_omp_ctx
{
struct gimplify_omp_ctx *outer_context;
@@ -250,7 +239,6 @@ struct gimplify_omp_ctx
bool in_for_exprs;
bool ompacc;
int defaultmap[5];
- hash_map<tree, oacc_array_mapping_info> *decl_data_clause;
};
struct privatize_reduction
@@ -485,7 +473,6 @@ new_omp_context (enum omp_region_type region_type)
c->defaultmap[GDMK_AGGREGATE] = GOVD_MAP;
c->defaultmap[GDMK_ALLOCATABLE] = GOVD_MAP;
c->defaultmap[GDMK_POINTER] = GOVD_MAP;
- c->decl_data_clause = NULL;
return c;
}
@@ -498,8 +485,6 @@ delete_omp_context (struct gimplify_omp_ctx *c)
splay_tree_delete (c->variables);
delete c->privatized_types;
c->loop_iter_var.release ();
- if (c->decl_data_clause)
- delete c->decl_data_clause;
XDELETE (c);
}
@@ -11235,41 +11220,8 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p,
case OMP_TARGET:
break;
case OACC_DATA:
- {
- tree base_ptr = OMP_CLAUSE_CHAIN (c);
- tree pset = NULL;
- if (base_ptr
- && OMP_CLAUSE_CODE (base_ptr) == OMP_CLAUSE_MAP
- && OMP_CLAUSE_MAP_KIND (base_ptr) == GOMP_MAP_TO_PSET)
- {
- pset = base_ptr;
- base_ptr = OMP_CLAUSE_CHAIN (base_ptr);
- }
- if (base_ptr
- && OMP_CLAUSE_CODE (base_ptr) == OMP_CLAUSE_MAP
- && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_TO_PSET
- && ((OMP_CLAUSE_MAP_KIND (base_ptr)
- == GOMP_MAP_FIRSTPRIVATE_POINTER)
- || OMP_CLAUSE_MAP_KIND (base_ptr) == GOMP_MAP_POINTER))
- {
- /* If we have an array descriptor, fish the right base
- address variable to use out of that (otherwise we'd have
- to deconstruct "arr.data" in the subsequent pointer
- mapping). */
- tree base_addr = pset ? OMP_CLAUSE_DECL (pset)
- : OMP_CLAUSE_DECL (base_ptr);
- if (!ctx->decl_data_clause)
- ctx->decl_data_clause
- = new hash_map<tree, oacc_array_mapping_info>;
- oacc_array_mapping_info ai;
- ai.mapping = unshare_expr (c);
- ai.pset = pset ? unshare_expr (pset) : NULL;
- ai.pointer = unshare_expr (base_ptr);
- ctx->decl_data_clause->put (base_addr, ai);
- }
- if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE)
- break;
- }
+ if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE)
+ break;
/* FALLTHRU */
case OMP_TARGET_DATA:
case OMP_TARGET_ENTER_DATA:
@@ -12430,46 +12382,6 @@ struct gimplify_adjust_omp_clauses_data
gimple_seq *pre_p;
};
-/* For OpenACC parallel and kernels regions, the implicit data mappings for
- arrays must respect explicit data clauses set by a containing acc data
- region. Specifically, an array section on the data clause must be
- transformed into an equivalent PRESENT mapping on the inner parallel or
- kernels region. This function returns a pointer to an
- oacc_array_mapping_info if an array slice of DECL is specified in a
- lexically-enclosing data construct, or returns NULL otherwise. */
-
-static oacc_array_mapping_info *
-gomp_oacc_needs_data_present (tree decl)
-{
- gimplify_omp_ctx *ctx = NULL;
-
- if (gimplify_omp_ctxp->region_type != ORT_ACC_PARALLEL
- && gimplify_omp_ctxp->region_type != ORT_ACC_KERNELS)
- return NULL;
-
- if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE
- && TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE
- && TREE_CODE (TREE_TYPE (decl)) != RECORD_TYPE
- && (TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE
- || TREE_CODE (TREE_TYPE (TREE_TYPE (decl))) != ARRAY_TYPE))
- return NULL;
-
- decl = get_base_address (decl);
-
- for (ctx = gimplify_omp_ctxp->outer_context; ctx; ctx = ctx->outer_context)
- {
- oacc_array_mapping_info *ret;
-
- if (ctx->region_type != ORT_ACC_DATA)
- break;
-
- if (ctx->decl_data_clause && (ret = ctx->decl_data_clause->get (decl)))
- return ret;
- }
-
- return NULL;
-}
-
/* For all variables that were not actually used within the context,
remove PRIVATE, SHARED, and FIRSTPRIVATE clauses. */
@@ -12591,7 +12503,6 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
clause = build_omp_clause (input_location, code);
OMP_CLAUSE_DECL (clause) = decl;
OMP_CLAUSE_CHAIN (clause) = chain;
- oacc_array_mapping_info *array_info;
if (private_debug)
OMP_CLAUSE_PRIVATE_DEBUG (clause) = 1;
else if (code == OMP_CLAUSE_PRIVATE && (flags & GOVD_PRIVATE_OUTER_REF))
@@ -12600,56 +12511,6 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
&& (flags & GOVD_WRITTEN) == 0
&& omp_shared_to_firstprivate_optimizable_decl_p (decl))
OMP_CLAUSE_SHARED_READONLY (clause) = 1;
- else if ((code == OMP_CLAUSE_MAP || code == OMP_CLAUSE_FIRSTPRIVATE)
- && (array_info = gomp_oacc_needs_data_present (decl)))
- {
- tree mapping = array_info->mapping;
- tree pointer = array_info->pointer;
-
- if (code == OMP_CLAUSE_FIRSTPRIVATE)
- /* Oops, we have the wrong type of clause. Rebuild it. */
- clause = build_omp_clause (OMP_CLAUSE_LOCATION (clause),
- OMP_CLAUSE_MAP);
-
- OMP_CLAUSE_DECL (clause) = unshare_expr (OMP_CLAUSE_DECL (mapping));
- OMP_CLAUSE_SET_MAP_KIND (clause, GOMP_MAP_FORCE_PRESENT);
- OMP_CLAUSE_SIZE (clause) = unshare_expr (OMP_CLAUSE_SIZE (mapping));
-
- /* Create a new data clause for the firstprivate pointer. */
- tree nc = build_omp_clause (OMP_CLAUSE_LOCATION (clause),
- OMP_CLAUSE_MAP);
- OMP_CLAUSE_DECL (nc) = unshare_expr (OMP_CLAUSE_DECL (pointer));
- OMP_CLAUSE_SET_MAP_KIND (nc, GOMP_MAP_POINTER);
-
- /* For GOMP_MAP_FIRSTPRIVATE_POINTER, this is a bias, not a size. */
- OMP_CLAUSE_SIZE (nc) = unshare_expr (OMP_CLAUSE_SIZE (pointer));
-
- /* Create a new data clause for the PSET, if present. */
- tree psetc = NULL;
- if (array_info->pset)
- {
- tree pset = array_info->pset;
- psetc = build_omp_clause (OMP_CLAUSE_LOCATION (clause),
- OMP_CLAUSE_MAP);
- OMP_CLAUSE_DECL (psetc) = unshare_expr (OMP_CLAUSE_DECL (pset));
- OMP_CLAUSE_SIZE (psetc) = unshare_expr (OMP_CLAUSE_SIZE (pset));
- OMP_CLAUSE_SET_MAP_KIND (psetc, GOMP_MAP_TO_PSET);
- OMP_CLAUSE_CHAIN (psetc) = nc;
- }
-
- gimplify_omp_ctx *ctx = gimplify_omp_ctxp;
- gimplify_omp_ctxp = ctx->outer_context;
- gimplify_expr (&OMP_CLAUSE_DECL (clause), pre_p, NULL,
- is_gimple_lvalue, fb_lvalue);
- gimplify_expr (&OMP_CLAUSE_SIZE (clause), pre_p, NULL,
- is_gimple_val, fb_rvalue);
- gimplify_expr (&OMP_CLAUSE_SIZE (nc), pre_p, NULL, is_gimple_val,
- fb_rvalue);
- gimplify_omp_ctxp = ctx;
-
- OMP_CLAUSE_CHAIN (nc) = OMP_CLAUSE_CHAIN (clause);
- OMP_CLAUSE_CHAIN (clause) = psetc ? psetc : nc;
- }
else if (code == OMP_CLAUSE_FIRSTPRIVATE && (flags & GOVD_EXPLICIT) == 0)
OMP_CLAUSE_FIRSTPRIVATE_IMPLICIT (clause) = 1;
else if (code == OMP_CLAUSE_MAP && (flags & GOVD_MAP_0LEN_ARRAY) != 0)
diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
index 59143d8..14ec3b8 100644
--- a/gcc/omp-low.cc
+++ b/gcc/omp-low.cc
@@ -15191,14 +15191,8 @@ lower_omp_target (gimple_stmt_iterator *gsi_p, omp_context *ctx)
x = fold_convert_loc (clause_loc, type, x);
if (!integer_zerop (OMP_CLAUSE_SIZE (c)))
{
- tree bias = OMP_CLAUSE_SIZE (c), remapped_bias;
- if (is_gimple_omp_oacc (ctx->stmt))
- {
- if (DECL_P (bias)
- && (remapped_bias = maybe_lookup_decl (bias, ctx)))
- bias = remapped_bias;
- }
- else if (DECL_P (bias))
+ tree bias = OMP_CLAUSE_SIZE (c);
+ if (DECL_P (bias))
bias = lookup_decl (bias, ctx);
bias = fold_convert_loc (clause_loc, sizetype, bias);
bias = fold_build1_loc (clause_loc, NEGATE_EXPR, sizetype,
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 810f1e6..8879959 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,8 @@
+2023-06-19 Julian Brown <julian@codesourcery.com>
+
+ * c-c++-common/goacc/acc-data-chain.c: Partly disable test.
+ * gfortran.dg/goacc/pr70828.f90: Likewise.
+
2023-06-13 Sandra Loosemore <sandra@codesourcery.com>
* gfortran.dg/gomp/collapse1.f90: Adjust expected errors.
diff --git a/gcc/testsuite/c-c++-common/goacc/acc-data-chain.c b/gcc/testsuite/c-c++-common/goacc/acc-data-chain.c
index 8a039be..932786c 100644
--- a/gcc/testsuite/c-c++-common/goacc/acc-data-chain.c
+++ b/gcc/testsuite/c-c++-common/goacc/acc-data-chain.c
@@ -21,4 +21,6 @@ int main(int argc, char *argv[])
}
// { dg-final { scan-tree-dump-times "omp target oacc_data map\\(from:b\\\[0\\\] \\\[len: 400\\\]\\) map\\(to:a\\\[0\\\] \\\[len: 400\\\]\\)" 1 "gimple" } }
-// { dg-final { scan-tree-dump-times "omp target oacc_parallel map\\(force_present:b\\\[0\\\] \\\[len: 400\\\]\\) map.alloc:b \\\[pointer assign, bias: 0\\\]\\) map\\(force_present:a\\\[0\\\] \\\[len: 400\\\]\\) map\\(alloc:a \\\[pointer assign, bias: 0\\\]\\)" 1 "gimple" } }
+/* This isn't expected to work while the "lexical inheritance" support is
+ reverted. */
+// { dg-final { scan-tree-dump-times "omp target oacc_parallel map\\(force_present:b\\\[0\\\] \\\[len: 400\\\]\\) map.alloc:b \\\[pointer assign, bias: 0\\\]\\) map\\(force_present:a\\\[0\\\] \\\[len: 400\\\]\\) map\\(alloc:a \\\[pointer assign, bias: 0\\\]\\)" 0 "gimple" } }
diff --git a/gcc/testsuite/gfortran.dg/goacc/pr70828.f90 b/gcc/testsuite/gfortran.dg/goacc/pr70828.f90
index fcfe086..72b0d9a 100644
--- a/gcc/testsuite/gfortran.dg/goacc/pr70828.f90
+++ b/gcc/testsuite/gfortran.dg/goacc/pr70828.f90
@@ -19,4 +19,5 @@ program test
end program test
! { dg-final { scan-tree-dump-times "omp target oacc_data map\\(tofrom:data\\\[\_\[0-9\]+\\\] \\\[len: _\[0-9\]+\\\]\\) map\\(alloc:data \\\[pointer assign, bias: _\[0-9\]+\\\]\\)" 1 "gimple" } }
-! { dg-final { scan-tree-dump-times "omp target oacc_parallel map\\(force_present:data\\\[D\\.\[0-9\]+\\\] \\\[len: D\\.\[0-9\]+\\\]\\) map\\(alloc:data \\\[pointer assign, bias: D\\.\[0-9\]+\\\]\\)" 1 "gimple" } }
+! Disable for now
+! { dg-final { scan-tree-dump-times "omp target oacc_parallel map\\(force_present:data\\\[D\\.\[0-9\]+\\\] \\\[len: D\\.\[0-9\]+\\\]\\) map\\(alloc:data \\\[pointer assign, bias: D\\.\[0-9\]+\\\]\\)" 0 "gimple" } }