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
This commit is contained in:
Julian Brown 2015-05-19 11:06:31 +00:00 committed by Julian Brown
parent 9626d143b9
commit c831982647
2 changed files with 12 additions and 1 deletions

View 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

View 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)