Skip to content

Commit b5aa33d

Browse files
authored
[SYCL] Add macro to disable range rounding for FPGA compilations (#3428)
Set macro SYCL_DISABLE_PARALLEL_FOR_RANGE_ROUNDING for all FPGA compilations to avoid emitting two versions of the kernel - one by default and another for parallel_for. Signed-off-by: Soumi Manna [email protected]
1 parent 59adeb1 commit b5aa33d

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,12 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
11291129
Builder.defineMacro("__SYCL_DEVICE_ONLY__", "1");
11301130
Builder.defineMacro("SYCL_EXTERNAL", "__attribute__((sycl_device))");
11311131

1132+
// Enable __SYCL_DISABLE_PARALLEL_FOR_RANGE_ROUNDING__ macro for
1133+
// all FPGA compilations.
1134+
if (TI.getTriple().getSubArch() == llvm::Triple::SPIRSubArch_fpga) {
1135+
Builder.defineMacro("__SYCL_DISABLE_PARALLEL_FOR_RANGE_ROUNDING__", "1");
1136+
}
1137+
11321138
if (TI.getTriple().isNVPTX()) {
11331139
Builder.defineMacro("__SYCL_NVPTX__", "1");
11341140
}

clang/test/Preprocessor/predefined-macros.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,16 @@
214214
// CHECK-HIP-DEV: #define __HIPCC__ 1
215215
// CHECK-HIP-DEV: #define __HIP_DEVICE_COMPILE__ 1
216216
// CHECK-HIP-DEV: #define __HIP__ 1
217+
218+
// RUN: %clang_cc1 %s -E -dM -fsycl-is-device \
219+
// RUN: -triple spir64_fpga-unknown-unknown-sycldevice -o - \
220+
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-RANGE
221+
// CHECK-RANGE: #define __SYCL_DISABLE_PARALLEL_FOR_RANGE_ROUNDING__ 1
222+
223+
// RUN: %clang_cc1 %s -E -dM -fsycl-is-device -o - \
224+
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-NO-RANGE
225+
226+
// RUN: %clang_cc1 %s -E -dM -o - \
227+
// RUN: | FileCheck -match-full-lines %s --check-prefix=CHECK-NO-RANGE
228+
229+
// CHECK-NO-RANGE-NOT: #define __SYCL_DISABLE_PARALLEL_FOR_RANGE_ROUNDING__ 1

0 commit comments

Comments
 (0)