This is a summary of discussions relative to the merge request created by
Sebastian Galindo (galindos) <[email protected]> titled
C/C++ support for OpenACC init,set,shutdown directives.
since its creation.
Description: This patch add OpenACC init,set,shutdown directives support for
the C
and C++ front-ends.
An unexpected runtime error was fixed: When the device_type clause had
the argument as *, the set directive was passing an invalid argument to
the runtime library.
The bug 126507 was resolved (dtype alias for device_type).
gcc/c-family/ChangeLog:
* c-common.h (c_finish_oacc_executable_directive): Declare.
* c-omp.cc (oacc_eval_device_type): New.
(c_finish_oacc_executable_directive): New. Lower init, set and
shutdown to GOACC builtins; map set's device_type(*) to
GOMP_DEVICE_DEFAULT.
* c-pragma.cc (oacc_pragmas): Register init, set and shutdown.
* c-pragma.h (enum pragma_kind): Add PRAGMA_OACC_INIT,
PRAGMA_OACC_SET and PRAGMA_OACC_SHUTDOWN.
(enum pragma_omp_clause): Add PRAGMA_OACC_CLAUSE_DEVICE_NUM and
PRAGMA_OACC_CLAUSE_DEVICE_TYPE alias.
gcc/c/ChangeLog:
* c-parser.cc (c_parser_omp_clause_name): Recognize device_num and
dtype as an alias of device_type.
(c_parser_oacc_single_int_clause): Allow device_num 0; clamp
non-positive device_num to 0.
(c_parser_oacc_clause_device_type): New. Parse OpenACC
device_type/dtype arguments.
(c_parser_oacc_all_clauses): Handle DEVICE_NUM and OpenACC
DEVICE_TYPE.
(OACC_INIT_CLAUSE_MASK, OACC_SHUTDOWN_CLAUSE_MASK,
OACC_SET_CLAUSE_MASK): New.
(c_parser_oacc_executable_directive): New.
(c_parser_omp_construct): Handle init, set and shutdown.
* c-typeck.cc (c_finish_omp_clauses): Accept OMP_CLAUSE_DEVICE_NUM.
gcc/cp/ChangeLog:
* parser.cc (cp_parser_omp_clause_name): Recognize device_num and
dtype as an alias of device_type.
(cp_parser_oacc_single_int_clause): Allow device_num 0; clamp
non-positive device_num to 0.
(cp_parser_oacc_clause_device_type): New. Parse OpenACC
device_type/dtype arguments.
(cp_parser_oacc_all_clauses): Handle DEVICE_NUM and OpenACC
DEVICE_TYPE.
(OACC_INIT_CLAUSE_MASK, OACC_SHUTDOWN_CLAUSE_MASK,
OACC_SET_CLAUSE_MASK): New.
(cp_parser_oacc_executable_directive): New.
(cp_parser_omp_construct): Handle init, set and shutdown.
(cp_parser_pragma): Allow init, set and shutdown in statement
context.
* semantics.cc (finish_omp_clauses): Handle OMP_CLAUSE_DEVICE_NUM
like other integral OpenACC clauses, including template
instantiation; require a non-negative value.
gcc/fortran/ChangeLog:
* openmp.cc (gfc_match_omp_clauses): Accept dtype as an alias of
OpenACC device_type.
* trans-openmp.cc (gfc_trans_oacc_executable_directive): For set,
map device_type(*) to GOMP_DEVICE_DEFAULT.
gcc/ChangeLog:
* tree-core.h (enum omp_clause_code): Add OMP_CLAUSE_DEVICE_NUM.
(enum oacc_clause_device_type_kind): New.
(struct tree_omp_clause): Add oacc_device_type_kind.
* tree-pretty-print.cc (dump_omp_clause): Dump DEVICE_NUM and
OpenACC DEVICE_TYPE kinds.
* tree.cc (omp_clause_num_ops, omp_clause_code_name): Handle
DEVICE_NUM.
* tree.h (OMP_CLAUSE_OACC_DEVICE_TYPE_KIND): Define.
gcc/testsuite/ChangeLog:
* c-c++-common/goacc/uninit-if-clause.c: Test uninitialized if on
init.
* c-c++-common/goacc/update-if_present-2.c: Expect errors for
if_present on init and shutdown.
* gfortran.dg/goacc/acc-set-1.f90: Test set with device_type(*).
* c-c++-common/goacc/acc-dtype-1.c: New test.
* c-c++-common/goacc/acc-init-1.c: New test.
* c-c++-common/goacc/acc-init-clauses-1.c: New test.
* c-c++-common/goacc/acc-set-1.c: New test.
* c-c++-common/goacc/acc-set-clauses-1.c: New test.
* c-c++-common/goacc/acc-shutdown-1.c: New test.
* c-c++-common/goacc/acc-shutdown-clauses-1.c: New test.
* gfortran.dg/goacc/acc-dtype-1.f90: New test.
Signed-off-by: Sebastian Galindo <[email protected]>
CC: [email protected], [email protected]
The full and up to date discussion can be found at
https://forge.sourceware.org/gcc/gcc/pulls/225
The merge request has been closed without being merged directly on the forge
repository.
On 2026-09-20 13:50:45+00:00, Thomas Schwinge (tschwinge) wrote:
> An unexpected runtime error was fixed: When the device_type clause had the
> argument as *, the set directive was passing an invalid argument to the
> runtime library.
Please make that a separate patch submission (including the corresponding test
case updates).
> The bug 126507 was resolved (dtype alias for device_type).
..., and that one as well, separately. Put `[PR126507]` at the end of the Git
commit summary line, and `PR fortran/126507` in the ChangeLog updates as part
of the Git commit log.
(I'm now reviewing the C, C++ changes here.)