On 6/4/25 08:15, Tobias Burnus wrote:
This came up when looking at some context selectors that use 'target_device',
but is largely unrelated to it. (target_device has its own special casing).

Namely, it makes omp_get_initial_device and omp_get_num_devices PURE,
which attributes don't permit for Fortran - based on the state that
the number of devices cannot change after startup. I am not sure whether
"LEAF" is true here (and elsewhere) as the check whether the devices
setup has been to run. [Q:] Is that's an issue?

Caveat: Using -std=c++XX will disable all OpenMP builtins, unless
-fbuiltin-... or -fnonansi-builtins. I wonder whether
[RFC 1] we should do something about this ...

[RFC 1]
- Does this patch make sense or not?
- Do the simplifications make sense or not?
- Is the documentation fine or overly complex?

My complaint about the documentation isn't that it's overly complex, but this paragraph is pretty garbled:

+Note that in GCC this function call is already folded to at compile time:
+To the value @code{omp_initial_device} in non-host code, to zero if GCC
+was not configured to support offloading, or otherwise to a call to
+@code{omp_get_num_devices}; compile with
+@option{-fno-builtin-omp_get_initial_device} if a run-time function is desired.

I suggest rewriting this as:

Note that GCC inlines this function unless you compile with @option{-fno-builtin-omp_get_initial_device}. If GCC was not configured to support offloading, it expands to constant zero; in non-host code it expands to @code{omp_initial_device}; and otherwise it is replaced with a call to @code{omp_get_num_devices}.

-Sandra

Reply via email to