[gomp4] Lack of OpenACC NVPTX devices is not an error during scanning
diff mbox

Message ID 20150519113658.20df46ff@octopus
State New
Headers show

Commit Message

Julian Brown May 19, 2015, 10:36 a.m. UTC
Hi,

This patch fixes an oversight whereby if the CUDA libraries are
available for some reason on a system that doesn't actually contain an
nVidia card, an OpenACC program will raise an error if the NVPTX
backend is picked as a default instead of falling back to some other
device instead.

OK for gomp4 branch? For trunk?

Thanks,

Julian

ChangeLog

    libgomp/
    * plugin/plugin-nvptx.c (nvptx_get_num_devices): Return zero
    on cuInit failure.

Comments

Jakub Jelinek May 19, 2015, 10:40 a.m. UTC | #1
On Tue, May 19, 2015 at 11:36:58AM +0100, Julian Brown wrote:
> This patch fixes an oversight whereby if the CUDA libraries are
> available for some reason on a system that doesn't actually contain an
> nVidia card, an OpenACC program will raise an error if the NVPTX
> backend is picked as a default instead of falling back to some other
> device instead.
> 
> OK for gomp4 branch? For trunk?
> 
> Thanks,
> 
> Julian
> 
> ChangeLog
> 
>     libgomp/
>     * plugin/plugin-nvptx.c (nvptx_get_num_devices): Return zero
>     on cuInit failure.

LGTM.

	Jakub

Patch
diff mbox

commit 696a0d7e22bb8217ff581886cdf0979bfc2e85bb
Author: Julian Brown <julian@codesourcery.com>
Date:   Fri May 15 03:22:56 2015 -0700

    Lack of PTX devices is not an error during scanning.

diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index b36691a..d09a91c 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -781,7 +781,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)