* plugin/plugin-nvptx.c (nvptx_get_num_devices): Return zero
authorjules <jules@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 May 2015 11:06:31 +0000 (11:06 +0000)
committerjules <jules@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 19 May 2015 11:06:31 +0000 (11:06 +0000)
on cuInit failure.

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

libgomp/ChangeLog
libgomp/plugin/plugin-nvptx.c

index 33ea5fb..60ad7f5 100644 (file)
@@ -1,3 +1,8 @@
+2015-05-19  Julian Brown  <julian@codesourcery.com>
+
+       * plugin/plugin-nvptx.c (nvptx_get_num_devices): Return zero
+       on cuInit failure.
+
 2015-05-13  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/66133
index 583ec87..ee3a0ae 100644 (file)
@@ -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)