aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.cc
diff options
context:
space:
mode:
authorChung-Lin Tang <cltang@codesourcery.com>2023-06-06 03:46:29 -0700
committerThomas Schwinge <thomas@codesourcery.com>2023-08-15 16:31:56 +0200
commitbed993884b149851fe930b43cf11cbcdf05f1578 (patch)
tree79983da781a0031a6c0b7bc06256a9e8e485fa6d /gcc/gimplify.cc
parent0618adfa80fcd2fd7ae03b30553c60a6b1abf573 (diff)
downloadgcc-bed993884b149851fe930b43cf11cbcdf05f1578.zip
gcc-bed993884b149851fe930b43cf11cbcdf05f1578.tar.gz
gcc-bed993884b149851fe930b43cf11cbcdf05f1578.tar.bz2
OpenACC 2.7: default clause support for data constructs
This patch implements the OpenACC 2.7 addition of default(none|present) support for data constructs. Now, specifying "default(none|present)" on a data construct turns on same default clause behavior for all lexically enclosed compute constructs (which don't already themselves have a default clause). gcc/c/ChangeLog: * c-parser.cc (OACC_DATA_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_DEFAULT. gcc/cp/ChangeLog: * parser.cc (OACC_DATA_CLAUSE_MASK): Add PRAGMA_OACC_CLAUSE_DEFAULT. gcc/fortran/ChangeLog: * openmp.cc (OACC_DATA_CLAUSES): Add OMP_CLAUSE_DEFAULT. gcc/ChangeLog: * gimplify.cc (oacc_region_type_name): New function. (oacc_default_clause): If no 'default' clause appears on this compute construct, see if one appears on a lexically containing 'data' construct. (gimplify_scan_omp_clauses): Upon OMP_CLAUSE_DEFAULT case, set ctx->oacc_default_clause_ctx to current context. gcc/testsuite/ChangeLog: * c-c++-common/goacc/default-3.c: Adjust testcase. * c-c++-common/goacc/default-4.c: Adjust testcase. * c-c++-common/goacc/default-5.c: Adjust testcase. * gfortran.dg/goacc/default-3.f95: Adjust testcase. * gfortran.dg/goacc/default-4.f: Adjust testcase. * gfortran.dg/goacc/default-5.f: Adjust testcase. Co-authored-by: Thomas Schwinge <thomas@codesourcery.com>
Diffstat (limited to 'gcc/gimplify.cc')
-rw-r--r--gcc/gimplify.cc64
1 files changed, 51 insertions, 13 deletions
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 320920e..7549436 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -7699,6 +7699,25 @@ omp_default_clause (struct gimplify_omp_ctx *ctx, tree decl,
return flags;
}
+/* Return string name for types of OpenACC constructs from ORT_* values. */
+
+static const char *
+oacc_region_type_name (enum omp_region_type region_type)
+{
+ switch (region_type)
+ {
+ case ORT_ACC_DATA:
+ return "data";
+ case ORT_ACC_PARALLEL:
+ return "parallel";
+ case ORT_ACC_KERNELS:
+ return "kernels";
+ case ORT_ACC_SERIAL:
+ return "serial";
+ default:
+ gcc_unreachable ();
+ }
+}
/* Determine outer default flags for DECL mentioned in an OACC region
but not declared in an enclosing clause. */
@@ -7706,7 +7725,23 @@ omp_default_clause (struct gimplify_omp_ctx *ctx, tree decl,
static unsigned
oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
{
- const char *rkind;
+ struct gimplify_omp_ctx *ctx_default = ctx;
+ /* If no 'default' clause appears on this compute construct... */
+ if (ctx_default->default_kind == OMP_CLAUSE_DEFAULT_SHARED)
+ {
+ /* ..., see if one appears on a lexically containing 'data'
+ construct. */
+ while ((ctx_default = ctx_default->outer_context))
+ {
+ if (ctx_default->region_type == ORT_ACC_DATA
+ && ctx_default->default_kind != OMP_CLAUSE_DEFAULT_SHARED)
+ break;
+ }
+ /* If not, reset. */
+ if (!ctx_default)
+ ctx_default = ctx;
+ }
+
bool on_device = false;
bool is_private = false;
bool declared = is_oacc_declared (decl);
@@ -7738,14 +7773,12 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
switch (ctx->region_type)
{
case ORT_ACC_KERNELS:
- rkind = "kernels";
-
if (is_private)
flags |= GOVD_FIRSTPRIVATE;
else if (AGGREGATE_TYPE_P (type))
{
/* Aggregates default to 'present_or_copy', or 'present'. */
- if (ctx->default_kind != OMP_CLAUSE_DEFAULT_PRESENT)
+ if (ctx_default->default_kind != OMP_CLAUSE_DEFAULT_PRESENT)
flags |= GOVD_MAP;
else
flags |= GOVD_MAP | GOVD_MAP_FORCE_PRESENT;
@@ -7758,8 +7791,6 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
case ORT_ACC_PARALLEL:
case ORT_ACC_SERIAL:
- rkind = ctx->region_type == ORT_ACC_PARALLEL ? "parallel" : "serial";
-
if (is_private)
flags |= GOVD_FIRSTPRIVATE;
else if (on_device || declared)
@@ -7767,7 +7798,7 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
else if (AGGREGATE_TYPE_P (type))
{
/* Aggregates default to 'present_or_copy', or 'present'. */
- if (ctx->default_kind != OMP_CLAUSE_DEFAULT_PRESENT)
+ if (ctx_default->default_kind != OMP_CLAUSE_DEFAULT_PRESENT)
flags |= GOVD_MAP;
else
flags |= GOVD_MAP | GOVD_MAP_FORCE_PRESENT;
@@ -7785,16 +7816,23 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
if (DECL_ARTIFICIAL (decl))
; /* We can get compiler-generated decls, and should not complain
about them. */
- else if (ctx->default_kind == OMP_CLAUSE_DEFAULT_NONE)
+ else if (ctx_default->default_kind == OMP_CLAUSE_DEFAULT_NONE)
{
error ("%qE not specified in enclosing OpenACC %qs construct",
- DECL_NAME (lang_hooks.decls.omp_report_decl (decl)), rkind);
- inform (ctx->location, "enclosing OpenACC %qs construct", rkind);
- }
- else if (ctx->default_kind == OMP_CLAUSE_DEFAULT_PRESENT)
+ DECL_NAME (lang_hooks.decls.omp_report_decl (decl)),
+ oacc_region_type_name (ctx->region_type));
+ if (ctx_default != ctx)
+ inform (ctx->location, "enclosing OpenACC %qs construct and",
+ oacc_region_type_name (ctx->region_type));
+ inform (ctx_default->location,
+ "enclosing OpenACC %qs construct with %qs clause",
+ oacc_region_type_name (ctx_default->region_type),
+ "default(none)");
+ }
+ else if (ctx_default->default_kind == OMP_CLAUSE_DEFAULT_PRESENT)
; /* Handled above. */
else
- gcc_checking_assert (ctx->default_kind == OMP_CLAUSE_DEFAULT_SHARED);
+ gcc_checking_assert (ctx_default->default_kind == OMP_CLAUSE_DEFAULT_SHARED);
return flags;
}