summaryrefslogtreecommitdiff
path: root/libgomp/plugin
diff options
context:
space:
mode:
authorTobias Burnus <tburnus@baylibre.com>2024-09-23 15:58:39 +0200
committerTobias Burnus <tburnus@baylibre.com>2024-09-23 15:58:39 +0200
commitcdb9aa0f623ec7899da445a47f4a502b2987dc7b (patch)
treea228cf5ab250fea524958ea258dcfd038531ecdb /libgomp/plugin
parentffd861c808f307c865659b556dd5a8c922bd6a51 (diff)
OpenMP: Fix omp_get_device_from_uid, minor cleanup
In Fortran, omp_get_device_from_uid can also accept substrings, which are then not NUL terminated. Fixed by introducing a fortran.c wrapper function. Additionally, in case of a fail the plugin functions now return NULL instead of failing fatally such that a fall-back UID is generated. gcc/ChangeLog: * omp-general.cc (omp_runtime_api_procname): Strip "omp_" from string; move get_device_from_uid as now a '_' suffix exists. libgomp/ChangeLog: * fortran.c (omp_get_device_from_uid_): New function. * libgomp.map (GOMP_6.0): Add it. * oacc-host.c (host_dispatch): Init '.uid' and '.get_uid_func'. * omp_lib.f90.in: Make it used by removing bind(C). * omp_lib.h.in: Likewise. * target.c (omp_get_device_from_uid): Ensure the device is initialized. * plugin/plugin-gcn.c (GOMP_OFFLOAD_get_uid): Add function comment; return NULL in case of an error. * plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_uid): Likewise. * testsuite/libgomp.fortran/device_uid.f90: Update to test substrings.
Diffstat (limited to 'libgomp/plugin')
-rw-r--r--libgomp/plugin/plugin-gcn.c8
-rw-r--r--libgomp/plugin/plugin-nvptx.c7
2 files changed, 12 insertions, 3 deletions
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index bf6ad371ea2..f805206852d 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -3316,6 +3316,9 @@ GOMP_OFFLOAD_get_name (void)
return "gcn";
}
+/* Return the UID; if not available return NULL.
+ Returns freshly allocated memoy. */
+
const char *
GOMP_OFFLOAD_get_uid (int ord)
{
@@ -3328,7 +3331,10 @@ 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;
}
diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index a8b85bd9fd0..9310241d4fb 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -1242,6 +1242,9 @@ GOMP_OFFLOAD_get_name (void)
return "nvptx";
}
+/* Return the UID; if not available return NULL.
+ Returns freshly allocated memoy. */
+
const char *
GOMP_OFFLOAD_get_uid (int ord)
{
@@ -1254,9 +1257,9 @@ 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);