Skip to content

Revert "[SYCL] Remove sycl::byte alias" #4508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sycl/include/CL/sycl/aliases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ using half __SYCL2020_DEPRECATED("use 'sycl::half' instead") =

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {
using byte __SYCL2020_DEPRECATED("use std::byte instead") = std::uint8_t;
using schar = signed char;
using uchar = unsigned char;
using ushort = unsigned short;
Expand Down
3 changes: 2 additions & 1 deletion sycl/include/CL/sycl/detail/image_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {

// forward declarations
enum class image_channel_order : unsigned int;
enum class image_channel_type : unsigned int;
Expand All @@ -35,7 +36,7 @@ class handler;
namespace detail {

// utility functions and typedefs for image_impl
using image_allocator = aligned_allocator<unsigned char>;
using image_allocator = aligned_allocator<byte>;

// utility function: Returns the Number of Channels for a given Order.
__SYCL_EXPORT uint8_t getImageNumberChannels(image_channel_order Order);
Expand Down
4 changes: 3 additions & 1 deletion sycl/include/CL/sycl/image.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ enum class image_channel_type : unsigned int {
fp32 = 14
};

using image_allocator = detail::aligned_allocator<unsigned char>;
using byte = unsigned char;

using image_allocator = detail::aligned_allocator<byte>;

/// Defines a shared image data.
///
Expand Down
24 changes: 13 additions & 11 deletions sycl/include/CL/sycl/sycl_span.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ template<class Container>
__SYCL_INLINE_NAMESPACE(cl) {
namespace sycl {

// byte is unsigned char at sycl/image.hpp:58
using byte = unsigned char;

// asserts suppressed for device compatibility.
// TODO: enable
#if defined(__SYCL_DEVICE_ONLY__)
Expand Down Expand Up @@ -381,17 +384,16 @@ template <typename _Tp, size_t _Extent> class _SYCL_SPAN_TEMPLATE_VIS span {
return rev_iterator(begin());
}

_SYCL_SPAN_INLINE_VISIBILITY
span<const std::byte, _Extent * sizeof(element_type)>
_SYCL_SPAN_INLINE_VISIBILITY span<const byte, _Extent * sizeof(element_type)>
__as_bytes() const noexcept {
return span<const std::byte, _Extent * sizeof(element_type)>{
reinterpret_cast<const std::byte *>(data()), size_bytes()};
return span<const byte, _Extent * sizeof(element_type)>{
reinterpret_cast<const byte *>(data()), size_bytes()};
}

_SYCL_SPAN_INLINE_VISIBILITY span<std::byte, _Extent * sizeof(element_type)>
_SYCL_SPAN_INLINE_VISIBILITY span<byte, _Extent * sizeof(element_type)>
__as_writable_bytes() const noexcept {
return span<std::byte, _Extent * sizeof(element_type)>{
reinterpret_cast<std::byte *>(data()), size_bytes()};
return span<byte, _Extent * sizeof(element_type)>{
reinterpret_cast<byte *>(data()), size_bytes()};
}

private:
Expand Down Expand Up @@ -575,14 +577,14 @@ class _SYCL_SPAN_TEMPLATE_VIS span<_Tp, dynamic_extent> {
return rev_iterator(begin());
}

_SYCL_SPAN_INLINE_VISIBILITY span<const std::byte, dynamic_extent>
_SYCL_SPAN_INLINE_VISIBILITY span<const byte, dynamic_extent>
__as_bytes() const noexcept {
return {reinterpret_cast<const std::byte *>(data()), size_bytes()};
return {reinterpret_cast<const byte *>(data()), size_bytes()};
}

_SYCL_SPAN_INLINE_VISIBILITY span<std::byte, dynamic_extent>
_SYCL_SPAN_INLINE_VISIBILITY span<byte, dynamic_extent>
__as_writable_bytes() const noexcept {
return {reinterpret_cast<std::byte *>(data()), size_bytes()};
return {reinterpret_cast<byte *>(data()), size_bytes()};
}

private:
Expand Down
3 changes: 3 additions & 0 deletions sycl/test/basic_tests/types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ int main() {
// Check the size and alignment of the SYCL vectors.
checkVectors();

// Table 4.93: Additional scalar data types supported by SYCL.
static_assert(sizeof(s::byte) == sizeof(int8_t), "");

// Table 4.94: Scalar data type aliases supported by SYCL
static_assert(is_same<s::cl_bool, decltype(0 != 1)>::value, "");
checkSizeForSignedIntegral<s::cl_char, sizeof(int8_t)>();
Expand Down
4 changes: 4 additions & 0 deletions sycl/test/warnings/sycl_2020_deprecations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ int main() {
});
});

// expected-warning@+1{{'byte' is deprecated: use std::byte instead}}
sycl::byte B;
(void)B;

// expected-warning@+1{{'max_constant_buffer_size' is deprecated: max_constant_buffer_size is deprecated}}
auto MCBS = sycl::info::device::max_constant_buffer_size;
(void)MCBS;
Expand Down