From: Julian Brown Date: Tue, 19 May 2015 11:06:31 +0000 (+0000) Subject: plugin-nvptx.c (nvptx_get_num_devices): Return zero on cuInit failure. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c83198264705c6a36d0f20470af67f62928278bb;p=gcc.git plugin-nvptx.c (nvptx_get_num_devices): Return zero on cuInit failure. * plugin/plugin-nvptx.c (nvptx_get_num_devices): Return zero on cuInit failure. From-SVN: r223352 --- diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 33ea5fbf2a2..60ad7f50817 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,8 @@ +2015-05-19 Julian Brown + + * plugin/plugin-nvptx.c (nvptx_get_num_devices): Return zero + on cuInit failure. + 2015-05-13 Jakub Jelinek PR middle-end/66133 diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c index 583ec87aeee..ee3a0ae14a9 100644 --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -782,7 +782,13 @@ nvptx_get_num_devices (void) until cuInit has been called. Just call it now (but don't yet do any further initialization). */ if (instantiated_devices == 0) - cuInit (0); + { + r = cuInit (0); + /* This is not an error: e.g. we may have CUDA libraries installed but + no devices available. */ + if (r != CUDA_SUCCESS) + return 0; + } r = cuDeviceGetCount (&n); if (r!= CUDA_SUCCESS)