Skip to content

Commit 354d057

Browse files
authored
[SYCL][CUDA] Revert #6386 and remove c++17 usage. (#6400)
Reverts #6386 so that experimental/builtins.hpp is included in sycl.hpp. This avoids users being required to include this header when using printf or experimental math functions. Corresponding update here: intel/llvm-test-suite#1076.
1 parent d01371b commit 354d057

File tree

5 files changed

+33
-14
lines changed

5 files changed

+33
-14
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: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@
2727
#endif
2828

2929
__SYCL_INLINE_NAMESPACE(cl) {
30-
namespace sycl::ext::oneapi::experimental {
30+
namespace sycl {
31+
namespace ext {
32+
namespace oneapi {
33+
namespace experimental {
3134
namespace detail {
3235
template <size_t N>
3336
uint32_t to_uint32_t(sycl::marray<bfloat16, N> x, size_t start) {
@@ -144,7 +147,7 @@ sycl::marray<bfloat16, N> fabs(sycl::marray<bfloat16, N> x) {
144147
std::memcpy(&res[i * 2], &partial_res, sizeof(uint32_t));
145148
}
146149

147-
if constexpr (N % 2) {
150+
if (N % 2) {
148151
res[N - 1] = bfloat16::from_bits(__clc_fabs(x[N - 1].raw()));
149152
}
150153
return res;
@@ -179,7 +182,7 @@ sycl::marray<bfloat16, N> fmin(sycl::marray<bfloat16, N> x,
179182
std::memcpy(&res[i * 2], &partial_res, sizeof(uint32_t));
180183
}
181184

182-
if constexpr (N % 2) {
185+
if (N % 2) {
183186
res[N - 1] =
184187
bfloat16::from_bits(__clc_fmin(x[N - 1].raw(), y[N - 1].raw()));
185188
}
@@ -217,7 +220,7 @@ sycl::marray<bfloat16, N> fmax(sycl::marray<bfloat16, N> x,
217220
std::memcpy(&res[i * 2], &partial_res, sizeof(uint32_t));
218221
}
219222

220-
if constexpr (N % 2) {
223+
if (N % 2) {
221224
res[N - 1] =
222225
bfloat16::from_bits(__clc_fmax(x[N - 1].raw(), y[N - 1].raw()));
223226
}
@@ -257,7 +260,7 @@ sycl::marray<bfloat16, N> fma(sycl::marray<bfloat16, N> x,
257260
std::memcpy(&res[i * 2], &partial_res, sizeof(uint32_t));
258261
}
259262

260-
if constexpr (N % 2) {
263+
if (N % 2) {
261264
res[N - 1] = bfloat16::from_bits(
262265
__clc_fma(x[N - 1].raw(), y[N - 1].raw(), z[N - 1].raw()));
263266
}
@@ -271,7 +274,10 @@ sycl::marray<bfloat16, N> fma(sycl::marray<bfloat16, N> x,
271274
#endif // defined(__SYCL_DEVICE_ONLY__) && defined(__NVPTX__)
272275
}
273276

274-
} // namespace sycl::ext::oneapi::experimental
277+
} // namespace experimental
278+
} // namespace oneapi
279+
} // namespace ext
280+
} // namespace sycl
275281
} // __SYCL_INLINE_NAMESPACE(cl)
276282

277283
#undef __SYCL_CONSTANT_AS

sycl/include/sycl/ext/oneapi/matrix/matrix-tensorcore.hpp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010
#include <sycl/ext/oneapi/experimental/bfloat16.hpp>
1111

1212
__SYCL_INLINE_NAMESPACE(cl) {
13-
namespace sycl::ext::oneapi {
14-
namespace experimental::matrix {
13+
namespace sycl {
14+
namespace ext {
15+
namespace oneapi {
16+
namespace experimental {
17+
namespace matrix {
1518

1619
enum class matrix_use { a, b, accumulator };
1720

@@ -169,7 +172,8 @@ joint_matrix_fill(Group sg,
169172
#endif // defined(__SYCL_DEVICE_ONLY__) && defined(__NVPTX__)
170173
}
171174

172-
} // namespace experimental::matrix
175+
} // namespace matrix
176+
} // namespace experimental
173177

174178
namespace detail {
175179

@@ -199,6 +203,7 @@ constexpr int get_layout_id<
199203
return 1;
200204
}
201205

206+
#if __cplusplus >= 201703L // if constexpr usage
202207
template <typename S, typename T,
203208
sycl::ext::oneapi::experimental::matrix::matrix_use Use,
204209
size_t NumRows, size_t NumCols,
@@ -379,6 +384,7 @@ struct joint_matrix_load_impl<
379384
}
380385
}
381386
};
387+
#endif // __cplusplus >= 201703L
382388

383389
template <typename T, size_t NumRows, size_t NumCols,
384390
sycl::ext::oneapi::experimental::matrix::matrix_layout Layout,
@@ -391,6 +397,7 @@ struct joint_matrix_store_impl {
391397
multi_ptr<T, Space> dst, size_t stride);
392398
};
393399

400+
#if __cplusplus >= 201703L // if constexpr usage
394401
template <typename T, size_t NumRows, size_t NumCols,
395402
sycl::ext::oneapi::experimental::matrix::matrix_layout Layout,
396403
access::address_space Space>
@@ -454,6 +461,7 @@ struct joint_matrix_store_impl<
454461
}
455462
}
456463
};
464+
#endif // __cplusplus >= 201703L
457465

458466
template <typename T1, typename T2, std::size_t M, std::size_t K, std::size_t N,
459467
sycl::ext::oneapi::experimental::matrix::matrix_layout LayoutA,
@@ -510,6 +518,7 @@ constexpr int get_layout_pair_id<
510518
return 3;
511519
}
512520

521+
#if __cplusplus >= 201703L // if constexpr usage
513522
template <typename T1, typename T2, std::size_t M, std::size_t K, std::size_t N,
514523
sycl::ext::oneapi::experimental::matrix::matrix_layout LayoutA,
515524
sycl::ext::oneapi::experimental::matrix::matrix_layout LayoutB,
@@ -675,10 +684,12 @@ struct joint_matrix_mad_impl<
675684
return D;
676685
}
677686
};
687+
#endif // __cplusplus >= 201703L
678688

679689
} // namespace detail
680690

681-
namespace experimental::matrix {
691+
namespace experimental {
692+
namespace matrix {
682693

683694
template <typename Group, typename S, typename T, matrix_use Use,
684695
size_t NumRows, size_t NumCols, matrix_layout Layout,
@@ -766,6 +777,9 @@ float round_to_tf32(float a) {
766777
#endif // defined(__SYCL_DEVICE_ONLY__) && defined(__NVPTX__)
767778
}
768779

769-
} // namespace experimental::matrix
770-
} // namespace sycl::ext::oneapi
780+
} // namespace matrix
781+
} // namespace experimental
782+
} // namespace oneapi
783+
} // namespace ext
784+
} // namespace sycl
771785
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/test/basic_tests/built-ins.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// Hits an assertion with AMD:
88
// XFAIL: hip_amd
99

10-
#include <sycl/ext/oneapi/experimental/builtins.hpp>
1110
#include <sycl/sycl.hpp>
1211

1312
#include <cassert>

sycl/test/extensions/experimental-printf.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
// CHECK: Constant [[#TYPE]] [[#CONST:]]
1717
// CHECK: ExtInst [[#]] [[#]] [[#]] printf [[#]] [[#CONST]]
1818

19-
#include <sycl/ext/oneapi/experimental/builtins.hpp>
2019
#include <sycl/sycl.hpp>
2120

2221
#ifdef __SYCL_DEVICE_ONLY__

0 commit comments

Comments
 (0)