Skip to content

[SYCL] Disable std::byte code by _HAS_STD_BYTE #4834

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 6 commits into from
Nov 1, 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
6 changes: 3 additions & 3 deletions sycl/include/CL/sycl/detail/generic_type_lists.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ using vector_long_integer_list = type_list<vector_signed_long_integer_list,
using long_integer_list =
type_list<scalar_long_integer_list, vector_long_integer_list>;

#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
// std::byte
using scalar_byte_list = type_list<std::byte>;

Expand Down Expand Up @@ -321,7 +321,7 @@ using scalar_unsigned_integer_list =
scalar_unsigned_char_list>,
scalar_unsigned_short_list, scalar_unsigned_int_list,
scalar_unsigned_long_list, scalar_unsigned_longlong_list
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
,
scalar_byte_list
#endif
Expand All @@ -334,7 +334,7 @@ using vector_unsigned_integer_list =
vector_unsigned_char_list>,
vector_unsigned_short_list, vector_unsigned_int_list,
vector_unsigned_long_list, vector_unsigned_longlong_list
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
,
vector_byte_list
#endif
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/CL/sycl/detail/generic_type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ struct select_cl_mptr_or_vector_or_scalar;
// which is not supported on device
template <typename T> struct TypeHelper { using RetType = T; };

#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
template <> struct TypeHelper<std::byte> { using RetType = std::uint8_t; };
#endif

Expand Down
7 changes: 4 additions & 3 deletions sycl/include/CL/sycl/stream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,12 @@ EnableIfFP<T, unsigned> floatingPointToDecStr(T AbsVal, char *Digits,
for (unsigned I = 0; I < FractionLength; ++I)
Digits[Offset++] = digitToChar(FractionDigits[I]);

auto AbsExp = Exp < 0 ? -Exp : Exp;
// Exponent part
Digits[Offset++] = 'e';
Digits[Offset++] = Exp >= 0 ? '+' : '-';
Digits[Offset++] = digitToChar(abs(Exp) / 10);
Digits[Offset++] = digitToChar(abs(Exp) % 10);
Digits[Offset++] = digitToChar(AbsExp / 10);
Digits[Offset++] = digitToChar(AbsExp % 10);
} else { // normal mode
if (Exp < 0) {
Digits[Offset++] = '0';
Expand Down Expand Up @@ -958,7 +959,7 @@ class __SYCL_EXPORT __SYCL_SPECIAL_CLASS stream {
const h_item<Dimensions> &RHS);
};

#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
// Byte (has to be converted to a numeric value)
template <typename T>
inline std::enable_if_t<std::is_same<T, std::byte>::value, const stream &>
Expand Down
12 changes: 6 additions & 6 deletions sycl/include/CL/sycl/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ template <typename T> struct vec_helper {
static constexpr RetType get(T value) { return value; }
};

#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
template <> struct vec_helper<std::byte> {
using RetType = std::uint8_t;
static constexpr RetType get(std::byte value) { return (RetType)value; }
Expand Down Expand Up @@ -2206,7 +2206,7 @@ using select_apply_cl_t =
__SYCL_GET_CL_TYPE(int, num), __SYCL_GET_CL_TYPE(long, num)>; \
};

#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
#define __SYCL_DECLARE_BYTE_CONVERTER(num) \
template <> class BaseCLTypeConverter<std::byte, num> { \
public: \
Expand All @@ -2231,7 +2231,7 @@ using select_apply_cl_t =
using DataType = bool; \
};

#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
#define __SYCL_DECLARE_SCALAR_BYTE_CONVERTER \
template <> class BaseCLTypeConverter<std::byte, 1> { \
public: \
Expand Down Expand Up @@ -2330,7 +2330,7 @@ using select_apply_cl_t =
__SYCL_DECLARE_SCALAR_BOOL_CONVERTER \
} // namespace detail

#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
#define __SYCL_DECLARE_BYTE_VECTOR_CONVERTER \
namespace detail { \
__SYCL_DECLARE_BYTE_CONVERTER(2) \
Expand All @@ -2344,7 +2344,7 @@ using select_apply_cl_t =
__SYCL_DECLARE_VECTOR_CONVERTERS(char)
__SYCL_DECLARE_SCHAR_VECTOR_CONVERTERS
__SYCL_DECLARE_BOOL_VECTOR_CONVERTERS
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
__SYCL_DECLARE_BYTE_VECTOR_CONVERTER
#endif
__SYCL_DECLARE_UNSIGNED_INTEGRAL_VECTOR_CONVERTERS(uchar)
Expand All @@ -2371,7 +2371,7 @@ __SYCL_DECLARE_FLOAT_VECTOR_CONVERTERS(double)
#undef __SYCL_DECLARE_SCALAR_SCHAR_CONVERTER
#undef __SYCL_DECLARE_BOOL_VECTOR_CONVERTERS
#undef __SYCL_DECLARE_BOOL_CONVERTER
#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
#undef __SYCL_DECLARE_BYTE_VECTOR_CONVERTER
#undef __SYCL_DECLARE_BYTE_CONVERTER
#undef __SYCL_DECLARE_SCALAR_BYTE_CONVERTER
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
#include <CL/sycl/detail/group_sort_impl.hpp>

__SYCL_INLINE_NAMESPACE(cl) {
Expand Down
2 changes: 1 addition & 1 deletion sycl/include/sycl/ext/oneapi/group_sort.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#pragma once

#if __cplusplus >= 201703L
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
#include <CL/sycl/detail/defines_elementary.hpp>
#include <CL/sycl/detail/group_sort_impl.hpp>
#include <CL/sycl/detail/type_traits.hpp>
Expand Down
4 changes: 4 additions & 0 deletions sycl/test/regression/disabled_std_byte.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -D_HAS_STD_BYTE=0 %s -Xclang -verify-ignore-unexpected=note,warning
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
// expected-no-diagnostics
#include <CL/sycl.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I missed that the first time. I guess the problem is exposed on Windows platform only. Am I right?

Suggested change
#include <CL/sycl.hpp>
// REQUIRES: windows
#include <CL/sycl.hpp>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. But running both on Linux and Windows ensures that Linux is not regressed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not blocking, but this test is useless on Linux. It does nothing useful.
You might invent infinite number of other defines to tests if they are not regressed as well. What might be useful to dump all defines enabled by including sycl.hpp and check there is nothing unexpected.