static bool nvptx_init (void) { CUresult r; int ndevs; if (instantiated_devices != 0) return true; r = cuInit (0); if (r != CUDA_SUCCESS) GOMP_PLUGIN_fatal ("cuInit error: %s", cuda_error (r)); ptx_events = NULL; pthread_mutex_init (&ptx_event_lock, NULL); r = cuDeviceGetCount (&ndevs); if (r != CUDA_SUCCESS) GOMP_PLUGIN_fatal ("cuDeviceGetCount error: %s", cuda_error (r)); ptx_devices = GOMP_PLUGIN_malloc_cleared (sizeof (struct ptx_device *) * ndevs); return true; }
static bool nvptx_init (void) { int ndevs; if (instantiated_devices != 0) return true; CUDA_CALL (cuInit, 0); ptx_events = NULL; pthread_mutex_init (&ptx_event_lock, NULL); CUDA_CALL (cuDeviceGetCount, &ndevs); ptx_devices = GOMP_PLUGIN_malloc_cleared (sizeof (struct ptx_device *) * ndevs); return true; }