Skip to content

Commit 15e3e9d

Browse files
[NFC][SYCL] Substitute is_valid_size_v with check_value_in_v (#16913)
That would match with pre-existing `check_type_in_v`.
1 parent 7ed4491 commit 15e3e9d

File tree

4 files changed

+8
-25
lines changed

4 files changed

+8
-25
lines changed

sycl/include/sycl/builtins_utils_scalar.hpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,6 @@ template <typename> struct use_fast_math : std::false_type {};
3232
#endif
3333
template <typename T> constexpr bool use_fast_math_v = use_fast_math<T>::value;
3434

35-
template <size_t N, size_t... Ns> constexpr bool CheckSizeIn() {
36-
constexpr bool SameSize[] = {(N == Ns)...};
37-
// Replace with std::any_of with C++20.
38-
for (size_t I = 0; I < sizeof...(Ns); ++I)
39-
if (SameSize[I])
40-
return true;
41-
return false;
42-
}
43-
44-
// NOTE: We need a constexpr variable definition for the constexpr functions
45-
// as MSVC thinks function definitions are the same otherwise.
46-
template <size_t... Ns> constexpr bool check_size_in_v = CheckSizeIn<Ns...>();
47-
4835
// Utility for converting a swizzle to a vector or preserve the type if it isn't
4936
// a swizzle.
5037
template <typename T> struct simplify_if_swizzle {

sycl/include/sycl/builtins_utils_vec.hpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@
2020
namespace sycl {
2121
inline namespace _V1 {
2222
namespace detail {
23-
24-
// Utilty trait for checking that the number of elements in T is in Ns.
25-
template <typename T, size_t... Ns>
26-
struct is_valid_size
27-
: std::bool_constant<check_size_in_v<num_elements<T>::value, Ns...>> {};
28-
29-
template <typename T, int... Ns>
30-
constexpr bool is_valid_size_v = is_valid_size<T, Ns...>::value;
31-
3223
// Utility for converting a swizzle to a vector or preserve the type if it isn't
3324
// a swizzle.
3425
template <typename VecT, typename OperationLeftT, typename OperationRightT,

sycl/include/sycl/detail/builtins/geometric_functions.inc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ namespace sycl {
1414
inline namespace _V1 {
1515
namespace detail {
1616
template <typename T>
17-
struct shape_geo : std::bool_constant<is_valid_size_v<T, 2, 3, 4> ||
18-
is_scalar_arithmetic_v<T>> {};
17+
struct shape_geo
18+
: std::bool_constant<check_value_in_v<num_elements_v<T>, 2, 3, 4> ||
19+
is_scalar_arithmetic_v<T>> {};
1920
template <typename T>
20-
struct shape_geo3or4 : std::bool_constant<is_valid_size_v<T, 3, 4>> {};
21+
struct shape_geo3or4
22+
: std::bool_constant<check_value_in_v<num_elements_v<T>, 3, 4>> {};
2123
} // namespace detail
2224

2325
BUILTIN_CREATE_ENABLER(builtin_enable_geo, default_ret_type, fp_elem_type,

sycl/include/sycl/detail/type_traits.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,9 @@ struct map_type<T, From, To, Rest...> {
383383
template <typename T, typename... Ts>
384384
constexpr bool check_type_in_v = ((std::is_same_v<T, Ts> || ...));
385385

386+
template <auto V, auto... Vs>
387+
constexpr bool check_value_in_v = (((V == Vs) || ...));
388+
386389
#if __has_builtin(__type_pack_element)
387390
template <int N, typename... Ts>
388391
using nth_type_t = __type_pack_element<N, Ts...>;

0 commit comments

Comments
 (0)