public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [gomp4] Lack of OpenACC NVPTX devices is not an error during scanning
@ 2015-05-19 10:40 Julian Brown
  2015-05-19 11:02 ` Jakub Jelinek
  2015-05-21 15:57 ` Thomas Schwinge
  0 siblings, 2 replies; 3+ messages in thread
From: Julian Brown @ 2015-05-19 10:40 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 452 bytes --]

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.

[-- Attachment #2: no-ptx-devices-not-error-1.diff --]
[-- Type: text/x-patch, Size: 839 bytes --]

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)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-21 15:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-19 10:40 [gomp4] Lack of OpenACC NVPTX devices is not an error during scanning Julian Brown
2015-05-19 11:02 ` Jakub Jelinek
2015-05-21 15:57 ` Thomas Schwinge

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).