1 | // Just a little test file to make sure that the CUDA library works |
2 | |
3 | #include <c10/cuda/CUDAException.h> |
4 | #include <c10/cuda/impl/CUDATest.h> |
5 | |
6 | #include <cuda_runtime.h> |
7 | |
8 | namespace c10 { |
9 | namespace cuda { |
10 | namespace impl { |
11 | |
12 | bool has_cuda_gpu() { |
13 | int count; |
14 | C10_CUDA_IGNORE_ERROR(cudaGetDeviceCount(&count)); |
15 | |
16 | return count != 0; |
17 | } |
18 | |
19 | int c10_cuda_test() { |
20 | int r = 0; |
21 | if (has_cuda_gpu()) { |
22 | C10_CUDA_CHECK(cudaGetDevice(&r)); |
23 | } |
24 | return r; |
25 | } |
26 | |
27 | // This function is not exported |
28 | int c10_cuda_private_test() { |
29 | return 2; |
30 | } |
31 | |
32 | } // namespace impl |
33 | } // namespace cuda |
34 | } // namespace c10 |
35 | |