summaryrefslogtreecommitdiffstats
path: root/test cases/cuda
diff options
context:
space:
mode:
Diffstat (limited to 'test cases/cuda')
-rw-r--r--test cases/cuda/1 simple/meson.build4
-rw-r--r--test cases/cuda/1 simple/prog.cu29
-rw-r--r--test cases/cuda/10 cuda dependency/c/meson.build2
-rw-r--r--test cases/cuda/10 cuda dependency/c/prog.c19
-rw-r--r--test cases/cuda/10 cuda dependency/cpp/meson.build2
-rw-r--r--test cases/cuda/10 cuda dependency/cpp/prog.cc19
-rw-r--r--test cases/cuda/10 cuda dependency/meson.build6
-rw-r--r--test cases/cuda/10 cuda dependency/modules/meson.build2
-rw-r--r--test cases/cuda/10 cuda dependency/modules/prog.cc33
-rw-r--r--test cases/cuda/10 cuda dependency/version_reqs/meson.build2
-rw-r--r--test cases/cuda/10 cuda dependency/version_reqs/prog.cc28
-rw-r--r--test cases/cuda/11 cuda dependency (nvcc)/meson.build4
-rw-r--r--test cases/cuda/11 cuda dependency (nvcc)/modules/meson.build2
-rw-r--r--test cases/cuda/11 cuda dependency (nvcc)/modules/prog.cu33
-rw-r--r--test cases/cuda/11 cuda dependency (nvcc)/version_reqs/meson.build2
-rw-r--r--test cases/cuda/11 cuda dependency (nvcc)/version_reqs/prog.cu29
-rw-r--r--test cases/cuda/12 cuda dependency (mixed)/kernel.cu8
-rw-r--r--test cases/cuda/12 cuda dependency (mixed)/meson.build4
-rw-r--r--test cases/cuda/12 cuda dependency (mixed)/prog.cpp37
-rw-r--r--test cases/cuda/13 cuda compiler setting/meson.build4
-rw-r--r--test cases/cuda/13 cuda compiler setting/nativefile.ini3
-rw-r--r--test cases/cuda/13 cuda compiler setting/prog.cu29
-rw-r--r--test cases/cuda/14 cuda has header symbol/meson.build26
-rw-r--r--test cases/cuda/15 sanitizer/meson.build4
-rw-r--r--test cases/cuda/15 sanitizer/prog.cu29
-rw-r--r--test cases/cuda/16 multistd/lib.cu3
-rw-r--r--test cases/cuda/16 multistd/main.cu21
-rw-r--r--test cases/cuda/16 multistd/meson.build13
-rw-r--r--test cases/cuda/2 split/lib.cu12
-rw-r--r--test cases/cuda/2 split/main.cpp7
-rw-r--r--test cases/cuda/2 split/meson.build6
-rw-r--r--test cases/cuda/2 split/static/lib.cu12
-rw-r--r--test cases/cuda/2 split/static/libsta.cu12
-rw-r--r--test cases/cuda/2 split/static/main_static.cpp7
-rw-r--r--test cases/cuda/2 split/static/meson.build4
-rw-r--r--test cases/cuda/3 cudamodule/meson.build69
-rw-r--r--test cases/cuda/3 cudamodule/prog.cu29
-rw-r--r--test cases/cuda/4 shared/main.cu20
-rw-r--r--test cases/cuda/4 shared/meson.build6
-rw-r--r--test cases/cuda/4 shared/shared/kernels.cu13
-rw-r--r--test cases/cuda/4 shared/shared/kernels.h86
-rw-r--r--test cases/cuda/4 shared/shared/meson.build7
-rw-r--r--test cases/cuda/5 threads/main.cu20
-rw-r--r--test cases/cuda/5 threads/meson.build7
-rw-r--r--test cases/cuda/5 threads/shared/kernels.cu13
-rw-r--r--test cases/cuda/5 threads/shared/kernels.h86
-rw-r--r--test cases/cuda/5 threads/shared/meson.build5
-rw-r--r--test cases/cuda/6 std/main.cu20
-rw-r--r--test cases/cuda/6 std/meson.build4
-rw-r--r--test cases/cuda/7 static vs runtime/main.cu20
-rw-r--r--test cases/cuda/7 static vs runtime/meson.build4
-rw-r--r--test cases/cuda/8 release/main.cu24
-rw-r--r--test cases/cuda/8 release/meson.build10
-rw-r--r--test cases/cuda/9 optimize for space/main.cu20
-rw-r--r--test cases/cuda/9 optimize for space/meson.build4
55 files changed, 924 insertions, 0 deletions
diff --git a/test cases/cuda/1 simple/meson.build b/test cases/cuda/1 simple/meson.build
new file mode 100644
index 0000000..4f111d1
--- /dev/null
+++ b/test cases/cuda/1 simple/meson.build
@@ -0,0 +1,4 @@
+project('simple', 'cuda', version : '1.0.0')
+
+exe = executable('prog', 'prog.cu')
+test('cudatest', exe)
diff --git a/test cases/cuda/1 simple/prog.cu b/test cases/cuda/1 simple/prog.cu
new file mode 100644
index 0000000..06521b2
--- /dev/null
+++ b/test cases/cuda/1 simple/prog.cu
@@ -0,0 +1,29 @@
+#include <iostream>
+
+int main(void) {
+ 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;
+}
diff --git a/test cases/cuda/10 cuda dependency/c/meson.build b/test cases/cuda/10 cuda dependency/c/meson.build
new file mode 100644
index 0000000..921bc43
--- /dev/null
+++ b/test cases/cuda/10 cuda dependency/c/meson.build
@@ -0,0 +1,2 @@
+exe = executable('prog', 'prog.c', dependencies: dependency('cuda'))
+test('cudatest', exe)
diff --git a/test cases/cuda/10 cuda dependency/c/prog.c b/test cases/cuda/10 cuda dependency/c/prog.c
new file mode 100644
index 0000000..ed9333e
--- /dev/null
+++ b/test cases/cuda/10 cuda dependency/c/prog.c
@@ -0,0 +1,19 @@
+#include <cuda_runtime.h>
+#include <stdio.h>
+
+int cuda_devices(void) {
+ int result = 0;
+ cudaGetDeviceCount(&result);
+ return result;
+}
+
+int main(void) {
+ int n = cuda_devices();
+ if (n == 0) {
+ printf("No CUDA hardware found. Exiting.\n");
+ return 0;
+ }
+
+ printf("Found %i CUDA devices.\n", n);
+ return 0;
+}
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 0000000..a661b88
--- /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 0000000..4832afa
--- /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(void) {
+ int result = 0;
+ cudaGetDeviceCount(&result);
+ return result;
+}
+
+int main(void) {
+ 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;
+}
diff --git a/test cases/cuda/10 cuda dependency/meson.build b/test cases/cuda/10 cuda dependency/meson.build
new file mode 100644
index 0000000..3e602b6
--- /dev/null
+++ b/test cases/cuda/10 cuda dependency/meson.build
@@ -0,0 +1,6 @@
+project('cuda dependency', 'c', 'cpp')
+
+subdir('c')
+subdir('cpp')
+subdir('modules')
+subdir('version_reqs')
diff --git a/test cases/cuda/10 cuda dependency/modules/meson.build b/test cases/cuda/10 cuda dependency/modules/meson.build
new file mode 100644
index 0000000..0da43f2
--- /dev/null
+++ b/test cases/cuda/10 cuda dependency/modules/meson.build
@@ -0,0 +1,2 @@
+exe = executable('prog', 'prog.cc', dependencies: dependency('cuda', modules: ['cublas']))
+test('cudatest', exe)
diff --git a/test cases/cuda/10 cuda dependency/modules/prog.cc b/test cases/cuda/10 cuda dependency/modules/prog.cc
new file mode 100644
index 0000000..b4af4d4
--- /dev/null
+++ b/test cases/cuda/10 cuda dependency/modules/prog.cc
@@ -0,0 +1,33 @@
+#include <cuda_runtime.h>
+#include <cublas_v2.h>
+#include <iostream>
+
+int cuda_devices(void) {
+ int result = 0;
+ cudaGetDeviceCount(&result);
+ return result;
+}
+
+int main(void) {
+ int n = cuda_devices();
+ if (n == 0) {
+ std::cout << "No CUDA hardware found. Exiting.\n";
+ return 0;
+ }
+
+ std::cout << "Found " << n << " CUDA devices.\n";
+
+ cublasHandle_t handle;
+ if (cublasCreate(&handle) != CUBLAS_STATUS_SUCCESS) {
+ std::cout << "cuBLAS initialization failed. Exiting.\n";
+ return -1;
+ }
+
+ std::cout << "Initialized cuBLAS\n";
+ if (cublasDestroy(handle) != CUBLAS_STATUS_SUCCESS) {
+ std::cout << "cuBLAS de-initialization failed. Exiting.\n";
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/test cases/cuda/10 cuda dependency/version_reqs/meson.build b/test cases/cuda/10 cuda dependency/version_reqs/meson.build
new file mode 100644
index 0000000..45b5daa
--- /dev/null
+++ b/test cases/cuda/10 cuda dependency/version_reqs/meson.build
@@ -0,0 +1,2 @@
+exe = executable('prog', 'prog.cc', dependencies: dependency('cuda', version: ['>=8.5', '<10'], required: false, disabler: true))
+test('cudatest', exe)
diff --git a/test cases/cuda/10 cuda dependency/version_reqs/prog.cc b/test cases/cuda/10 cuda dependency/version_reqs/prog.cc
new file mode 100644
index 0000000..5668830
--- /dev/null
+++ b/test cases/cuda/10 cuda dependency/version_reqs/prog.cc
@@ -0,0 +1,28 @@
+#include <cuda_runtime.h>
+#include <iostream>
+
+int cuda_devices(void) {
+ int result = 0;
+ cudaGetDeviceCount(&result);
+ return result;
+}
+
+int main(void) {
+ std::cout << "Compiled against CUDA version: " << CUDART_VERSION << "\n";
+ int runtime_version = 0;
+ cudaError_t r = cudaRuntimeGetVersion(&runtime_version);
+ if (r != cudaSuccess) {
+ std::cout << "Couldn't obtain CUDA runtime version (error " << r << "). Exiting.\n";
+ return -1;
+ }
+ std::cout << "CUDA runtime version: " << runtime_version << "\n";
+
+ 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;
+}
diff --git a/test cases/cuda/11 cuda dependency (nvcc)/meson.build b/test cases/cuda/11 cuda dependency (nvcc)/meson.build
new file mode 100644
index 0000000..67b6568
--- /dev/null
+++ b/test cases/cuda/11 cuda dependency (nvcc)/meson.build
@@ -0,0 +1,4 @@
+project('cuda dependency', 'cuda')
+
+subdir('modules')
+subdir('version_reqs')
diff --git a/test cases/cuda/11 cuda dependency (nvcc)/modules/meson.build b/test cases/cuda/11 cuda dependency (nvcc)/modules/meson.build
new file mode 100644
index 0000000..c0fed83
--- /dev/null
+++ b/test cases/cuda/11 cuda dependency (nvcc)/modules/meson.build
@@ -0,0 +1,2 @@
+exe = executable('prog', 'prog.cu', dependencies: dependency('cuda', modules: ['cublas']))
+test('cudatest', exe)
diff --git a/test cases/cuda/11 cuda dependency (nvcc)/modules/prog.cu b/test cases/cuda/11 cuda dependency (nvcc)/modules/prog.cu
new file mode 100644
index 0000000..b4af4d4
--- /dev/null
+++ b/test cases/cuda/11 cuda dependency (nvcc)/modules/prog.cu
@@ -0,0 +1,33 @@
+#include <cuda_runtime.h>
+#include <cublas_v2.h>
+#include <iostream>
+
+int cuda_devices(void) {
+ int result = 0;
+ cudaGetDeviceCount(&result);
+ return result;
+}
+
+int main(void) {
+ int n = cuda_devices();
+ if (n == 0) {
+ std::cout << "No CUDA hardware found. Exiting.\n";
+ return 0;
+ }
+
+ std::cout << "Found " << n << " CUDA devices.\n";
+
+ cublasHandle_t handle;
+ if (cublasCreate(&handle) != CUBLAS_STATUS_SUCCESS) {
+ std::cout << "cuBLAS initialization failed. Exiting.\n";
+ return -1;
+ }
+
+ std::cout << "Initialized cuBLAS\n";
+ if (cublasDestroy(handle) != CUBLAS_STATUS_SUCCESS) {
+ std::cout << "cuBLAS de-initialization failed. Exiting.\n";
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/test cases/cuda/11 cuda dependency (nvcc)/version_reqs/meson.build b/test cases/cuda/11 cuda dependency (nvcc)/version_reqs/meson.build
new file mode 100644
index 0000000..6644c9e
--- /dev/null
+++ b/test cases/cuda/11 cuda dependency (nvcc)/version_reqs/meson.build
@@ -0,0 +1,2 @@
+exe = executable('prog', 'prog.cu', dependencies: dependency('cuda', version: ['>=10.1'], required: false, disabler: true))
+test('cudatest', exe)
diff --git a/test cases/cuda/11 cuda dependency (nvcc)/version_reqs/prog.cu b/test cases/cuda/11 cuda dependency (nvcc)/version_reqs/prog.cu
new file mode 100644
index 0000000..bc90081
--- /dev/null
+++ b/test cases/cuda/11 cuda dependency (nvcc)/version_reqs/prog.cu
@@ -0,0 +1,29 @@
+#include <cuda_runtime.h>
+#include <iostream>
+
+int cuda_devices(void) {
+ int result = 0;
+ cudaGetDeviceCount(&result);
+ return result;
+}
+
+int main(void) {
+ std::cout << "Compiled against CUDA version: " << CUDART_VERSION << "\n";
+
+ int runtime_version = 0;
+ switch (cudaError_t r = cudaRuntimeGetVersion(&runtime_version)) {
+ case cudaSuccess:
+ std::cout << "CUDA runtime version: " << runtime_version << "\n";
+ break;
+ case cudaErrorNoDevice:
+ std::cout << "No CUDA hardware found. Exiting.\n";
+ return 0;
+ default:
+ std::cout << "Couldn't obtain CUDA runtime version (error " << r << "). Exiting.\n";
+ return -1;
+ }
+
+ int n = cuda_devices();
+ std::cout << "Found " << n << " CUDA devices.\n";
+ return 0;
+}
diff --git a/test cases/cuda/12 cuda dependency (mixed)/kernel.cu b/test cases/cuda/12 cuda dependency (mixed)/kernel.cu
new file mode 100644
index 0000000..7daaa68
--- /dev/null
+++ b/test cases/cuda/12 cuda dependency (mixed)/kernel.cu
@@ -0,0 +1,8 @@
+#include <cuda_runtime.h>
+
+__global__ void kernel (void){
+}
+
+void do_cuda_stuff(void) {
+ kernel<<<1,1>>>();
+}
diff --git a/test cases/cuda/12 cuda dependency (mixed)/meson.build b/test cases/cuda/12 cuda dependency (mixed)/meson.build
new file mode 100644
index 0000000..5df4f84
--- /dev/null
+++ b/test cases/cuda/12 cuda dependency (mixed)/meson.build
@@ -0,0 +1,4 @@
+project('cuda dependency', 'cpp', 'cuda')
+
+exe = executable('prog', 'prog.cpp', 'kernel.cu', dependencies: dependency('cuda', modules: ['cublas']))
+test('cudatest', exe)
diff --git a/test cases/cuda/12 cuda dependency (mixed)/prog.cpp b/test cases/cuda/12 cuda dependency (mixed)/prog.cpp
new file mode 100644
index 0000000..50bb156
--- /dev/null
+++ b/test cases/cuda/12 cuda dependency (mixed)/prog.cpp
@@ -0,0 +1,37 @@
+#include <cuda_runtime.h>
+#include <cublas_v2.h>
+#include <iostream>
+
+void do_cuda_stuff(void);
+
+int cuda_devices(void) {
+ int result = 0;
+ cudaGetDeviceCount(&result);
+ return result;
+}
+
+int main(void) {
+ int n = cuda_devices();
+ if (n == 0) {
+ std::cout << "No CUDA hardware found. Exiting.\n";
+ return 0;
+ }
+
+ std::cout << "Found " << n << " CUDA devices.\n";
+
+ do_cuda_stuff();
+
+ cublasHandle_t handle;
+ if (cublasCreate(&handle) != CUBLAS_STATUS_SUCCESS) {
+ std::cout << "cuBLAS initialization failed. Exiting.\n";
+ return -1;
+ }
+
+ std::cout << "Initialized cuBLAS\n";
+ if (cublasDestroy(handle) != CUBLAS_STATUS_SUCCESS) {
+ std::cout << "cuBLAS de-initialization failed. Exiting.\n";
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/test cases/cuda/13 cuda compiler setting/meson.build b/test cases/cuda/13 cuda compiler setting/meson.build
new file mode 100644
index 0000000..4f111d1
--- /dev/null
+++ b/test cases/cuda/13 cuda compiler setting/meson.build
@@ -0,0 +1,4 @@
+project('simple', 'cuda', version : '1.0.0')
+
+exe = executable('prog', 'prog.cu')
+test('cudatest', exe)
diff --git a/test cases/cuda/13 cuda compiler setting/nativefile.ini b/test cases/cuda/13 cuda compiler setting/nativefile.ini
new file mode 100644
index 0000000..fb52e0d
--- /dev/null
+++ b/test cases/cuda/13 cuda compiler setting/nativefile.ini
@@ -0,0 +1,3 @@
+[binaries]
+
+cuda = 'nvcc'
diff --git a/test cases/cuda/13 cuda compiler setting/prog.cu b/test cases/cuda/13 cuda compiler setting/prog.cu
new file mode 100644
index 0000000..06521b2
--- /dev/null
+++ b/test cases/cuda/13 cuda compiler setting/prog.cu
@@ -0,0 +1,29 @@
+#include <iostream>
+
+int main(void) {
+ 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;
+}
diff --git a/test cases/cuda/14 cuda has header symbol/meson.build b/test cases/cuda/14 cuda has header symbol/meson.build
new file mode 100644
index 0000000..a23892d
--- /dev/null
+++ b/test cases/cuda/14 cuda has header symbol/meson.build
@@ -0,0 +1,26 @@
+project('cuda has header symbol', 'cuda')
+
+cuda = meson.get_compiler('cuda')
+
+# C checks
+assert (cuda.has_header_symbol('stdio.h', 'int'), 'base types should always be available')
+assert (cuda.has_header_symbol('stdio.h', 'printf'), 'printf function not found')
+assert (cuda.has_header_symbol('stdio.h', 'FILE'), 'FILE structure not found')
+assert (cuda.has_header_symbol('limits.h', 'INT_MAX'), 'INT_MAX define not found')
+assert (not cuda.has_header_symbol('limits.h', 'guint64'), 'guint64 is not defined in limits.h')
+assert (not cuda.has_header_symbol('stdlib.h', 'FILE'), 'FILE structure is defined in stdio.h, not stdlib.h')
+assert (not cuda.has_header_symbol('stdlol.h', 'printf'), 'stdlol.h shouldn\'t exist')
+assert (not cuda.has_header_symbol('stdlol.h', 'int'), 'shouldn\'t be able to find "int" with invalid header')
+
+# C++ checks
+assert (cuda.has_header_symbol('iostream', 'std::iostream'), 'iostream not found in iostream.h')
+assert (cuda.has_header_symbol('vector', 'std::vector'), 'vector not found in vector.h')
+assert (not cuda.has_header_symbol('limits.h', 'std::iostream'), 'iostream should not be defined in limits.h')
+
+# CUDA checks
+assert (cuda.has_header_symbol('cuda.h', 'CUDA_VERSION'), 'CUDA_VERSION not found in cuda.h')
+assert (not cuda.has_header_symbol('cuda.h', 'cublasSaxpy'), 'cublasSaxpy is defined in cublas.h, not cuda.h')
+if cuda.version().version_compare('>=4.0')
+ assert (cuda.has_header_symbol('thrust/device_vector.h', 'thrust::device_vector'), 'thrust::device_vector not found')
+ assert (not cuda.has_header_symbol('thrust/fill.h', 'thrust::sort'), 'thrust::sort should not be defined in thrust/fill.h')
+endif
diff --git a/test cases/cuda/15 sanitizer/meson.build b/test cases/cuda/15 sanitizer/meson.build
new file mode 100644
index 0000000..367a4e2
--- /dev/null
+++ b/test cases/cuda/15 sanitizer/meson.build
@@ -0,0 +1,4 @@
+project('simple', 'cuda', version : '1.0.0',
+ default_options: ['b_sanitize=address,undefined'])
+
+libtests = shared_library('tests', 'prog.cu')
diff --git a/test cases/cuda/15 sanitizer/prog.cu b/test cases/cuda/15 sanitizer/prog.cu
new file mode 100644
index 0000000..5816809
--- /dev/null
+++ b/test cases/cuda/15 sanitizer/prog.cu
@@ -0,0 +1,29 @@
+#include <iostream>
+
+int run_tests(void) {
+ 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;
+}
diff --git a/test cases/cuda/16 multistd/lib.cu b/test cases/cuda/16 multistd/lib.cu
new file mode 100644
index 0000000..8b5d5a7
--- /dev/null
+++ b/test cases/cuda/16 multistd/lib.cu
@@ -0,0 +1,3 @@
+int do_cuda_stuff() {
+ return 0;
+}
diff --git a/test cases/cuda/16 multistd/main.cu b/test cases/cuda/16 multistd/main.cu
new file mode 100644
index 0000000..7b06570
--- /dev/null
+++ b/test cases/cuda/16 multistd/main.cu
@@ -0,0 +1,21 @@
+#include <cuda_runtime.h>
+#include <iostream>
+
+auto cuda_devices(void) {
+ int result = 0;
+ cudaGetDeviceCount(&result);
+ return result;
+}
+
+int do_cuda_stuff();
+
+int main(void) {
+ 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 do_cuda_stuff();
+}
diff --git a/test cases/cuda/16 multistd/meson.build b/test cases/cuda/16 multistd/meson.build
new file mode 100644
index 0000000..36709d8
--- /dev/null
+++ b/test cases/cuda/16 multistd/meson.build
@@ -0,0 +1,13 @@
+project('C++-CUDA multi-std', 'cpp', 'cuda',
+ version : '1.0.0',
+ default_options : ['cpp_std=c++17', 'cuda_std=c++14'])
+
+# Regression test: Passing override_options used to cause a crash.
+# See https://github.com/mesonbuild/meson/issues/9448.
+libcpp11 = static_library('testcpp11', 'lib.cu',
+ override_options: ['cpp_std=c++11']
+)
+
+exe = executable('prog', 'main.cu', link_with: libcpp11)
+# The runtimes leak memory, so ignore it.
+test('cudatest', exe, env: ['ASAN_OPTIONS=detect_leaks=0'])
diff --git a/test cases/cuda/2 split/lib.cu b/test cases/cuda/2 split/lib.cu
new file mode 100644
index 0000000..e891933
--- /dev/null
+++ b/test cases/cuda/2 split/lib.cu
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include <iostream>
+
+__global__ void kernel (void){
+}
+
+int do_cuda_stuff(void) {
+ kernel<<<1,1>>>();
+
+ printf("Hello, World!\n");
+ return 0;
+}
diff --git a/test cases/cuda/2 split/main.cpp b/test cases/cuda/2 split/main.cpp
new file mode 100644
index 0000000..ce79003
--- /dev/null
+++ b/test cases/cuda/2 split/main.cpp
@@ -0,0 +1,7 @@
+#include<iostream>
+
+int do_cuda_stuff(void);
+
+int main(void) {
+ return do_cuda_stuff();
+}
diff --git a/test cases/cuda/2 split/meson.build b/test cases/cuda/2 split/meson.build
new file mode 100644
index 0000000..2e2bec1
--- /dev/null
+++ b/test cases/cuda/2 split/meson.build
@@ -0,0 +1,6 @@
+project('simple', 'cuda', 'cpp')
+
+exe = executable('prog', 'main.cpp', 'lib.cu')
+test('cudatest', exe)
+
+subdir('static')
diff --git a/test cases/cuda/2 split/static/lib.cu b/test cases/cuda/2 split/static/lib.cu
new file mode 100644
index 0000000..757c9b5
--- /dev/null
+++ b/test cases/cuda/2 split/static/lib.cu
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include <iostream>
+
+__global__ void kernel (void){
+}
+
+int do_cuda_stuff() {
+ kernel<<<1,1>>>();
+
+ printf("Hello, World!\n");
+ return 0;
+}
diff --git a/test cases/cuda/2 split/static/libsta.cu b/test cases/cuda/2 split/static/libsta.cu
new file mode 100644
index 0000000..757c9b5
--- /dev/null
+++ b/test cases/cuda/2 split/static/libsta.cu
@@ -0,0 +1,12 @@
+#include <stdio.h>
+#include <iostream>
+
+__global__ void kernel (void){
+}
+
+int do_cuda_stuff() {
+ kernel<<<1,1>>>();
+
+ printf("Hello, World!\n");
+ return 0;
+}
diff --git a/test cases/cuda/2 split/static/main_static.cpp b/test cases/cuda/2 split/static/main_static.cpp
new file mode 100644
index 0000000..ce79003
--- /dev/null
+++ b/test cases/cuda/2 split/static/main_static.cpp
@@ -0,0 +1,7 @@
+#include<iostream>
+
+int do_cuda_stuff(void);
+
+int main(void) {
+ return do_cuda_stuff();
+}
diff --git a/test cases/cuda/2 split/static/meson.build b/test cases/cuda/2 split/static/meson.build
new file mode 100644
index 0000000..9078198
--- /dev/null
+++ b/test cases/cuda/2 split/static/meson.build
@@ -0,0 +1,4 @@
+l = static_library('clib', 'lib.cu')
+exe = executable('staexe', 'main_static.cpp',
+ link_with : l)
+test('static Cuda test', exe)
diff --git a/test cases/cuda/3 cudamodule/meson.build b/test cases/cuda/3 cudamodule/meson.build
new file mode 100644
index 0000000..5c3ed60
--- /dev/null
+++ b/test cases/cuda/3 cudamodule/meson.build
@@ -0,0 +1,69 @@
+project('cudamodule', 'cuda', version : '1.0.0')
+
+nvcc = meson.get_compiler('cuda')
+cuda = import('unstable-cuda')
+
+arch_flags = cuda.nvcc_arch_flags(nvcc.version(), 'Auto', detected: ['6.0'])
+arch_readable = cuda.nvcc_arch_readable(nvcc.version(), 'Auto', detected: ['6.0'])
+driver_version = cuda.min_driver_version(nvcc.version())
+
+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)
+
+
+#
+# Assert Series
+#
+
+# Sanity test.
+assert(' '.join(cuda.nvcc_arch_flags('11.1', '8.6')) ==
+ '-gencode arch=compute_86,code=sm_86')
+
+# CUDA Toolkit too old, flag filtered out.
+assert(' '.join(cuda.nvcc_arch_flags('11.0', '8.6')) ==
+ '')
+
+# Named architectures.
+assert(' '.join(cuda.nvcc_arch_flags('11.0', 'Ampere')) ==
+ '-gencode arch=compute_80,code=sm_80')
+
+# Splitting & deduplication.
+assert(' '.join(cuda.nvcc_arch_flags('11.0', 'Ampere;8.0,8.0')) ==
+ '-gencode arch=compute_80,code=sm_80')
+
+# Same, but list supplied as list.
+assert(' '.join(cuda.nvcc_arch_flags('11.0', ['Ampere', '8.0', '8.0'])) ==
+ '-gencode arch=compute_80,code=sm_80')
+
+# Same, but mode set to Auto with detected set to a string with a variety of separators.
+assert(' '.join(cuda.nvcc_arch_flags('11.0', 'Auto', detected: 'Ampere;8.0,8.0')) ==
+ '-gencode arch=compute_80,code=sm_80')
+
+# Same, but detected set to a list.
+assert(' '.join(cuda.nvcc_arch_flags('11.0', 'Auto', detected: ['Ampere', '8.0', '8.0'])) ==
+ '-gencode arch=compute_80,code=sm_80')
+
+# Ask for 8.6 binary with 8.0-level PTX.
+assert(' '.join(cuda.nvcc_arch_flags('11.1', '8.6(8.0)')) ==
+ '-gencode arch=compute_80,code=sm_86')
+
+# Same, but keep the 8.0 PTX.
+assert(' '.join(cuda.nvcc_arch_flags('11.1', '8.6(8.0)+PTX')) ==
+ '-gencode arch=compute_80,code=sm_86 -gencode arch=compute_80,code=compute_80')
+
+# Detected Ampere RTX 3090 on CUDA 10.2, saturate to 7.5+PTX
+assert(' '.join(cuda.nvcc_arch_flags('10.2', 'Auto', detected: ['8.0'])) ==
+ '-gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75')
+
+# Failed to auto-detect with CUDA 10.2, default to common GPUs (3.0;3.5;5.0;5.2;6.0;6.1;7.0;7.5+PTX)
+assert(' '.join(cuda.nvcc_arch_flags('10.2', 'Auto', detected: [])) ==
+ '-gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 '+
+ '-gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 '+
+ '-gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 '+
+ '-gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 '+
+ '-gencode arch=compute_75,code=compute_75')
diff --git a/test cases/cuda/3 cudamodule/prog.cu b/test cases/cuda/3 cudamodule/prog.cu
new file mode 100644
index 0000000..06521b2
--- /dev/null
+++ b/test cases/cuda/3 cudamodule/prog.cu
@@ -0,0 +1,29 @@
+#include <iostream>
+
+int main(void) {
+ 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;
+}
diff --git a/test cases/cuda/4 shared/main.cu b/test cases/cuda/4 shared/main.cu
new file mode 100644
index 0000000..1235914
--- /dev/null
+++ b/test cases/cuda/4 shared/main.cu
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <cuda_runtime.h>
+#include "shared/kernels.h"
+
+
+int main(void) {
+ int cuda_devices = 0;
+ cudaGetDeviceCount(&cuda_devices);
+ if(cuda_devices == 0) {
+ printf("No Cuda hardware found. Exiting.\n");
+ return 0;
+ }
+
+ if(run_tests() != 0){
+ printf("CUDA tests failed! Exiting.\n");
+ return 0;
+ }
+
+ return 0;
+}
diff --git a/test cases/cuda/4 shared/meson.build b/test cases/cuda/4 shared/meson.build
new file mode 100644
index 0000000..532aaeb
--- /dev/null
+++ b/test cases/cuda/4 shared/meson.build
@@ -0,0 +1,6 @@
+project('simple', 'cuda', version : '1.0.0')
+
+subdir('shared')
+
+exe = executable('prog', 'main.cu', dependencies: libkernels)
+test('cudatest', exe)
diff --git a/test cases/cuda/4 shared/shared/kernels.cu b/test cases/cuda/4 shared/shared/kernels.cu
new file mode 100644
index 0000000..5cda629
--- /dev/null
+++ b/test cases/cuda/4 shared/shared/kernels.cu
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <cuda_runtime.h>
+#include "kernels.h"
+
+
+TAG_HIDDEN __global__ void kernel (void){
+}
+
+TAG_PUBLIC int run_tests(void) {
+ kernel<<<1,1>>>();
+
+ return (int)cudaDeviceSynchronize();
+}
diff --git a/test cases/cuda/4 shared/shared/kernels.h b/test cases/cuda/4 shared/shared/kernels.h
new file mode 100644
index 0000000..dbcb99d
--- /dev/null
+++ b/test cases/cuda/4 shared/shared/kernels.h
@@ -0,0 +1,86 @@
+/* Include Guard */
+#ifndef SHARED_KERNELS_H
+#define SHARED_KERNELS_H
+
+/**
+ * Includes
+ */
+
+#include <cuda_runtime.h>
+
+
+/**
+ * Defines
+ */
+
+/**
+ * When building a library, it is a good idea to expose as few as possible
+ * internal symbols (functions, objects, data structures). Not only does it
+ * prevent users from relying on private portions of the library that are
+ * subject to change without any notice, but it can have performance
+ * advantages:
+ *
+ * - It can make shared libraries link faster at dynamic-load time.
+ * - It can make internal function calls faster by bypassing the PLT.
+ *
+ * Thus, the compilation should by default hide all symbols, while the API
+ * headers will explicitly mark public the few symbols the users are permitted
+ * to use with a PUBLIC tag. We also define a HIDDEN tag, since it may be
+ * required to explicitly tag certain C++ types as visible in order for
+ * exceptions to function correctly.
+ *
+ * Additional complexity comes from non-POSIX-compliant systems, which
+ * artificially impose a requirement on knowing whether we are building or
+ * using a DLL.
+ *
+ * The above commentary and below code is inspired from
+ * 'https://gcc.gnu.org/wiki/Visibility'
+ */
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+# define TAG_ATTRIBUTE_EXPORT __declspec(dllexport)
+# define TAG_ATTRIBUTE_IMPORT __declspec(dllimport)
+# define TAG_ATTRIBUTE_HIDDEN
+#elif __GNUC__ >= 4
+# define TAG_ATTRIBUTE_EXPORT __attribute__((visibility("default")))
+# define TAG_ATTRIBUTE_IMPORT __attribute__((visibility("default")))
+# define TAG_ATTRIBUTE_HIDDEN __attribute__((visibility("hidden")))
+#else
+# define TAG_ATTRIBUTE_EXPORT
+# define TAG_ATTRIBUTE_IMPORT
+# define TAG_ATTRIBUTE_HIDDEN
+#endif
+
+#if TAG_IS_SHARED
+# if TAG_IS_BUILDING
+# define TAG_PUBLIC TAG_ATTRIBUTE_EXPORT
+# else
+# define TAG_PUBLIC TAG_ATTRIBUTE_IMPORT
+# endif
+# define TAG_HIDDEN TAG_ATTRIBUTE_HIDDEN
+#else
+# define TAG_PUBLIC
+# define TAG_HIDDEN
+#endif
+#define TAG_STATIC static
+
+
+
+
+/* Extern "C" Guard */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+/* Function Prototypes */
+TAG_PUBLIC int run_tests(void);
+
+
+
+/* End Extern "C" and Include Guard */
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/test cases/cuda/4 shared/shared/meson.build b/test cases/cuda/4 shared/shared/meson.build
new file mode 100644
index 0000000..61cf1d3
--- /dev/null
+++ b/test cases/cuda/4 shared/shared/meson.build
@@ -0,0 +1,7 @@
+libkernels = shared_library('kernels', 'kernels.cu',
+ cuda_args: ['-DTAG_IS_SHARED=1', '-DTAG_IS_BUILDING=1'],
+ gnu_symbol_visibility: 'hidden',
+ soversion : 1,
+ version : '1.2.3')
+libkernels = declare_dependency(compile_args: ['-DTAG_IS_SHARED=1'],
+ link_with: libkernels)
diff --git a/test cases/cuda/5 threads/main.cu b/test cases/cuda/5 threads/main.cu
new file mode 100644
index 0000000..1235914
--- /dev/null
+++ b/test cases/cuda/5 threads/main.cu
@@ -0,0 +1,20 @@
+#include <stdio.h>
+#include <cuda_runtime.h>
+#include "shared/kernels.h"
+
+
+int main(void) {
+ int cuda_devices = 0;
+ cudaGetDeviceCount(&cuda_devices);
+ if(cuda_devices == 0) {
+ printf("No Cuda hardware found. Exiting.\n");
+ return 0;
+ }
+
+ if(run_tests() != 0){
+ printf("CUDA tests failed! Exiting.\n");
+ return 0;
+ }
+
+ return 0;
+}
diff --git a/test cases/cuda/5 threads/meson.build b/test cases/cuda/5 threads/meson.build
new file mode 100644
index 0000000..2a804a3
--- /dev/null
+++ b/test cases/cuda/5 threads/meson.build
@@ -0,0 +1,7 @@
+project('simple', 'cuda', version : '1.0.0')
+
+subdir('shared')
+
+thread_dep = dependency('threads')
+exe = executable('prog', 'main.cu', dependencies: [libkernels, thread_dep])
+test('cudatest', exe)
diff --git a/test cases/cuda/5 threads/shared/kernels.cu b/test cases/cuda/5 threads/shared/kernels.cu
new file mode 100644
index 0000000..5cda629
--- /dev/null
+++ b/test cases/cuda/5 threads/shared/kernels.cu
@@ -0,0 +1,13 @@
+#include <stdio.h>
+#include <cuda_runtime.h>
+#include "kernels.h"
+
+
+TAG_HIDDEN __global__ void kernel (void){
+}
+
+TAG_PUBLIC int run_tests(void) {
+ kernel<<<1,1>>>();
+
+ return (int)cudaDeviceSynchronize();
+}
diff --git a/test cases/cuda/5 threads/shared/kernels.h b/test cases/cuda/5 threads/shared/kernels.h
new file mode 100644
index 0000000..dbcb99d
--- /dev/null
+++ b/test cases/cuda/5 threads/shared/kernels.h
@@ -0,0 +1,86 @@
+/* Include Guard */
+#ifndef SHARED_KERNELS_H
+#define SHARED_KERNELS_H
+
+/**
+ * Includes
+ */
+
+#include <cuda_runtime.h>
+
+
+/**
+ * Defines
+ */
+
+/**
+ * When building a library, it is a good idea to expose as few as possible
+ * internal symbols (functions, objects, data structures). Not only does it
+ * prevent users from relying on private portions of the library that are
+ * subject to change without any notice, but it can have performance
+ * advantages:
+ *
+ * - It can make shared libraries link faster at dynamic-load time.
+ * - It can make internal function calls faster by bypassing the PLT.
+ *
+ * Thus, the compilation should by default hide all symbols, while the API
+ * headers will explicitly mark public the few symbols the users are permitted
+ * to use with a PUBLIC tag. We also define a HIDDEN tag, since it may be
+ * required to explicitly tag certain C++ types as visible in order for
+ * exceptions to function correctly.
+ *
+ * Additional complexity comes from non-POSIX-compliant systems, which
+ * artificially impose a requirement on knowing whether we are building or
+ * using a DLL.
+ *
+ * The above commentary and below code is inspired from
+ * 'https://gcc.gnu.org/wiki/Visibility'
+ */
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+# define TAG_ATTRIBUTE_EXPORT __declspec(dllexport)
+# define TAG_ATTRIBUTE_IMPORT __declspec(dllimport)
+# define TAG_ATTRIBUTE_HIDDEN
+#elif __GNUC__ >= 4
+# define TAG_ATTRIBUTE_EXPORT __attribute__((visibility("default")))
+# define TAG_ATTRIBUTE_IMPORT __attribute__((visibility("default")))
+# define TAG_ATTRIBUTE_HIDDEN __attribute__((visibility("hidden")))
+#else
+# define TAG_ATTRIBUTE_EXPORT
+# define TAG_ATTRIBUTE_IMPORT
+# define TAG_ATTRIBUTE_HIDDEN
+#endif
+
+#if TAG_IS_SHARED
+# if TAG_IS_BUILDING
+# define TAG_PUBLIC TAG_ATTRIBUTE_EXPORT
+# else
+# define TAG_PUBLIC TAG_ATTRIBUTE_IMPORT
+# endif
+# define TAG_HIDDEN TAG_ATTRIBUTE_HIDDEN
+#else
+# define TAG_PUBLIC
+# define TAG_HIDDEN
+#endif
+#define TAG_STATIC static
+
+
+
+
+/* Extern "C" Guard */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+/* Function Prototypes */
+TAG_PUBLIC int run_tests(void);
+
+
+
+/* End Extern "C" and Include Guard */
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/test cases/cuda/5 threads/shared/meson.build b/test cases/cuda/5 threads/shared/meson.build
new file mode 100644
index 0000000..5987916
--- /dev/null
+++ b/test cases/cuda/5 threads/shared/meson.build
@@ -0,0 +1,5 @@
+libkernels = shared_library('kernels', 'kernels.cu',
+ cuda_args: ['-DTAG_IS_SHARED=1', '-DTAG_IS_BUILDING=1'],
+ gnu_symbol_visibility: 'hidden')
+libkernels = declare_dependency(compile_args: ['-DTAG_IS_SHARED=1'],
+ link_with: libkernels)
diff --git a/test cases/cuda/6 std/main.cu b/test cases/cuda/6 std/main.cu
new file mode 100644
index 0000000..a2ffba4
--- /dev/null
+++ b/test cases/cuda/6 std/main.cu
@@ -0,0 +1,20 @@
+#include <cuda_runtime.h>
+#include <iostream>
+
+auto cuda_devices(void) {
+ int result = 0;
+ cudaGetDeviceCount(&result);
+ return result;
+}
+
+
+int main(void) {
+ 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;
+}
diff --git a/test cases/cuda/6 std/meson.build b/test cases/cuda/6 std/meson.build
new file mode 100644
index 0000000..69a6868
--- /dev/null
+++ b/test cases/cuda/6 std/meson.build
@@ -0,0 +1,4 @@
+project('C++ std', 'cuda', version : '1.0.0', default_options : ['cuda_std=c++14'])
+
+exe = executable('prog', 'main.cu')
+test('cudatest', exe)
diff --git a/test cases/cuda/7 static vs runtime/main.cu b/test cases/cuda/7 static vs runtime/main.cu
new file mode 100644
index 0000000..bd1dbc4
--- /dev/null
+++ b/test cases/cuda/7 static vs runtime/main.cu
@@ -0,0 +1,20 @@
+#include <cuda_runtime.h>
+#include <iostream>
+
+int cuda_devices(void) {
+ int result = 0;
+ cudaGetDeviceCount(&result);
+ return result;
+}
+
+
+int main(void) {
+ 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;
+}
diff --git a/test cases/cuda/7 static vs runtime/meson.build b/test cases/cuda/7 static vs runtime/meson.build
new file mode 100644
index 0000000..ab13304
--- /dev/null
+++ b/test cases/cuda/7 static vs runtime/meson.build
@@ -0,0 +1,4 @@
+project('static msvc runtime', 'cuda', version : '1.0.0', default_options : ['b_vscrt=mtd'])
+
+exe = executable('prog', 'main.cu')
+test('cudatest', exe)
diff --git a/test cases/cuda/8 release/main.cu b/test cases/cuda/8 release/main.cu
new file mode 100644
index 0000000..2a98874
--- /dev/null
+++ b/test cases/cuda/8 release/main.cu
@@ -0,0 +1,24 @@
+#include <cuda_runtime.h>
+#include <iostream>
+
+#ifndef NDEBUG
+#error "NDEBUG not defined, this is a Meson bug"
+#endif
+
+int cuda_devices(void) {
+ int result = 0;
+ cudaGetDeviceCount(&result);
+ return result;
+}
+
+
+int main(void) {
+ 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;
+}
diff --git a/test cases/cuda/8 release/meson.build b/test cases/cuda/8 release/meson.build
new file mode 100644
index 0000000..c5cad32
--- /dev/null
+++ b/test cases/cuda/8 release/meson.build
@@ -0,0 +1,10 @@
+project('release', 'cpp', 'cuda', version : '1.0.0', default_options : ['buildtype=release', 'b_ndebug=if-release'])
+
+# We don't actually need boost, but it serves as a common dependency
+# that has the potential to add "-isystem/usr/include" to the compile
+# line. By making it optional, we test that system search paths get
+# removed without unnecessarily failing the test if boost is absent.
+boost_dep = dependency('boost', include_type : 'system', required : false)
+
+exe = executable('prog', 'main.cu', dependencies : boost_dep)
+test('cudatest', exe)
diff --git a/test cases/cuda/9 optimize for space/main.cu b/test cases/cuda/9 optimize for space/main.cu
new file mode 100644
index 0000000..bd1dbc4
--- /dev/null
+++ b/test cases/cuda/9 optimize for space/main.cu
@@ -0,0 +1,20 @@
+#include <cuda_runtime.h>
+#include <iostream>
+
+int cuda_devices(void) {
+ int result = 0;
+ cudaGetDeviceCount(&result);
+ return result;
+}
+
+
+int main(void) {
+ 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;
+}
diff --git a/test cases/cuda/9 optimize for space/meson.build b/test cases/cuda/9 optimize for space/meson.build
new file mode 100644
index 0000000..cd6ac05
--- /dev/null
+++ b/test cases/cuda/9 optimize for space/meson.build
@@ -0,0 +1,4 @@
+project('optimize for space', 'cuda', version : '1.0.0', default_options : ['optimization=s'])
+
+exe = executable('prog', 'main.cu')
+test('cudatest', exe)