summaryrefslogtreecommitdiff
path: root/libgomp
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2018-08-08 14:26:28 +0000
committerTom de Vries <vries@gcc.gnu.org>2018-08-08 14:26:28 +0000
commitcedd9bd016db29cc7f7f358125a89193d81dfa50 (patch)
tree5eaefa2fde4ae620a9d6848791130ac97f8d7443 /libgomp
parentb113af959cc00dd8726298003e837b5824288649 (diff)
downloadgcc-cedd9bd016db29cc7f7f358125a89193d81dfa50.tar.gz
[libgomp, nvptx] Allow cuGetErrorString to be NULL
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. From-SVN: r263407
Diffstat (limited to 'libgomp')
-rw-r--r--libgomp/ChangeLog6
-rw-r--r--libgomp/plugin/cuda-lib.def2
-rw-r--r--libgomp/plugin/plugin-nvptx.c10
3 files changed, 14 insertions, 4 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index c425f688147..605c84c2286 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,5 +1,11 @@
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
(CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR): Define.
(nvptx_open_device): Use
diff --git a/libgomp/plugin/cuda-lib.def b/libgomp/plugin/cuda-lib.def
index be8e3b3ec4d..6365cdbfcbe 100644
--- a/libgomp/plugin/cuda-lib.def
+++ b/libgomp/plugin/cuda-lib.def
@@ -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)
diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index 589d6596cc2..b549b774003 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -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;