Skip to content

Commit ff35d8c

Browse files
authored
Revert "[SYCL] Remove sycl::byte alias (#4424)" (#4508)
This reverts commit 8ab843b.
1 parent 08b41e1 commit ff35d8c

File tree

6 files changed

+26
-13
lines changed

6 files changed

+26
-13
lines changed

sycl/include/CL/sycl/aliases.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ using half __SYCL2020_DEPRECATED("use 'sycl::half' instead") =
6868

6969
__SYCL_INLINE_NAMESPACE(cl) {
7070
namespace sycl {
71+
using byte __SYCL2020_DEPRECATED("use std::byte instead") = std::uint8_t;
7172
using schar = signed char;
7273
using uchar = unsigned char;
7374
using ushort = unsigned short;

sycl/include/CL/sycl/detail/image_impl.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
__SYCL_INLINE_NAMESPACE(cl) {
2323
namespace sycl {
24+
2425
// forward declarations
2526
enum class image_channel_order : unsigned int;
2627
enum class image_channel_type : unsigned int;
@@ -35,7 +36,7 @@ class handler;
3536
namespace detail {
3637

3738
// utility functions and typedefs for image_impl
38-
using image_allocator = aligned_allocator<unsigned char>;
39+
using image_allocator = aligned_allocator<byte>;
3940

4041
// utility function: Returns the Number of Channels for a given Order.
4142
__SYCL_EXPORT uint8_t getImageNumberChannels(image_channel_order Order);

sycl/include/CL/sycl/image.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ enum class image_channel_type : unsigned int {
5959
fp32 = 14
6060
};
6161

62-
using image_allocator = detail::aligned_allocator<unsigned char>;
62+
using byte = unsigned char;
63+
64+
using image_allocator = detail::aligned_allocator<byte>;
6365

6466
/// Defines a shared image data.
6567
///

sycl/include/CL/sycl/sycl_span.hpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ template<class Container>
138138
__SYCL_INLINE_NAMESPACE(cl) {
139139
namespace sycl {
140140

141+
// byte is unsigned char at sycl/image.hpp:58
142+
using byte = unsigned char;
143+
141144
// asserts suppressed for device compatibility.
142145
// TODO: enable
143146
#if defined(__SYCL_DEVICE_ONLY__)
@@ -381,17 +384,16 @@ template <typename _Tp, size_t _Extent> class _SYCL_SPAN_TEMPLATE_VIS span {
381384
return rev_iterator(begin());
382385
}
383386

384-
_SYCL_SPAN_INLINE_VISIBILITY
385-
span<const std::byte, _Extent * sizeof(element_type)>
387+
_SYCL_SPAN_INLINE_VISIBILITY span<const byte, _Extent * sizeof(element_type)>
386388
__as_bytes() const noexcept {
387-
return span<const std::byte, _Extent * sizeof(element_type)>{
388-
reinterpret_cast<const std::byte *>(data()), size_bytes()};
389+
return span<const byte, _Extent * sizeof(element_type)>{
390+
reinterpret_cast<const byte *>(data()), size_bytes()};
389391
}
390392

391-
_SYCL_SPAN_INLINE_VISIBILITY span<std::byte, _Extent * sizeof(element_type)>
393+
_SYCL_SPAN_INLINE_VISIBILITY span<byte, _Extent * sizeof(element_type)>
392394
__as_writable_bytes() const noexcept {
393-
return span<std::byte, _Extent * sizeof(element_type)>{
394-
reinterpret_cast<std::byte *>(data()), size_bytes()};
395+
return span<byte, _Extent * sizeof(element_type)>{
396+
reinterpret_cast<byte *>(data()), size_bytes()};
395397
}
396398

397399
private:
@@ -575,14 +577,14 @@ class _SYCL_SPAN_TEMPLATE_VIS span<_Tp, dynamic_extent> {
575577
return rev_iterator(begin());
576578
}
577579

578-
_SYCL_SPAN_INLINE_VISIBILITY span<const std::byte, dynamic_extent>
580+
_SYCL_SPAN_INLINE_VISIBILITY span<const byte, dynamic_extent>
579581
__as_bytes() const noexcept {
580-
return {reinterpret_cast<const std::byte *>(data()), size_bytes()};
582+
return {reinterpret_cast<const byte *>(data()), size_bytes()};
581583
}
582584

583-
_SYCL_SPAN_INLINE_VISIBILITY span<std::byte, dynamic_extent>
585+
_SYCL_SPAN_INLINE_VISIBILITY span<byte, dynamic_extent>
584586
__as_writable_bytes() const noexcept {
585-
return {reinterpret_cast<std::byte *>(data()), size_bytes()};
587+
return {reinterpret_cast<byte *>(data()), size_bytes()};
586588
}
587589

588590
private:

sycl/test/basic_tests/types.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ int main() {
9393
// Check the size and alignment of the SYCL vectors.
9494
checkVectors();
9595

96+
// Table 4.93: Additional scalar data types supported by SYCL.
97+
static_assert(sizeof(s::byte) == sizeof(int8_t), "");
98+
9699
// Table 4.94: Scalar data type aliases supported by SYCL
97100
static_assert(is_same<s::cl_bool, decltype(0 != 1)>::value, "");
98101
checkSizeForSignedIntegral<s::cl_char, sizeof(int8_t)>();

sycl/test/warnings/sycl_2020_deprecations.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ int main() {
130130
});
131131
});
132132

133+
// expected-warning@+1{{'byte' is deprecated: use std::byte instead}}
134+
sycl::byte B;
135+
(void)B;
136+
133137
// expected-warning@+1{{'max_constant_buffer_size' is deprecated: max_constant_buffer_size is deprecated}}
134138
auto MCBS = sycl::info::device::max_constant_buffer_size;
135139
(void)MCBS;

0 commit comments

Comments
 (0)