Hi Sebastian!

On 2026-05-29T02:51:11-0400, "Sebastian Galindo" 
<[email protected]> wrote:
> I'm implementing the parsing for the acc init directive clauses, one of
> them is device_type

By the way, I should mention that we've recently corrected the OpenACC
specification text:

| Clarified that the 'device_type' clause on the 'init', 'shutdown', and 'set' 
directives accepts a single 'device-type' argument.

... instead of a 'device-type-list', as specified through OpenACC 3.4.
(Not visible to publicly, but still cross-referencing:
<https://github.com/OpenACC/openacc-spec/issues/537>
"Set directive should not take a device-type-list.",
<https://github.com/OpenACC/openacc-spec/pull/550>
"Changes init, shutdown, and set directives to accept just a single device_type 
argument rather than a list".)
So, no need for you to invent a libgomp function that is accepting a list
of device types.


> but this name ['device_type'] conflicts with OMP_CLAUSE_DEVICE_TYPE
> that comes from OpenMP 5.0 and it does have different possible values.
>
> - How should I name the new clause "device_type" from OpenACC? Maybe
>   OACC_CLAUSE_DEVICE_TYPE and include it in the omp_mask?

In the C/C++ clause parsing, you'd add to 'enum pragma_omp_clause':

  PRAGMA_OACC_CLAUSE_DEVICE_TYPE = PRAGMA_OMP_CLAUSE_DEVICE_TYPE,

..., and then use 'PRAGMA_OACC_CLAUSE_DEVICE_TYPE' for OpenACC parsing.
In Fortran ('gcc/fortran/openmp.cc:gfc_match_omp_clauses'), you just
re-use 'OMP_CLAUSE_DEVICE_TYPE' also for OpenACC, and disambiguate the
two cases with 'if (openacc)' (as done, for example, for
'OMP_CLAUSE_DEVICE', which also is shared for the OpenACC and OpenMP
'device' clauses, with different semantics).


> And also regarding the argument, I don't have a clear idea how to 
> resolve the type of the device, since the types are defined in
> openacc.h 
>
> - Is there any standard (or suggested way / example) to resolve the type into 
> the
>   argument?

Eh, good find.  I understand your idea is to use the 'openacc.h'-defined
'acc_device_t' enums ('acc_device_nvidia' etc. mapping to '5' etc.).
But, for the 'device_type' clause, the arguments are plain "names".
See, for example, OpenACC 3.4, A. "Recommendations for Implementers":

| A.1.1 NVIDIA GPU Targets
| [...]
| device type clause argument
| An implementation should use the case-insensitive name 'nvidia' as the 
argument to the 'device_type' clause.

Etc.

Therefore, in clause parsing, do a simple '!strcmp ("nvidia", [...])'
etc. (see, for example, the OpenACC/OpenMP 'default' clause parsing), and
then, for your 'GOACC_[...]' function calls, you may use
'GOMP_DEVICE_NVIDIA_PTX' etc. (see 'include/gomp-constants.h', which
defines the "Communication between GCC and libgomp").


Grüße
 Thomas

Reply via email to