Skip to content

Commit c00c1fa

Browse files
authored
[SYCL] Remove half type alias causing name conflicts (#2624)
It causes conflicts with CUDA headers, which define also the half type in global scope.
1 parent f79b9d0 commit c00c1fa

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

sycl/include/CL/sycl/half_type.hpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -220,15 +220,12 @@ inline float cast_if_host_half(half_impl::half val) {
220220
} // namespace sycl
221221
} // __SYCL_INLINE_NAMESPACE(cl)
222222

223-
using half = cl::sycl::detail::half_impl::half;
224-
225223
// Partial specialization of some functions in namespace `std`
226224
namespace std {
227225

228-
229226
// Partial specialization of `std::hash<cl::sycl::half>`
230-
template <> struct hash<half> {
231-
size_t operator()(half const &Key) const noexcept {
227+
template <> struct hash<cl::sycl::half> {
228+
size_t operator()(cl::sycl::half const &Key) const noexcept {
232229
return hash<uint16_t>{}(reinterpret_cast<const uint16_t &>(Key));
233230
}
234231
};
@@ -260,7 +257,7 @@ template <> struct hash<half> {
260257

261258
#define SYCL_HLF_RADIX 2
262259

263-
template <> struct numeric_limits<half> {
260+
template <> struct numeric_limits<cl::sycl::half> {
264261
static constexpr const bool is_specialized = true;
265262

266263
static constexpr const bool is_signed = true;
@@ -307,51 +304,53 @@ template <> struct numeric_limits<half> {
307304

308305
static constexpr const float_round_style round_style = round_to_nearest;
309306

310-
static __SYCL_CONSTEXPR_ON_DEVICE const half(min)() noexcept {
307+
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half(min)() noexcept {
311308
return SYCL_HLF_MIN;
312309
}
313310

314-
static __SYCL_CONSTEXPR_ON_DEVICE const half(max)() noexcept {
311+
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half(max)() noexcept {
315312
return SYCL_HLF_MAX;
316313
}
317314

318-
static __SYCL_CONSTEXPR_ON_DEVICE const half lowest() noexcept {
315+
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half lowest() noexcept {
319316
return -SYCL_HLF_MAX;
320317
}
321318

322-
static __SYCL_CONSTEXPR_ON_DEVICE const half epsilon() noexcept {
319+
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half epsilon() noexcept {
323320
return SYCL_HLF_EPSILON;
324321
}
325322

326-
static __SYCL_CONSTEXPR_ON_DEVICE const half round_error() noexcept {
323+
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half
324+
round_error() noexcept {
327325
return 0.5F;
328326
}
329327

330-
static __SYCL_CONSTEXPR_ON_DEVICE const half infinity() noexcept {
328+
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half infinity() noexcept {
331329
return __builtin_huge_valf();
332330
}
333331

334-
static __SYCL_CONSTEXPR_ON_DEVICE const half quiet_NaN() noexcept {
332+
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half quiet_NaN() noexcept {
335333
return __builtin_nanf("");
336334
}
337335

338-
static __SYCL_CONSTEXPR_ON_DEVICE const half signaling_NaN() noexcept {
336+
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half
337+
signaling_NaN() noexcept {
339338
return __builtin_nansf("");
340339
}
341340

342-
static __SYCL_CONSTEXPR_ON_DEVICE const half denorm_min() noexcept {
341+
static __SYCL_CONSTEXPR_ON_DEVICE const cl::sycl::half denorm_min() noexcept {
343342
return 5.96046e-08F;
344343
}
345344
};
346345

347346
} // namespace std
348347

349-
inline std::ostream &operator<<(std::ostream &O, half const &rhs) {
348+
inline std::ostream &operator<<(std::ostream &O, cl::sycl::half const &rhs) {
350349
O << static_cast<float>(rhs);
351350
return O;
352351
}
353352

354-
inline std::istream &operator>>(std::istream &I, half &rhs) {
353+
inline std::istream &operator>>(std::istream &I, cl::sycl::half &rhs) {
355354
float ValFloat = 0.0f;
356355
I >> ValFloat;
357356
rhs = ValFloat;

0 commit comments

Comments
 (0)