Debian Codegraph @

test cases/cuda/3 cudamodule/meson.build

raw
1 project('cudamodule', 'cuda', version : '1.0.0')
2
3 nvcc = meson.get_compiler('cuda')
4 cuda = import('unstable-cuda')
5
6 arch_flags = cuda.nvcc_arch_flags(nvcc.version(), 'Auto', detected: ['6.0'])
7 arch_readable = cuda.nvcc_arch_readable(nvcc.version(), 'Auto', detected: ['6.0'])
8 driver_version = cuda.min_driver_version(nvcc.version())
9
10 message('NVCC version: ' + nvcc.version())
11 message('NVCC flags: ' + ' '.join(arch_flags))
12 message('NVCC readable: ' + ' '.join(arch_readable))
13 message('Driver version: >=' + driver_version)
14
15 exe = executable('prog', 'prog.cu', cuda_args: arch_flags)
16 test('cudatest', exe)
17
18
19 #
20 # Assert Series
21 #
22
23 # Sanity test.
24 assert(' '.join(cuda.nvcc_arch_flags('11.1', '8.6')) ==
25 '-gencode arch=compute_86,code=sm_86')
26
27 # CUDA Toolkit too old, flag filtered out.
28 assert(' '.join(cuda.nvcc_arch_flags('11.0', '8.6')) ==
29 '')
30
31 # Named architectures.
32 assert(' '.join(cuda.nvcc_arch_flags('11.0', 'Ampere')) ==
33 '-gencode arch=compute_80,code=sm_80')
34
35 # Splitting & deduplication.
36 assert(' '.join(cuda.nvcc_arch_flags('11.0', 'Ampere;8.0,8.0')) ==
37 '-gencode arch=compute_80,code=sm_80')
38
39 # Same, but list supplied as list.
40 assert(' '.join(cuda.nvcc_arch_flags('11.0', ['Ampere', '8.0', '8.0'])) ==
41 '-gencode arch=compute_80,code=sm_80')
42
43 # Same, but mode set to Auto with detected set to a string with a variety of separators.
44 assert(' '.join(cuda.nvcc_arch_flags('11.0', 'Auto', detected: 'Ampere;8.0,8.0')) ==
45 '-gencode arch=compute_80,code=sm_80')
46
47 # Same, but detected set to a list.
48 assert(' '.join(cuda.nvcc_arch_flags('11.0', 'Auto', detected: ['Ampere', '8.0', '8.0'])) ==
49 '-gencode arch=compute_80,code=sm_80')
50
51 # Ask for 8.6 binary with 8.0-level PTX.
52 assert(' '.join(cuda.nvcc_arch_flags('11.1', '8.6(8.0)')) ==
53 '-gencode arch=compute_80,code=sm_86')
54
55 # Same, but keep the 8.0 PTX.
56 assert(' '.join(cuda.nvcc_arch_flags('11.1', '8.6(8.0)+PTX')) ==
57 '-gencode arch=compute_80,code=sm_86 -gencode arch=compute_80,code=compute_80')
58
59 # Detected Ampere RTX 3090 on CUDA 10.2, saturate to 7.5+PTX
60 assert(' '.join(cuda.nvcc_arch_flags('10.2', 'Auto', detected: ['8.0'])) ==
61 '-gencode arch=compute_75,code=sm_75 -gencode arch=compute_75,code=compute_75')
62
63 # 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)
64 assert(' '.join(cuda.nvcc_arch_flags('10.2', 'Auto', detected: [])) ==
65 '-gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 '+
66 '-gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 '+
67 '-gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 '+
68 '-gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 '+
69 '-gencode arch=compute_75,code=compute_75')