From 1f12cae970f3b20cfa5275cf2337ce9ecf76917f Mon Sep 17 00:00:00 2001 From: Georgi Mirazchiyski Date: Wed, 2 Oct 2024 21:14:38 +0100 Subject: [PATCH] [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: https://github.com/intel/llvm/pull/15441#discussion_r1775982907 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. --- clang/test/Driver/sycl-cuda-arch-macro.cpp | 11 +++++++++++ clang/test/Preprocessor/sycl-macro.cpp | 4 ---- 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 clang/test/Driver/sycl-cuda-arch-macro.cpp diff --git a/clang/test/Driver/sycl-cuda-arch-macro.cpp b/clang/test/Driver/sycl-cuda-arch-macro.cpp new file mode 100644 index 0000000000000..99c96d864e2ac --- /dev/null +++ b/clang/test/Driver/sycl-cuda-arch-macro.cpp @@ -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" diff --git a/clang/test/Preprocessor/sycl-macro.cpp b/clang/test/Preprocessor/sycl-macro.cpp index 934c20a776915..b3ac51abc69bb 100644 --- a/clang/test/Preprocessor/sycl-macro.cpp +++ b/clang/test/Preprocessor/sycl-macro.cpp @@ -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 @@ -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