Skip to content

Commit 551230d

Browse files
committed
Merge remote-tracking branch 'upstream/sycl' into stmt-attr-cleanups
2 parents 51cb35e + 697469f commit 551230d

File tree

6 files changed

+48
-14
lines changed

6 files changed

+48
-14
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

sycl/include/CL/__spirv/spirv_ops.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,12 +322,13 @@ extern SYCL_EXTERNAL ap_int<Wout> __spirv_ArbitraryFloatCastINTEL(
322322

323323
template <int WA, int Wout>
324324
extern SYCL_EXTERNAL ap_int<Wout> __spirv_ArbitraryFloatCastFromIntINTEL(
325-
ap_int<WA> A, int32_t Mout, int32_t EnableSubnormals = 0,
326-
int32_t RoundingMode = 0, int32_t RoundingAccuracy = 0) noexcept;
325+
ap_int<WA> A, int32_t Mout, bool FromSign = false,
326+
int32_t EnableSubnormals = 0, int32_t RoundingMode = 0,
327+
int32_t RoundingAccuracy = 0) noexcept;
327328

328329
template <int WA, int Wout>
329330
extern SYCL_EXTERNAL ap_int<Wout> __spirv_ArbitraryFloatCastToIntINTEL(
330-
ap_int<WA> A, int32_t MA, int32_t EnableSubnormals = 0,
331+
ap_int<WA> A, int32_t MA, bool ToSign = false, int32_t EnableSubnormals = 0,
331332
int32_t RoundingMode = 0, int32_t RoundingAccuracy = 0) noexcept;
332333

333334
template <int WA, int WB, int Wout>

sycl/include/CL/sycl/INTEL/fpga_lsu.hpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ template <class... _mem_access_params> class lsu final {
4747
public:
4848
lsu() = delete;
4949

50-
template <typename _T> static _T load(sycl::global_ptr<_T> Ptr) {
50+
template <typename _T, access::address_space _space>
51+
static _T load(sycl::multi_ptr<_T, _space> Ptr) {
52+
check_space<_space>();
5153
check_load();
5254
#if defined(__SYCL_DEVICE_ONLY__) && __has_builtin(__builtin_intel_fpga_mem)
5355
return *__builtin_intel_fpga_mem((_T *)Ptr,
@@ -59,7 +61,9 @@ template <class... _mem_access_params> class lsu final {
5961
#endif
6062
}
6163

62-
template <typename _T> static void store(sycl::global_ptr<_T> Ptr, _T Val) {
64+
template <typename _T, access::address_space _space>
65+
static void store(sycl::multi_ptr<_T, _space> Ptr, _T Val) {
66+
check_space<_space>();
6367
check_store();
6468
#if defined(__SYCL_DEVICE_ONLY__) && __has_builtin(__builtin_intel_fpga_mem)
6569
*__builtin_intel_fpga_mem((_T *)Ptr,
@@ -92,6 +96,14 @@ template <class... _mem_access_params> class lsu final {
9296

9397
static_assert(_cache_val >= 0, "cache size parameter must be non-negative");
9498

99+
template <access::address_space _space> static void check_space() {
100+
static_assert(_space == access::address_space::global_space ||
101+
_space == access::address_space::global_device_space ||
102+
_space == access::address_space::global_host_space,
103+
"lsu controls are only supported for global_ptr, "
104+
"device_ptr, and host_ptr objects");
105+
}
106+
95107
static void check_load() {
96108
static_assert(_cache == 0 || _burst_coalesce == BURST_COALESCE,
97109
"unable to implement a cache without a burst coalescer");

sycl/test/check_device_code/fpga_ihs_float.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111

1212
#include "CL/__spirv/spirv_ops.hpp"
1313

14-
constexpr int32_t Subnorm = 0, RndMode = 2, RndAcc = 1;
14+
constexpr int32_t Subnorm = 0;
15+
constexpr int32_t RndMode = 2;
16+
constexpr int32_t RndAcc = 1;
17+
constexpr bool FromSign = false;
18+
constexpr bool ToSign = true;
1519

1620
template <int EA, int MA, int Eout, int Mout>
1721
void ap_float_cast() {
@@ -27,17 +31,17 @@ void ap_float_cast_from_int() {
2731
ap_int<WA> A;
2832
ap_int<1 + Eout + Mout> cast_from_int_res =
2933
__spirv_ArbitraryFloatCastFromIntINTEL<WA, 1 + Eout + Mout>(
30-
A, Mout, Subnorm, RndMode, RndAcc);
31-
// CHECK: call spir_func signext i25 @_Z{{[0-9]+}}__spirv_ArbitraryFloatCastFromIntINTEL{{.*}}(i43 {{[%a-z0-9.]+}}, i32 16, i32 0, i32 2, i32 1)
34+
A, Mout, FromSign, Subnorm, RndMode, RndAcc);
35+
// CHECK: call spir_func signext i25 @_Z{{[0-9]+}}__spirv_ArbitraryFloatCastFromIntINTEL{{.*}}(i43 {{[%a-z0-9.]+}}, i32 16, i1 zeroext false, i32 0, i32 2, i32 1)
3236
}
3337

3438
template <int EA, int MA, int Wout>
3539
void ap_float_cast_to_int() {
3640
ap_int<1 + EA + MA> A;
3741
ap_int<Wout> cast_to_int_res =
3842
__spirv_ArbitraryFloatCastToIntINTEL<1 + EA + MA, Wout>(
39-
A, MA, Subnorm, RndMode, RndAcc);
40-
// CHECK: call spir_func signext i30 @_Z{{[0-9]+}}__spirv_ArbitraryFloatCastToIntINTEL{{.*}}(i23 signext {{[%a-z0-9.]+}}, i32 15, i32 0, i32 2, i32 1)
43+
A, MA, ToSign, Subnorm, RndMode, RndAcc);
44+
// CHECK: call spir_func signext i30 @_Z{{[0-9]+}}__spirv_ArbitraryFloatCastToIntINTEL{{.*}}(i23 signext {{[%a-z0-9.]+}}, i32 15, i1 zeroext true, i32 0, i32 2, i32 1)
4145
}
4246

4347
template <int EA, int MA, int EB, int MB, int Eout, int Mout>

sycl/test/extensions/fpga.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,14 @@ int main() {
5959
/*Check LSU interface*/
6060
{
6161
cl::sycl::buffer<int, 1> output_buffer(1);
62-
cl::sycl::buffer<int, 1> input_buffer(1);
62+
auto *in_ptr = cl::sycl::malloc_host<int>(1, Queue.get_context());
6363

6464
Queue.submit([&](cl::sycl::handler &cgh) {
6565
auto output_accessor =
6666
output_buffer.get_access<cl::sycl::access::mode::write>(cgh);
67-
auto input_accessor =
68-
input_buffer.get_access<cl::sycl::access::mode::read>(cgh);
6967

7068
cgh.single_task<class kernel>([=] {
71-
auto input_ptr = input_accessor.get_pointer();
69+
cl::sycl::host_ptr<int> input_ptr(in_ptr);
7270
auto output_ptr = output_accessor.get_pointer();
7371

7472
using PrefetchingLSU =

0 commit comments

Comments
 (0)