]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[libgomp, nvptx] Allow cuGetErrorString to be NULL
authorvries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 8 Aug 2018 14:26:28 +0000 (14:26 +0000)
committervries <vries@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 8 Aug 2018 14:26:28 +0000 (14:26 +0000)
Cuda driver api function cuGetErrorString is available in version 6.0 and
higher.

Currently, when the driver that is used does not contain this function, the
libgomp nvptx plugin will not build (PLUGIN_NVPTX_DYNAMIC == 0) or run
(PLUGIN_NVPTX_DYNAMIC == 1).

This patch fixes this problem by testing for the presence of the function, and
handling absence.

Build on x86_64 with nvptx accelerator and reg-tested libgomp, both with and
without --without-cuda-driver.

2018-08-08  Tom de Vries  <tdevries@suse.de>

* plugin/cuda-lib.def (cuGetErrorString): Use CUDA_ONE_CALL_MAYBE_NULL.
* plugin/plugin-nvptx.c (cuda_error): Handle if cuGetErrorString is not
present.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@263407 138bc75d-0d04-0410-961f-82ee72b054a4

libgomp/ChangeLog
libgomp/plugin/cuda-lib.def
libgomp/plugin/plugin-nvptx.c

index c425f688147e4f60e28d17d4d9d983144872d5e8..605c84c228697254686ebe9c7071a5d31aa29460 100644 (file)
@@ -1,3 +1,9 @@
+2018-08-08  Tom de Vries  <tdevries@suse.de>
+
+       * plugin/cuda-lib.def (cuGetErrorString): Use CUDA_ONE_CALL_MAYBE_NULL.
+       * plugin/plugin-nvptx.c (cuda_error): Handle if cuGetErrorString is not
+       present.
+
 2018-08-08  Tom de Vries  <tdevries@suse.de>
 
        * plugin/plugin-nvptx.c
index be8e3b3ec4d6baf25a68cc2a532b3bd410856f8c..6365cdbfcbe4e147b653af681bc93b11967be9c7 100644 (file)
@@ -15,7 +15,7 @@ CUDA_ONE_CALL (cuEventQuery)
 CUDA_ONE_CALL (cuEventRecord)
 CUDA_ONE_CALL (cuEventSynchronize)
 CUDA_ONE_CALL (cuFuncGetAttribute)
-CUDA_ONE_CALL (cuGetErrorString)
+CUDA_ONE_CALL_MAYBE_NULL (cuGetErrorString)
 CUDA_ONE_CALL (cuInit)
 CUDA_ONE_CALL (cuLaunchKernel)
 CUDA_ONE_CALL (cuLinkAddData)
index 589d6596cc2f307dfebcedd883c41514ba411d43..b549b774003951f8289eab14c286e3ecbf51f19e 100644 (file)
@@ -161,13 +161,17 @@ init_cuda_lib (void)
 static const char *
 cuda_error (CUresult r)
 {
+  const char *fallback = "unknown cuda error";
   const char *desc;
 
+  if (!CUDA_CALL_EXISTS (cuGetErrorString))
+    return fallback;
+
   r = CUDA_CALL_NOCHECK (cuGetErrorString, r, &desc);
-  if (r != CUDA_SUCCESS)
-    desc = "unknown cuda error";
+  if (r == CUDA_SUCCESS)
+    return desc;
 
-  return desc;
+  return fallback;
 }
 
 static unsigned int instantiated_devices = 0;