"alloc",
"calloc",
"free",
- "get_device_from_uid",
"get_interop_int",
"get_interop_ptr",
"get_mapped_ptr",
"get_cancellation",
"get_default_allocator",
"get_default_device",
+ "get_device_from_uid",
"get_device_num",
"get_dynamic",
"get_initial_device",
as DECL_NAME only omp_* and omp_*_8 appear. */
"display_env",
"get_ancestor_thread_num",
- "omp_get_uid_from_device",
+ "get_uid_from_device",
"get_partition_place_nums",
"get_place_num_procs",
"get_place_proc_ids",
*res_len = *res ? strlen (*res) : 0;
}
+int
+omp_get_device_from_uid_ (const char *uid, size_t uid_len)
+{
+#ifndef LIBGOMP_OFFLOADED_ONLY
+ char *str = __builtin_alloca ((uid_len + 1) * sizeof (char));
+ memcpy (str, uid, uid_len * sizeof (char));
+ str[uid_len] = '\0';
+ return omp_get_device_from_uid (str);
+#else
+ /* Inside the target region, invoking this routine is undefined
+ behavior; thus, resolve it already here - instead of inside
+ libgomp/config/.../target.c.
+ Note that on nvptx __builtin_alloca is defined, but fails with a sorry
+ during compilation, as it is unsupported until isa 7.3 / sm_52. */
+ return omp_invalid_device;
+#endif
+}
+
void
omp_get_uid_from_device_ (const char **res, size_t *res_len,
int32_t device_num)
GOMP_6.0 {
global:
omp_get_device_from_uid;
+ omp_get_device_from_uid_;
omp_get_uid_from_device;
omp_get_uid_from_device_;
omp_get_uid_from_device_8_;
static struct gomp_device_descr host_dispatch =
{
.name = "host",
+ .uid = NULL,
.capabilities = (GOMP_OFFLOAD_CAP_SHARED_MEM
| GOMP_OFFLOAD_CAP_NATIVE_EXEC
| GOMP_OFFLOAD_CAP_OPENACC_200),
.type = OFFLOAD_TARGET_TYPE_HOST,
.get_name_func = host_get_name,
+ .get_uid_func = NULL,
.get_caps_func = host_get_caps,
.get_type_func = host_get_type,
.get_num_devices_func = host_get_num_devices,
end interface
interface
- ! Note: In gfortran, strings are \0 termined
- integer(c_int) function omp_get_device_from_uid(uid) bind(C)
+ integer(c_int) function omp_get_device_from_uid (uid)
use iso_c_binding
- character(c_char), intent(in) :: uid(*)
+ character, intent(in) :: uid(*)
end function omp_get_device_from_uid
end interface
end interface
interface
-! Note: In gfortran, strings are \0 termined
- integer(c_int) function omp_get_device_from_uid(uid) bind(C)
+ integer(c_int) function omp_get_device_from_uid (uid)
use iso_c_binding
- character(c_char), intent(in) :: uid(*)
+ character, intent(in) :: uid(*)
end function omp_get_device_from_uid
end interface
return "gcn";
}
+/* Return the UID; if not available return NULL.
+ Returns freshly allocated memoy. */
+
const char *
GOMP_OFFLOAD_get_uid (int ord)
{
status = hsa_fns.hsa_agent_get_info_fn (agent->id, HSA_AMD_AGENT_INFO_UUID,
str);
if (status != HSA_STATUS_SUCCESS)
- hsa_fatal ("Could not obtain device UUID", status);
+ {
+ free (str);
+ return NULL;
+ }
return str;
}
return "nvptx";
}
+/* Return the UID; if not available return NULL.
+ Returns freshly allocated memoy. */
+
const char *
GOMP_OFFLOAD_get_uid (int ord)
{
else if (CUDA_CALL_EXISTS (cuDeviceGetUuid))
r = CUDA_CALL_NOCHECK (cuDeviceGetUuid, &s, dev->dev);
else
- r = CUDA_ERROR_NOT_FOUND;
+ return NULL;
if (r != CUDA_SUCCESS)
- GOMP_PLUGIN_fatal ("cuDeviceGetUuid error: %s", cuda_error (r));
+ NULL;
size_t len = strlen ("GPU-12345678-9abc-defg-hijk-lmniopqrstuv");
char *str = (char *) GOMP_PLUGIN_malloc (len + 1);
if (strcmp (uid, str_omp_initial_device) == 0)
return omp_initial_device;
for (int dev = 0; dev < gomp_get_num_devices (); dev++)
- if (strcmp (uid, gomp_get_uid_for_device (&devices[dev], dev)) == 0)
- return dev;
+ {
+ struct gomp_device_descr *devicep = resolve_device (dev, false);
+ if (strcmp (uid, gomp_get_uid_for_device (devicep, dev)) == 0)
+ return dev;
+ }
return omp_invalid_device;
}
do i = omp_invalid_device - 1, omp_get_num_devices () + 1
str => omp_get_uid_from_device (i)
- dev = omp_get_device_from_uid (str);
+ dev = omp_get_device_from_uid (str)
! print *, i, str, dev
if (i < omp_initial_device .or. i > omp_get_num_devices ()) then
if (dev /= omp_invalid_device .or. associated(str)) &
stop 4
end if
strs(dev)%str => str
+
+ block
+ ! Check substring handling
+ character(len=100) :: long_str
+ integer :: dev2
+ long_str = str // "ABCDEF"
+ dev2 = omp_get_device_from_uid (long_str(1:len(str)))
+ if (i == omp_initial_device .or. i == omp_get_num_devices ()) then
+ if (dev2 /= omp_initial_device .and. dev2 /= omp_get_num_devices ()) &
+ stop 5
+ else if (dev /= dev2) then
+ stop 6
+ end if
+ end block
end do
do i = 0, omp_get_num_devices () - 1
do j = i + 1, omp_get_num_devices ()
if (strs(i)%str == strs(j)%str) &
- stop 4
+ stop 7
end do
end do
deallocate (strs)