On 08.12.22 15:35, Andrew Stubbs wrote:
On 08/12/2022 14:02, Tobias Burnus wrote:
With available, I assume that nvptx is an 'available device' (per OpenMP
definition, finally added in TR11), i.e. there is an image for nvptx and
- after omp_requires filtering - there remains at least one nvptx
device.

If plugin-nvptx has been loaded then the function will be available.
Do we need to get fancier than that?

I think it does not really make sense to use CUDA if there is no single device.
In terms of loading, the code does:

gomp_target_init(void)
{
...
  cur = OFFLOAD_PLUGINS;  /* This is a comma-separated string with the 
supported plugins. */
...
        if (gomp_load_plugin_for_device (&current_device, plugin_name))
          {
            int omp_req = omp_requires_mask & ~GOMP_REQUIRES_TARGET_USED;
            new_num_devs = current_device.get_num_devices_func (omp_req);

Thus, CUDA is loaded at the 'gomp_load_plugin_for_device' line and at the
'new_num_devs =' line, it has been filtered for OpenMP's 'requires' demands.*

Thus, 'new_num_devs' contains the number of 'accessible devices' (OpenMP 
definition),
filtered for the 'requires'* (which part of the 'supported devices' 
requirements).

(* With some caveats related to late loading of offloading code from (shared) 
libraries.)

 * * *

Admittedly, this does not yet cover the last suggested feature:

GOMP_offload_register_ver (...)
{
        gomp_load_image_to_device (devicep, version,

which is relevant for the first part of:

'supported devices' - '... supported by the implementation for execution of 
target code ...
requires directive are fulfilled'.

(available = (intersection of 'accessible devices' and 'supported devices') 
possibly
filtered + reordered via the OMP_AVAILABLE_DEVICES env var.)


I am not sure how strictly it is required and when we know when the all 
offload_register are
over; I do note that OpenMP TR 11 has an over-engineered OMP_AVAILABLE_DEVICES 
environment
variable which permits to filter the list of available devices – which also 
requires early
access to the initial 'available devices' list. But it might be sufficient to 
rely on the
device-is-accessible + requires filtering and ignore whether an actual image is 
available.

Tobias

-----------------
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

Reply via email to