test cases/cuda/10 cuda dependency/c/prog.c
raw| 1 | #include <cuda_runtime.h> |
| 2 | #include <stdio.h> |
| 3 | |
| 4 | int cuda_devices(void) { |
| 5 | int result = 0; |
| 6 | cudaGetDeviceCount(&result); |
| 7 | return result; |
| 8 | } |
| 9 | |
| 10 | int main(void) { |
| 11 | int n = cuda_devices(); |
| 12 | if (n == 0) { |
| 13 | printf("No CUDA hardware found. Exiting.\n"); |
| 14 | return 0; |
| 15 | } |
| 16 | |
| 17 | printf("Found %i CUDA devices.\n", n); |
| 18 | return 0; |
| 19 | } |