Skip to content

[SYCL] Remove the __SYCL_NVPTX__ macro #3977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions clang/lib/Frontend/InitPreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1180,8 +1180,6 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
Builder.defineMacro("SYCL_EXTERNAL", "__attribute__((sycl_device))");

const llvm::Triple &DeviceTriple = TI.getTriple();
if (DeviceTriple.isNVPTX())
Builder.defineMacro("__SYCL_NVPTX__", "1");
const llvm::Triple::SubArchType DeviceSubArch = DeviceTriple.getSubArch();
if (DeviceTriple.isSPIR() &&
DeviceSubArch != llvm::Triple::SPIRSubArch_fpga)
Expand Down
14 changes: 13 additions & 1 deletion clang/test/Preprocessor/sycl-macro-target-specific.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
// RUN: %clang_cc1 %s -fsycl-is-device -triple nvptx64-nvidia-nvcl-sycldevice -E -dM \
// RUN: | FileCheck --check-prefix=CHECK-NVPTX %s
// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -E -dM \
// RUN: | FileCheck --check-prefix=CHECK-NVPTX-NEG %s
// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64_gen-unknown-unknown-sycldevice -E -dM \
// RUN: | FileCheck --check-prefix=CHECK-NVPTX-NEG %s
// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64_x86_64-unknown-unknown-sycldevice -E -dM \
// RUN: | FileCheck --check-prefix=CHECK-NVPTX-NEG %s
// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64_fpga-unknown-unknown-sycldevice -E -dM \
// RUN: | FileCheck --check-prefix=CHECK-NVPTX-NEG %s
// CHECK-NVPTX: #define __NVPTX__
// CHECK-NVPTX-NEG-NOT: #define __NVPTX__

// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -E -dM \
// RUN: | FileCheck --check-prefix=CHECK-SYCL-FP-ATOMICS %s
// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64_gen-unknown-unknown-sycldevice -E -dM \
Expand All @@ -8,6 +21,5 @@
// RUN: | FileCheck --check-prefix=CHECK-SYCL-FP-ATOMICS-NEG %s
// RUN: %clang_cc1 %s -fsycl-is-device -triple nvptx64-nvidia-nvcl-sycldevice -E -dM \
// RUN: | FileCheck --check-prefix=CHECK-SYCL-FP-ATOMICS-NEG %s

// CHECK-SYCL-FP-ATOMICS: #define SYCL_USE_NATIVE_FP_ATOMICS
// CHECK-SYCL-FP-ATOMICS-NEG-NOT: #define SYCL_USE_NATIVE_FP_ATOMICS
10 changes: 5 additions & 5 deletions sycl/doc/CompilerAndRuntimeDesign.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,11 @@ is then passed to the offload wrapper tool.
##### Checking if the compiler is targeting NVPTX

When the SYCL compiler is in device mode and targeting the NVPTX backend,
compiler defines the macro `__SYCL_NVPTX__`.
This macro can safely be used to enable NVPTX specific code path in SYCL
kernels.
the compiler defines `__SYCL_DEVICE_ONLY__` and `__NVPTX__` macros. This
macro combination can safely be used to enable NVPTX specific code
path in SYCL kernels.

*Note: this macro is defined only during the device compilation phase.*
*Note: these macros are defined only during the device compilation phase.*

##### NVPTX Builtins

Expand All @@ -567,7 +567,7 @@ Example:

```cpp
double my_min(double x, double y) {
#ifdef __SYCL_NVPTX__
#if defined(__NVPTX__) && defined(__SYCL_DEVICE_ONLY__)
// Only available if in device mode and
// while compiling for the NVPTX target.
return __nvvm_fmin_d(x, y);
Expand Down
6 changes: 3 additions & 3 deletions sycl/include/CL/__spirv/spirv_vars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#define __SPIRV_VAR_QUALIFIERS extern "C" const

#if defined(__SYCL_NVPTX__) || defined(__AMDCGN__)
#if defined(__NVPTX__) || defined(__AMDGCN__)

SYCL_EXTERNAL size_t __spirv_GlobalInvocationId_x();
SYCL_EXTERNAL size_t __spirv_GlobalInvocationId_y();
Expand Down Expand Up @@ -51,7 +51,7 @@ SYCL_EXTERNAL uint32_t __spirv_NumSubgroups();
SYCL_EXTERNAL uint32_t __spirv_SubgroupId();
SYCL_EXTERNAL uint32_t __spirv_SubgroupLocalInvocationId();

#else // __SYCL_NVPTX__ || defined(__AMDCGN__)
#else // defined(__NVPTX__) || defined(__AMDGCN__)

typedef size_t size_t_vec __attribute__((ext_vector_type(3)));
__SPIRV_VAR_QUALIFIERS size_t_vec __spirv_BuiltInGlobalSize;
Expand Down Expand Up @@ -154,7 +154,7 @@ SYCL_EXTERNAL inline uint32_t __spirv_SubgroupLocalInvocationId() {
return __spirv_BuiltInSubgroupLocalInvocationId;
}

#endif // __SYCL_NVPTX__ || defined(__AMDCGN__)
#endif // defined(__NVPTX__) || defined(__AMDGCN__)

#undef __SPIRV_VAR_QUALIFIERS

Expand Down