Skip to content

Commit ccedb78

Browse files
Refactor is_genbool_v not to use type lists
1 parent 2d90abc commit ccedb78

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

sycl/include/sycl/detail/generic_type_lists.hpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -461,16 +461,6 @@ using marray_integer_list =
461461
using integer_list =
462462
tl_append<scalar_integer_list, vector_integer_list, marray_integer_list>;
463463

464-
// bool types
465-
466-
using marray_bool_list =
467-
type_list<marray<bool, 1>, marray<bool, 2>, marray<bool, 3>,
468-
marray<bool, 4>, marray<bool, 8>, marray<bool, 16>>;
469-
470-
using scalar_bool_list = type_list<bool>;
471-
472-
using bool_list = tl_append<scalar_bool_list, marray_bool_list>;
473-
474464
} // namespace gtl
475465
} // namespace detail
476466
} // namespace _V1

sycl/include/sycl/detail/generic_type_traits.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ inline constexpr bool is_sugeninteger_v =
6565
is_contained_v<T, gtl::scalar_unsigned_integer_list>;
6666

6767
template <typename T>
68-
inline constexpr bool is_genbool_v = is_contained_v<T, gtl::bool_list>;
68+
inline constexpr bool is_genbool_v =
69+
std::is_same_v<T, bool> ||
70+
(is_marray_v<T> && std::is_same_v<element_type_t<T>, bool> &&
71+
is_allowed_vec_size_v<num_elements_v<T>>);
6972

7073
template <typename T>
7174
using is_byte = typename

sycl/include/sycl/detail/type_traits/vec_marray_traits.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ struct element_type<T __attribute__((ext_vector_type(N)))> {
9999
#endif
100100
template <typename T> using element_type_t = typename element_type<T>::type;
101101

102+
template <int N>
103+
inline constexpr bool is_allowed_vec_size_v =
104+
N == 1 || N == 2 || N == 3 || N == 4 || N == 8 || N == 16;
105+
102106
} // namespace detail
103107
} // namespace _V1
104108
} // namespace sycl

sycl/include/sycl/vector.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,7 @@ class __SYCL_EBO vec
137137
static_assert(std::is_same_v<DataT, std::remove_cv_t<DataT>>,
138138
"DataT must be cv-unqualified");
139139

140-
static_assert(NumElements == 1 || NumElements == 2 || NumElements == 3 ||
141-
NumElements == 4 || NumElements == 8 || NumElements == 16,
140+
static_assert(detail::is_allowed_vec_size_v<NumElements>,
142141
"Invalid number of elements for sycl::vec: only 1, 2, 3, 4, 8 "
143142
"or 16 are supported");
144143
static_assert(sizeof(bool) == sizeof(uint8_t), "bool size is not 1 byte");

0 commit comments

Comments
 (0)