Skip to content

Commit c6c1cd5

Browse files
committed
[SYCL] Disable std::byte code by __HAS_STD_BYTE
MS VS allows to disable std::byte type using __HAS_STD_BYTE=0 (https://devblogs.microsoft.com/cppblog/c17-features-and-stl-fixes-in-vs-2017-15-3/). This patch disables SYCL code which relies on this type in this case.
1 parent c222497 commit c6c1cd5

File tree

6 files changed

+21
-10
lines changed

6 files changed

+21
-10
lines changed

sycl/include/CL/sycl/detail/generic_type_traits.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ struct select_cl_mptr_or_vector_or_scalar;
433433
// which is not supported on device
434434
template <typename T> struct TypeHelper { using RetType = T; };
435435

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

sycl/include/CL/sycl/stream.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ class __SYCL_EXPORT __SYCL_SPECIAL_CLASS stream {
958958
const h_item<Dimensions> &RHS);
959959
};
960960

961-
#if __cplusplus >= 201703L
961+
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
962962
// Byte (has to be converted to a numeric value)
963963
template <typename T>
964964
inline std::enable_if_t<std::is_same<T, std::byte>::value, const stream &>

sycl/include/CL/sycl/types.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ template <typename T> struct vec_helper {
103103
static constexpr RetType get(T value) { return value; }
104104
};
105105

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

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

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

2333-
#if __cplusplus >= 201703L
2333+
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
23342334
#define __SYCL_DECLARE_BYTE_VECTOR_CONVERTER \
23352335
namespace detail { \
23362336
__SYCL_DECLARE_BYTE_CONVERTER(2) \
@@ -2344,7 +2344,7 @@ using select_apply_cl_t =
23442344
__SYCL_DECLARE_VECTOR_CONVERTERS(char)
23452345
__SYCL_DECLARE_SCHAR_VECTOR_CONVERTERS
23462346
__SYCL_DECLARE_BOOL_VECTOR_CONVERTERS
2347-
#if __cplusplus >= 201703L
2347+
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
23482348
__SYCL_DECLARE_BYTE_VECTOR_CONVERTER
23492349
#endif
23502350
__SYCL_DECLARE_UNSIGNED_INTEGRAL_VECTOR_CONVERTERS(uchar)
@@ -2371,7 +2371,7 @@ __SYCL_DECLARE_FLOAT_VECTOR_CONVERTERS(double)
23712371
#undef __SYCL_DECLARE_SCALAR_SCHAR_CONVERTER
23722372
#undef __SYCL_DECLARE_BOOL_VECTOR_CONVERTERS
23732373
#undef __SYCL_DECLARE_BOOL_CONVERTER
2374-
#if __cplusplus >= 201703L
2374+
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
23752375
#undef __SYCL_DECLARE_BYTE_VECTOR_CONVERTER
23762376
#undef __SYCL_DECLARE_BYTE_CONVERTER
23772377
#undef __SYCL_DECLARE_SCALAR_BYTE_CONVERTER

sycl/include/sycl/ext/oneapi/experimental/group_helpers_sorters.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#pragma once
1010

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

1414
__SYCL_INLINE_NAMESPACE(cl) {

sycl/include/sycl/ext/oneapi/group_sort.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
#pragma once
1010

11-
#if __cplusplus >= 201703L
11+
#if __cplusplus >= 201703L && (!defined(_HAS_STD_BYTE) || _HAS_STD_BYTE != 0)
1212
#include <CL/sycl/detail/defines_elementary.hpp>
1313
#include <CL/sycl/detail/group_sort_impl.hpp>
1414
#include <CL/sycl/detail/type_traits.hpp>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify -D_HAS_STD_BYTE=0 %s -Xclang -verify-ignore-unexpected=note,warning
2+
// RUN: %clangxx -fsycl -fsyntax-only -Xclang -verify %s -Xclang -verify-ignore-unexpected=note,warning
3+
// expected-no-diagnostics
4+
using namespace ::std;
5+
#include <CL/sycl.hpp>
6+
#include <algorithm>
7+
#ifdef _WIN32
8+
#include <windows.h>
9+
#endif
10+
11+
int main() { return 0; }

0 commit comments

Comments
 (0)