https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119036
Bug ID: 119036 Summary: [OpenMP] dispatch with interop(obj) clause and obj == omp_interop_none should not set default-device-var ICV Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: openmp Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: sandra at gcc dot gnu.org Target Milestone: --- OpenMP has: "If the 'interop' clause is present and has only one interop-var, and the 'device' clause is not specified, the behavior is as if the 'device' clause is present with a device-description equivalent to the device_num property of the interop-var." This does not (yet) specify what happens when interop-var has the value omp_interop_none but IMHO, it makes most sense to not touch the default-device-var ICV. → associated OpenMP issue is #4459 Currently, the GCC uses - in gcc/gimplify.cc's gimplify_omp_dispatch: dev_num = omp_get_interop_int(obj, omp_ipr_device_num, NULL); Expected - either of (a) Use omp_default_device, i.e. dev_num = obj == omp_interop_none ? omp_default_device : omp_get_interop_int(obj, omp_ipr_device_num, NULL); → This requires that omp_default_device support has been added to omp_set_default_device + omp_default_device added to include/gomp-constants.h (b) Guard the code, i.e. if (obj != omp_interop_none) { dev_num = omp_get_interop_int(obj, omp_ipr_device_num, NULL); saved_device = omp_get_default_device (); omp_set_default_device (dev_num); } ... if (obj != omp_interop_none) omp_set_default_device (saved_dev_num); Regarding (a): To make that OpenMP 6.1/TR15 feature available to the users, it additionally has to be added to libgomp/{omp.h.in,omp_lib.{f90,h}.in} and libgomp/target.c.