https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119677

            Bug ID: 119677
           Summary: [OpenMP][6.1] Support omp_default_device / Cleanup
                    modify_call_for_omp_dispatch via
                    GOMP_DEVICE_DEFAULT_OMP_61
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: openmp
          Severity: normal
          Priority: P3
         Component: libgomp
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---

Created attachment 61034
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=61034&action=edit
Patch that updates modify_call_for_omp_dispatch (+ testcase changes) but no
full libgomp/target.c update

OpenMP 5.2 added omp_initial_device and omp_invalid_device;
OpenMP 6.1/TR14 will add 'omp_default_device'.

Since r15-8654-g99e2906ae255fc, GCC already uses GOMP_DEVICE_DEFAULT_OMP_61
internally.

EXPECTED:

(1) Use GOMP_DEVICE_DEFAULT_OMP_61 internally to avoid 'omp_get_default_device'
    call in modify_call_for_omp_dispatch -> See attached patch.

(2) Consider whether it makes sense also with other compiler-generated lib
calls

(3) API routines in libgomp/target.c have special code to handle:

      if (device_num == omp_initial_device 
          || device_num == gomp_get_num_devices ())

which needs to also handle device_num := omp_default_device to avoids
invalid code.

  For instance, it could be replaced by:

    if (is_intial_device (&device_num))

with

  static inline bool
  is_initial_device (int &device_num)
    {
      if (*device_num == GOMP_DEVICE_DEFAULT_OMP_61)
        { 
          struct gomp_task_icv *icv = gomp_icv (false);
          *device_num = icv->default_device_var;
        }
      return (*device_num == omp_initial_device
              || *device_num == omp_get_initial_device ());
    }


    BTW: Note that omp_set_default_device() ignores omp_default_device
    (according to the spec and as implemented). Otherwise, call it would
    make it impossible to recover a 'real' device number.

(4) Add omp_default_device to omp.h / omp_lib.
    + add some testcases
    + consider updating the documentation for it, cf. PR119676.

Reply via email to