diff options
| author | Aleksey Gurtovoy <agurtovoy@acm.org> | 2019-10-04 18:34:02 -0500 |
|---|---|---|
| committer | Jussi Pakkanen <jpakkane@gmail.com> | 2019-11-05 22:17:44 +0200 |
| commit | f56ef583d3c8ecda7725ca04b48011c9081a7349 (patch) | |
| tree | dca107fce3c6cafa32e575406020be827b6197fa /test cases/cuda/10 cuda dependency/cpp | |
| parent | 11f1adb7ddc800b8c016f3ee40e979a377ba9c01 (diff) | |
| download | meson-f56ef583d3c8ecda7725ca04b48011c9081a7349.tar.gz | |
dependency('cuda')
Diffstat (limited to 'test cases/cuda/10 cuda dependency/cpp')
| -rw-r--r-- | test cases/cuda/10 cuda dependency/cpp/meson.build | 2 | ||||
| -rw-r--r-- | test cases/cuda/10 cuda dependency/cpp/prog.cc | 19 |
2 files changed, 21 insertions, 0 deletions
diff --git a/test cases/cuda/10 cuda dependency/cpp/meson.build b/test cases/cuda/10 cuda dependency/cpp/meson.build new file mode 100644 index 000000000..a661b8875 --- /dev/null +++ b/test cases/cuda/10 cuda dependency/cpp/meson.build @@ -0,0 +1,2 @@ +exe = executable('prog', 'prog.cc', dependencies: dependency('cuda')) +test('cudatest', exe) diff --git a/test cases/cuda/10 cuda dependency/cpp/prog.cc b/test cases/cuda/10 cuda dependency/cpp/prog.cc new file mode 100644 index 000000000..728debc83 --- /dev/null +++ b/test cases/cuda/10 cuda dependency/cpp/prog.cc @@ -0,0 +1,19 @@ +#include <cuda_runtime.h> +#include <iostream> + +int cuda_devices() { + int result = 0; + cudaGetDeviceCount(&result); + return result; +} + +int main() { + int n = cuda_devices(); + if (n == 0) { + std::cout << "No CUDA hardware found. Exiting.\n"; + return 0; + } + + std::cout << "Found " << n << " CUDA devices.\n"; + return 0; +} |
