summaryrefslogtreecommitdiff
path: root/test cases/cuda
diff options
context:
space:
mode:
authorOlexa Bilaniuk <obilaniu@gmail.com>2019-01-28 05:29:04 -0500
committerOlexa Bilaniuk <obilaniu@gmail.com>2019-02-02 22:49:02 -0500
commit592af0b1afa03b10beffee481c00c60a7b7db907 (patch)
treee2e2f27733b1357f1078b675ed6cfb19f6ae5181 /test cases/cuda
parentad442b352083a48f97f3f47834b770da1ef1248b (diff)
downloadmeson-592af0b1afa03b10beffee481c00c60a7b7db907.tar.gz
Add unstable CUDA module.
Includes three general utility functions connected to CUDA, in particular the crafting of -gencode flags as done in CMake: https://github.com/Kitware/CMake/blob/master/Modules/FindCUDA/ select_compute_arch.cmake
Diffstat (limited to 'test cases/cuda')
-rw-r--r--test cases/cuda/3 cudamodule/meson.build16
-rw-r--r--test cases/cuda/3 cudamodule/prog.cu30
2 files changed, 46 insertions, 0 deletions
diff --git a/test cases/cuda/3 cudamodule/meson.build b/test cases/cuda/3 cudamodule/meson.build
new file mode 100644
index 000000000..0dc948987
--- /dev/null
+++ b/test cases/cuda/3 cudamodule/meson.build
@@ -0,0 +1,16 @@
+project('cudamodule', 'cuda', version : '1.0.0')
+
+nvcc = meson.get_compiler('cuda')
+cuda = import('unstable-cuda')
+
+arch_flags = cuda.nvcc_arch_flags(nvcc, 'Auto', detected: ['3.0'])
+arch_readable = cuda.nvcc_arch_readable(nvcc, 'Auto', detected: ['3.0'])
+driver_version = cuda.min_driver_version(nvcc)
+
+message('NVCC version: ' + nvcc.version())
+message('NVCC flags: ' + ' '.join(arch_flags))
+message('NVCC readable: ' + ' '.join(arch_readable))
+message('Driver version: >=' + driver_version)
+
+exe = executable('prog', 'prog.cu', cuda_args: arch_flags)
+test('cudatest', exe)
diff --git a/test cases/cuda/3 cudamodule/prog.cu b/test cases/cuda/3 cudamodule/prog.cu
new file mode 100644
index 000000000..7eab6738c
--- /dev/null
+++ b/test cases/cuda/3 cudamodule/prog.cu
@@ -0,0 +1,30 @@
+#include <iostream>
+
+int main(int argc, char **argv) {
+ int cuda_devices = 0;
+ std::cout << "CUDA version: " << CUDART_VERSION << "\n";
+ cudaGetDeviceCount(&cuda_devices);
+ if(cuda_devices == 0) {
+ std::cout << "No Cuda hardware found. Exiting.\n";
+ return 0;
+ }
+ std::cout << "This computer has " << cuda_devices << " Cuda device(s).\n";
+ cudaDeviceProp props;
+ cudaGetDeviceProperties(&props, 0);
+ std::cout << "Properties of device 0.\n\n";
+
+ std::cout << " Name: " << props.name << "\n";
+ std::cout << " Global memory: " << props.totalGlobalMem << "\n";
+ std::cout << " Shared memory: " << props.sharedMemPerBlock << "\n";
+ std::cout << " Constant memory: " << props.totalConstMem << "\n";
+ std::cout << " Block registers: " << props.regsPerBlock << "\n";
+
+ std::cout << " Warp size: " << props.warpSize << "\n";
+ std::cout << " Threads per block: " << props.maxThreadsPerBlock << "\n";
+ std::cout << " Max block dimensions: [ " << props.maxThreadsDim[0] << ", " << props.maxThreadsDim[1] << ", " << props.maxThreadsDim[2] << " ]" << "\n";
+ std::cout << " Max grid dimensions: [ " << props.maxGridSize[0] << ", " << props.maxGridSize[1] << ", " << props.maxGridSize[2] << " ]" << "\n";
+ std::cout << "\n";
+
+ return 0;
+}
+