Skip to content

Commit 3e4289c

Browse files
committed
reviewer feedback. restored release note and moved bit_cast to its own file
Signed-off-by: Chris Perkins <[email protected]>
1 parent cc75fea commit 3e4289c

File tree

4 files changed

+56
-31
lines changed

4 files changed

+56
-31
lines changed

sycl/ReleaseNotes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ Release notes for the commit range ba404be..24726df
763763
BEs to perform additional optimizations [fdcaeae] [08f8656]
764764
- Added partial support for [Host task with interop capabilities extension](https://github.com/codeplaysoftware/standards-proposals/blob/master/host_task/host_task.md) [ae3fd5c]
765765
- Added support for [SYCL_INTEL_bitcast](doc/extensions/Bitcast/SYCL_INTEL_bitcast.asciidoc)
766-
as a `sycl::bit_cast` [e3da4ef]
766+
as a `sycl::detail::bit_cast` [e3da4ef]
767767
- Introduced the Level Zero plugin which enables SYCL working on top of Level0
768768
API. Interoperability is not supportet yet [d32da99]
769769
- Implemented [parallel_for simplification extension](doc/extensions/ParallelForSimpification) [13fe9fb]

sycl/include/CL/sycl/bit_cast.hpp

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
//==---------------- helpers.hpp - SYCL helpers ----------------------------==//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#pragma once
10+
11+
#if __cpp_lib_bit_cast
12+
#include <bit>
13+
#endif
14+
15+
__SYCL_INLINE_NAMESPACE(cl) {
16+
namespace sycl {
17+
18+
// forward decl
19+
namespace detail {
20+
inline void memcpy(void *Dst, const void *Src, size_t Size);
21+
}
22+
23+
// sycl::bit_cast ( no longer sycl::detail::bit_cast )
24+
template <typename To, typename From>
25+
#if __cpp_lib_bit_cast || __has_builtin(__builtin_bit_cast)
26+
constexpr
27+
#endif
28+
To
29+
bit_cast(const From &from) noexcept {
30+
static_assert(sizeof(To) == sizeof(From),
31+
"Sizes of To and From must be equal");
32+
static_assert(std::is_trivially_copyable<From>::value,
33+
"From must be trivially copyable");
34+
static_assert(std::is_trivially_copyable<To>::value,
35+
"To must be trivially copyable");
36+
#if __cpp_lib_bit_cast
37+
return std::bit_cast<To>(from);
38+
#else // __cpp_lib_bit_cast
39+
40+
#if __has_builtin(__builtin_bit_cast)
41+
return __builtin_bit_cast(To, from);
42+
#else // __has_builtin(__builtin_bit_cast)
43+
static_assert(std::is_trivially_default_constructible<To>::value,
44+
"To must be trivially default constructible");
45+
To to;
46+
sycl::detail::memcpy(&to, &from, sizeof(To));
47+
return to;
48+
#endif // __has_builtin(__builtin_bit_cast)
49+
50+
#endif // __cpp_lib_bit_cast
51+
}
52+
53+
} // namespace sycl
54+
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/include/CL/sycl/detail/helpers.hpp

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -245,35 +245,5 @@ getSPIRVMemorySemanticsMask(const access::fence_space AccessSpace,
245245

246246
} // namespace detail
247247

248-
// sycl::bit_cast ( no longer sycl::detail::bit_cast )
249-
template <typename To, typename From>
250-
#if __cpp_lib_bit_cast || __has_builtin(__builtin_bit_cast)
251-
constexpr
252-
#endif
253-
To
254-
bit_cast(const From &from) noexcept {
255-
static_assert(sizeof(To) == sizeof(From),
256-
"Sizes of To and From must be equal");
257-
static_assert(std::is_trivially_copyable<From>::value,
258-
"From must be trivially copyable");
259-
static_assert(std::is_trivially_copyable<To>::value,
260-
"To must be trivially copyable");
261-
#if __cpp_lib_bit_cast
262-
return std::bit_cast<To>(from);
263-
#else // __cpp_lib_bit_cast
264-
265-
#if __has_builtin(__builtin_bit_cast)
266-
return __builtin_bit_cast(To, from);
267-
#else // __has_builtin(__builtin_bit_cast)
268-
static_assert(std::is_trivially_default_constructible<To>::value,
269-
"To must be trivially default constructible");
270-
To to;
271-
sycl::detail::memcpy(&to, &from, sizeof(To));
272-
return to;
273-
#endif // __has_builtin(__builtin_bit_cast)
274-
275-
#endif // __cpp_lib_bit_cast
276-
}
277-
278248
} // namespace sycl
279249
} // __SYCL_INLINE_NAMESPACE(cl)

sycl/include/CL/sycl/stl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <CL/sycl/detail/defines.hpp>
1414

15+
#include "bit_cast.hpp"
1516
#include <exception>
1617
#include <functional>
1718
#include <memory>

0 commit comments

Comments
 (0)