Skip to content

Commit 8db7dd5

Browse files
committed
Add exp builtins header to sycl.hpp and c++17 guards.
Signed-off-by: JackAKirk <[email protected]>
1 parent e0c40a9 commit 8db7dd5

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

sycl/include/CL/sycl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#include <sycl/ext/oneapi/backend/level_zero.hpp>
6262
#endif
6363
#include <sycl/ext/oneapi/device_global/properties.hpp>
64+
#include <sycl/ext/oneapi/experimental/builtins.hpp>
6465
#include <sycl/ext/oneapi/experimental/cuda/barrier.hpp>
6566
#include <sycl/ext/oneapi/filter_selector.hpp>
6667
#include <sycl/ext/oneapi/group_algorithm.hpp>

sycl/include/sycl/ext/oneapi/experimental/builtins.hpp

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,12 @@ sycl::marray<bfloat16, N> fabs(sycl::marray<bfloat16, N> x) {
143143
auto partial_res = __clc_fabs(detail::to_uint32_t(x, i * 2));
144144
std::memcpy(&res[i * 2], &partial_res, sizeof(uint32_t));
145145
}
146-
147-
if constexpr (N % 2) {
146+
#if __cplusplus >= 201703L
147+
if constexpr (N % 2)
148+
#else
149+
if (N % 2)
150+
#endif // __cplusplus >= 201703L
151+
{
148152
res[N - 1] = bfloat16::from_bits(__clc_fabs(x[N - 1].raw()));
149153
}
150154
return res;
@@ -179,7 +183,12 @@ sycl::marray<bfloat16, N> fmin(sycl::marray<bfloat16, N> x,
179183
std::memcpy(&res[i * 2], &partial_res, sizeof(uint32_t));
180184
}
181185

182-
if constexpr (N % 2) {
186+
#if __cplusplus >= 201703L
187+
if constexpr (N % 2)
188+
#else
189+
if (N % 2)
190+
#endif // __cplusplus >= 201703L
191+
{
183192
res[N - 1] =
184193
bfloat16::from_bits(__clc_fmin(x[N - 1].raw(), y[N - 1].raw()));
185194
}
@@ -217,7 +226,12 @@ sycl::marray<bfloat16, N> fmax(sycl::marray<bfloat16, N> x,
217226
std::memcpy(&res[i * 2], &partial_res, sizeof(uint32_t));
218227
}
219228

220-
if constexpr (N % 2) {
229+
#if __cplusplus >= 201703L
230+
if constexpr (N % 2)
231+
#else
232+
if (N % 2)
233+
#endif // __cplusplus >= 201703L
234+
{
221235
res[N - 1] =
222236
bfloat16::from_bits(__clc_fmax(x[N - 1].raw(), y[N - 1].raw()));
223237
}
@@ -257,7 +271,12 @@ sycl::marray<bfloat16, N> fma(sycl::marray<bfloat16, N> x,
257271
std::memcpy(&res[i * 2], &partial_res, sizeof(uint32_t));
258272
}
259273

260-
if constexpr (N % 2) {
274+
#if __cplusplus >= 201703L
275+
if constexpr (N % 2)
276+
#else
277+
if (N % 2)
278+
#endif // __cplusplus >= 201703L
279+
{
261280
res[N - 1] = bfloat16::from_bits(
262281
__clc_fma(x[N - 1].raw(), y[N - 1].raw(), z[N - 1].raw()));
263282
}

0 commit comments

Comments
 (0)