xref: /llvm-project/clang/test/Preprocessor/cuda-preprocess.cu (revision 63fbc771218f6ec6700c607ed257a536bb016e12)
1 // Tests CUDA compilation with -E.
2 
3 // REQUIRES: x86-registered-target
4 // REQUIRES: nvptx-registered-target
5 
6 #ifndef __CUDA_ARCH__
7 #define PREPROCESSED_AWAY
8 clang_unittest_no_arch PREPROCESSED_AWAY
9 #else
10 clang_unittest_cuda_arch __CUDA_ARCH__
11 #endif
12 
13 // CHECK-NOT: PREPROCESSED_AWAY
14 
15 // RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 -nocudainc -nocudalib %s 2>&1 \
16 // RUN:   | FileCheck -check-prefix NOARCH %s
17 // RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 --cuda-host-only -nocudainc %s 2>&1 \
18 // RUN:   | FileCheck -check-prefix NOARCH %s
19 // NOARCH: clang_unittest_no_arch
20 
21 // RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 --cuda-device-only -nocudainc -nocudalib %s 2>&1 \
22 // RUN:   | FileCheck -check-prefix SM20 %s
23 // SM20: clang_unittest_cuda_arch 200
24 
25 // RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_30 --cuda-device-only -nocudainc -nocudalib %s 2>&1 \
26 // RUN:   | FileCheck -check-prefix SM30 %s
27 // SM30: clang_unittest_cuda_arch 300
28 
29 // RUN: %clang -E -target x86_64-linux-gnu --cuda-gpu-arch=sm_20 --cuda-gpu-arch=sm_30 \
30 // RUN:   --cuda-device-only -nocudainc -nocudalib %s 2>&1 \
31 // RUN:   | FileCheck -check-prefix SM20 -check-prefix SM30 %s
32