Skip to content

Commit

Permalink
[SYCL] Move driver related __CUDA_ARCH__ test to Driver folder from…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
GeorgeWeb authored Oct 2, 2024
1 parent 48a95e4 commit 1f12cae
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 11 additions & 0 deletions clang/test/Driver/sycl-cuda-arch-macro.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Verify the __CUDA_ARCH__ macro has not been defined when offloading SYCL on NVPTX
// RUN: %clangxx -E -dM -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --offload-arch=sm_80 -nocudalib -fno-sycl-libspirv %s 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-CUDA-ARCH-MACRO %s
// CHECK-CUDA-ARCH-MACRO-NOT: #define __CUDA_ARCH__ {{[0-9]+}}

// Verify that '-fcuda-is-device' is not supplied when offloading SYCL on NVPTX
// RUN: %clangxx -### -fsycl -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --offload-arch=sm_80 -nocudalib -fno-sycl-libspirv %s 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-CUDA-IS-DEVICE %s
// CHECK-CUDA-IS-DEVICE: clang{{.*}} "-cc1" "-triple" "nvptx64-nvidia-cuda"
// CHECK-CUDA-IS-DEVICE-NOT: "-fcuda-is-device"
// CHECK-CUDA-IS-DEVICE-SAME: "-fsycl-is-device"
4 changes: 0 additions & 4 deletions clang/test/Preprocessor/sycl-macro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
// RUN: --check-prefix=CHECK-NO-SYCL_FIT_IN_INT %s
// RUN: %clang_cc1 %s -triple nvptx64-nvidia-cuda -target-cpu sm_80 -fsycl-is-device -E -dM | FileCheck \
// RUN: --check-prefix=CHECK-CUDA %s -DARCH_CODE=800
// RUN: %clangxx %s -fsycl -nocudalib -fsycl-targets=nvptx64-nvidia-cuda -Xsycl-target-backend --offload-arch=sm_80 -E -dM | FileCheck \
// RUN: --check-prefix=CHECK-CUDA-SYCL-DRIVER %s
// RUN: %clang_cc1 %s -triple amdgcn-amd-amdhsa -target-cpu gfx906 -fsycl-is-device -E -dM | FileCheck --check-prefix=CHECK-HIP %s

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

// CHECK-CUDA-SYCL-DRIVER-NOT: #define __CUDA_ARCH__ {{[0-9]+}}

// CHECK-HIP:#define __CUDA_ARCH__ 0

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

0 comments on commit 1f12cae

Please sign in to comment.