Hi!
On 2023-08-01T23:35:16+0800, Chung-Lin Tang wrote:
> this is v2 of the patch for implementing the OpenACC 2.7 addition of
> default(none|present) support for data constructs.
Thanks!
> Instead of propagating an additional 'oacc_default_kind' for OpenACC,
> this patch does it in a more complete way: it directly propagates the
> gimplify_omp_ctx* pointer of the inner most context where we found
> a default-clause.
Right -- but reviewing this, it came upon me that we don't need any such
new code at all, and instead may in 'gcc/gimplify.cc:oacc_default_clause'
simply look through the 'ctx's to find the 'default' clause information.
This centralizes the logic in the one place where it's relevant.
> This supports displaying the location/type of OpenACC
> construct where the default-clause is in the error messages.
This is preserved...
> The testcases also have the multiple nested data construct testing added,
> where we can now have messages referring precisely to the exact innermost
> default clause that was active at that program point.
..., but we should also still 'inform' about the compute construct, where
the user is expected to add explicit data clauses (if not adding to the
'data' construct where the 'default(none)' clause appears):
> --- a/gcc/gimplify.cc
> +++ b/gcc/gimplify.cc
> @@ -7785,16 +7809,20 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx,
> tree decl, unsigned flags)
> - else if (ctx->default_kind == OMP_CLAUSE_DEFAULT_NONE)
> + else if (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));
> + inform (ctx->oacc_default_clause_ctx->location,
> + "enclosing OpenACC %qs construct",
> + oacc_region_type_name
> + (ctx->oacc_default_clause_ctx->region_type));
> +}
That is, we should keep here the original 'inform' for 'ctx->location',
and *add another* 'inform' for 'ctx->oacc_default_clause_ctx->location'.
Otherwise that's confusing to users.
Instead of requiring another iteration through you, I've now implemented
that, and with test cases enhanced some more, pushed to master branch
commit bed993884b149851fe930b43cf11cbcdf05f1578
"OpenACC 2.7: default clause support for data constructs", see attached.
Grüße
Thomas
-
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht
München, HRB 106955
>From bed993884b149851fe930b43cf11cbcdf05f1578 Mon Sep 17 00:00:00 2001
From: Chung-Lin Tang
Date: Tue, 6 Jun 2023 03:46:29 -0700
Subject: [PATCH] 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
---
gcc/c/c-parser.cc | 1 +
gcc/cp/parser.cc | 1 +
gcc/fortran/openmp.cc | 3 +-
gcc/gimplify.cc | 64 +++
gcc/testsuite/c-c++-common/goacc/default-3.c | 59 +-
gcc/testsuite/c-c++-common/goacc/default-4.c | 42 ++
gcc/testsuite/c-c++-common/goacc/default-5.c | 19 -
gcc/testsuite/gfortran.dg/goacc/default-3.f95 | 77 ++-
gcc/testsuite/gfortran.dg/goacc/default-4.f | 36 +
gcc/testsuite/gfortran.dg/goacc/default-5.f | 19 -
10