Skip to content

Commit 0bbb68e

Browse files
author
Artem Gindinson
authored
[SYCL] Enable native FP atomics by default (#3869)
Since Intel GPU and CPU support the target, pass the required macro by default during device FE compilation for SPIR non-FPGA targets. This alleviates the users of the native FP atomic functionality from passing the macro explicitly. Signed-off-by: Artem Gindinson <artem.gindinson@intel.com>
1 parent e3c1096 commit 0bbb68e

File tree

6 files changed

+32
-15
lines changed

6 files changed

+32
-15
lines changed

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,9 +1179,13 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
11791179
Builder.defineMacro("__SYCL_DEVICE_ONLY__", "1");
11801180
Builder.defineMacro("SYCL_EXTERNAL", "__attribute__((sycl_device))");
11811181

1182-
if (TI.getTriple().isNVPTX()) {
1183-
Builder.defineMacro("__SYCL_NVPTX__", "1");
1184-
}
1182+
const llvm::Triple &DeviceTriple = TI.getTriple();
1183+
if (DeviceTriple.isNVPTX())
1184+
Builder.defineMacro("__SYCL_NVPTX__", "1");
1185+
const llvm::Triple::SubArchType DeviceSubArch = DeviceTriple.getSubArch();
1186+
if (DeviceTriple.isSPIR() &&
1187+
DeviceSubArch != llvm::Triple::SPIRSubArch_fpga)
1188+
Builder.defineMacro("SYCL_USE_NATIVE_FP_ATOMICS");
11851189
}
11861190
if (LangOpts.SYCLUnnamedLambda)
11871191
Builder.defineMacro("__SYCL_UNNAMED_LAMBDA__", "1");
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64-unknown-unknown-sycldevice -E -dM \
2+
// RUN: | FileCheck --check-prefix=CHECK-SYCL-FP-ATOMICS %s
3+
// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64_gen-unknown-unknown-sycldevice -E -dM \
4+
// RUN: | FileCheck --check-prefix=CHECK-SYCL-FP-ATOMICS %s
5+
// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64_x86_64-unknown-unknown-sycldevice -E -dM \
6+
// RUN: | FileCheck --check-prefix=CHECK-SYCL-FP-ATOMICS %s
7+
// RUN: %clang_cc1 %s -fsycl-is-device -triple spir64_fpga-unknown-unknown-sycldevice -E -dM \
8+
// RUN: | FileCheck --check-prefix=CHECK-SYCL-FP-ATOMICS-NEG %s
9+
// RUN: %clang_cc1 %s -fsycl-is-device -triple nvptx64-nvidia-nvcl-sycldevice -E -dM \
10+
// RUN: | FileCheck --check-prefix=CHECK-SYCL-FP-ATOMICS-NEG %s
11+
12+
// CHECK-SYCL-FP-ATOMICS: #define SYCL_USE_NATIVE_FP_ATOMICS
13+
// CHECK-SYCL-FP-ATOMICS-NEG-NOT: #define SYCL_USE_NATIVE_FP_ATOMICS

sycl/test/atomic_ref/add.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -DSYCL_USE_NATIVE_FP_ATOMICS \
2-
// RUN: -fsycl-device-only -S %s -o - | FileCheck %s --check-prefix=CHECK-LLVM
31
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-device-only -S %s -o - \
4-
// RUN: | FileCheck %s --check-prefix=CHECK-LLVM-EMU
2+
// RUN: | FileCheck %s --check-prefix=CHECK-LLVM
3+
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -USYCL_USE_NATIVE_FP_ATOMICS \
4+
// RUN: -fsycl-device-only -S %s -o - | FileCheck %s --check-prefix=CHECK-LLVM-EMU
55
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-targets=%sycl_triple %s -o %t.out
66
// RUN: %RUN_ON_HOST %t.out
77

sycl/test/atomic_ref/max.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -DSYCL_USE_NATIVE_FP_ATOMICS \
2-
// RUN: -fsycl-device-only -S %s -o - | FileCheck %s --check-prefix=CHECK-LLVM
31
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-device-only -S %s -o - \
4-
// RUN: | FileCheck %s --check-prefix=CHECK-LLVM-EMU
2+
// RUN: | FileCheck %s --check-prefix=CHECK-LLVM
3+
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -USYCL_USE_NATIVE_FP_ATOMICS \
4+
// RUN: -fsycl-device-only -S %s -o - | FileCheck %s --check-prefix=CHECK-LLVM-EMU
55
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-targets=%sycl_triple %s -o %t.out
66
// RUN: %RUN_ON_HOST %t.out
77

sycl/test/atomic_ref/min.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -DSYCL_USE_NATIVE_FP_ATOMICS \
2-
// RUN: -fsycl-device-only -S %s -o - | FileCheck %s --check-prefix=CHECK-LLVM
31
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-device-only -S %s -o - \
4-
// RUN: | FileCheck %s --check-prefix=CHECK-LLVM-EMU
2+
// RUN: | FileCheck %s --check-prefix=CHECK-LLVM
3+
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -USYCL_USE_NATIVE_FP_ATOMICS \
4+
// RUN: -fsycl-device-only -S %s -o - | FileCheck %s --check-prefix=CHECK-LLVM-EMU
55
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-targets=%sycl_triple %s -o %t.out
66
// RUN: %RUN_ON_HOST %t.out
77

sycl/test/atomic_ref/sub.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -DSYCL_USE_NATIVE_FP_ATOMICS \
2-
// RUN: -fsycl-device-only -S %s -o - | FileCheck %s --check-prefix=CHECK-LLVM
31
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-device-only -S %s -o - \
4-
// RUN: | FileCheck %s --check-prefix=CHECK-LLVM-EMU
2+
// RUN: | FileCheck %s --check-prefix=CHECK-LLVM
3+
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -USYCL_USE_NATIVE_FP_ATOMICS \
4+
// RUN: -fsycl-device-only -S %s -o - | FileCheck %s --check-prefix=CHECK-LLVM-EMU
55
// RUN: %clangxx -fsycl -fsycl-unnamed-lambda -fsycl-targets=%sycl_triple %s -o %t.out
66
// RUN: %RUN_ON_HOST %t.out
77

0 commit comments

Comments
 (0)