Skip to content

Commit 1f12cae

Browse files
authored
[SYCL] Move driver related __CUDA_ARCH__ test to Driver folder from Preprocessor (#15521)
This PR moves the driver invocation test that checks `__CUDA_ARCH__` does not get defined and ensures that it doesn't require the `libspirv-nvptx64-nvidia-cuda` bitcode files by passing `-fno-sycl-libspirv` to the `%clangxx` command. Link to the comment in related PR that reported this issue: #15441 (comment) Additionally, an extra test is added to check that the `-fcuda-is-device` option is not supplied in the CC1 invocation targeting `nvptx64-nvidia-cuda`, which enables `LangOptions.CudaIsDevice` and was the cause of defining the `__CUDA_ARCH__` macro.
1 parent 48a95e4 commit 1f12cae

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Verify the __CUDA_ARCH__ macro has not been defined when offloading SYCL on NVPTX
2+
// RUN: %clangxx -E -dM -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --offload-arch=sm_80 -nocudalib -fno-sycl-libspirv %s 2>&1 \
3+
// RUN: | FileCheck --check-prefix=CHECK-CUDA-ARCH-MACRO %s
4+
// CHECK-CUDA-ARCH-MACRO-NOT: #define __CUDA_ARCH__ {{[0-9]+}}
5+
6+
// Verify that '-fcuda-is-device' is not supplied when offloading SYCL on NVPTX
7+
// RUN: %clangxx -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --offload-arch=sm_80 -nocudalib -fno-sycl-libspirv %s 2>&1 \
8+
// RUN: | FileCheck --check-prefix=CHECK-CUDA-IS-DEVICE %s
9+
// CHECK-CUDA-IS-DEVICE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
10+
// CHECK-CUDA-IS-DEVICE-NOT: "-fcuda-is-device"
11+
// CHECK-CUDA-IS-DEVICE-SAME: "-fsycl-is-device"

clang/test/Preprocessor/sycl-macro.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
// RUN: --check-prefix=CHECK-NO-SYCL_FIT_IN_INT %s
99
// RUN: %clang_cc1 %s -triple nvptx64-nvidia-cuda -target-cpu sm_80 -fsycl-is-device -E -dM | FileCheck \
1010
// RUN: --check-prefix=CHECK-CUDA %s -DARCH_CODE=800
11-
// RUN: %clangxx %s -fsycl -nocudalib -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --offload-arch=sm_80 -E -dM | FileCheck \
12-
// RUN: --check-prefix=CHECK-CUDA-SYCL-DRIVER %s
1311
// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa -target-cpu gfx906 -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-HIP %s
1412

1513
// RUN: %clang_cc1 %s -triple nvptx64-nvidia-cuda -target-cpu sm_90a -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-CUDA-FEATURE %s
@@ -38,8 +36,6 @@
3836
// CHECK-CUDA:#define __SYCL_CUDA_ARCH__ [[ARCH_CODE]]
3937
// CHECK-CUDA-NOT:#define __CUDA_ARCH__ {{[0-9]+}}
4038

41-
// CHECK-CUDA-SYCL-DRIVER-NOT: #define __CUDA_ARCH__ {{[0-9]+}}
42-
4339
// CHECK-HIP:#define __CUDA_ARCH__ 0
4440

4541
// CHECK-CUDA-FEATURE:#define __CUDA_ARCH_FEAT_SM90_ALL 1

0 commit comments

Comments
 (0)