Skip to content

Commit

Permalink
[NFC][SYCL] Move helpers from builtins_preview.hpp to their single uses
Browse files Browse the repository at this point in the history
There are some issues with them as well (both in naming and bugs in
implementation), to be fixed in a separate PR to ease review.
  • Loading branch information
aelovikov-intel committed Feb 7, 2024
1 parent 9617939 commit 0ce7b06
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
23 changes: 0 additions & 23 deletions sycl/include/sycl/builtins_preview.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,29 +175,13 @@ auto builtin_delegate_to_scalar(FuncTy F, const Ts &...x) {
}
}

template <typename T>
struct any_elem_type
: std::bool_constant<check_type_in_v<
get_elem_type_t<T>, float, double, half, char, signed char, short,
int, long, long long, unsigned char, unsigned short, unsigned int,
unsigned long, unsigned long long>> {};
template <typename T>
struct fp_elem_type
: std::bool_constant<
check_type_in_v<get_elem_type_t<T>, float, double, half>> {};
template <typename T>
struct float_elem_type
: std::bool_constant<check_type_in_v<get_elem_type_t<T>, float>> {};
template <typename T>
struct integer_elem_type
: std::bool_constant<
check_type_in_v<get_elem_type_t<T>, char, signed char, short, int,
long, long long, unsigned char, unsigned short,
unsigned int, unsigned long, unsigned long long>> {};
template <typename T>
struct suint32_elem_type
: std::bool_constant<
check_type_in_v<get_elem_type_t<T>, int32_t, uint32_t>> {};

template <typename... Ts>
struct same_basic_shape : std::bool_constant<builtin_same_shape_v<Ts...>> {};
Expand Down Expand Up @@ -244,13 +228,6 @@ struct builtin_enable
SHAPE_CHECKER, EXTRA_CONDITIONS, Ts...>::type; \
}
} // namespace detail

BUILTIN_CREATE_ENABLER(builtin_enable_generic, default_ret_type, any_elem_type,
any_shape, same_elem_type)
BUILTIN_CREATE_ENABLER(builtin_enable_generic_scalar, default_ret_type,
any_elem_type, scalar_only, same_elem_type)
BUILTIN_CREATE_ENABLER(builtin_enable_generic_non_scalar, default_ret_type,
any_elem_type, non_scalar_only, same_elem_type)
} // namespace _V1
} // namespace sycl

Expand Down
12 changes: 12 additions & 0 deletions sycl/include/sycl/detail/builtins/integer_functions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@

namespace sycl {
inline namespace _V1 {
namespace detail {
template <typename T>
struct integer_elem_type
: std::bool_constant<
check_type_in_v<get_elem_type_t<T>, char, signed char, short, int,
long, long long, unsigned char, unsigned short,
unsigned int, unsigned long, unsigned long long>> {};
template <typename T>
struct suint32_elem_type
: std::bool_constant<
check_type_in_v<get_elem_type_t<T>, int32_t, uint32_t>> {};
} // namespace detail
BUILTIN_CREATE_ENABLER(builtin_enable_integer, default_ret_type,
integer_elem_type, any_shape, same_elem_type)
BUILTIN_CREATE_ENABLER(builtin_enable_integer_non_scalar, default_ret_type,
Expand Down
14 changes: 14 additions & 0 deletions sycl/include/sycl/detail/builtins/relational_functions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
namespace sycl {
inline namespace _V1 {
namespace detail {
template <typename T>
struct any_elem_type
: std::bool_constant<check_type_in_v<
get_elem_type_t<T>, float, double, half, char, signed char, short,
int, long, long long, unsigned char, unsigned short, unsigned int,
unsigned long, unsigned long long>> {};

template <typename T>
struct rel_ret_traits
: std::conditional<is_scalar_arithmetic_v<T>, bool,
Expand All @@ -21,6 +28,13 @@ struct rel_ret_traits
same_size_signed_int_t<simplify_if_swizzle_t<T>>>> {
};
} // namespace detail

BUILTIN_CREATE_ENABLER(builtin_enable_generic, default_ret_type, any_elem_type,
any_shape, same_elem_type)
BUILTIN_CREATE_ENABLER(builtin_enable_generic_scalar, default_ret_type,
any_elem_type, scalar_only, same_elem_type)
BUILTIN_CREATE_ENABLER(builtin_enable_generic_non_scalar, default_ret_type,
any_elem_type, non_scalar_only, same_elem_type)
BUILTIN_CREATE_ENABLER(builtin_enable_rel, rel_ret_traits, fp_elem_type,
non_scalar_only, same_elem_type)

Expand Down

0 comments on commit 0ce7b06

Please sign in to comment.