16 #include <type_traits>
19 inline namespace _V1 {
20 namespace ext::intel::esimd {
28 using uint_type_t = std::conditional_t<
32 std::conditional_t<N == 4, uint32_t,
33 std::conditional_t<N == 8, uint64_t, void>>>>;
36 using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
39 template <
typename U> constexpr
bool is_type() {
return false; }
41 template <
typename U,
typename T,
typename... Ts> constexpr
bool is_type() {
42 using UU =
typename std::remove_const_t<U>;
43 using TT =
typename std::remove_const_t<T>;
44 return std::is_same_v<UU, TT> || is_type<UU, Ts...>();
48 template <
class...>
struct make_esimd_void {
51 template <
class... Tys>
52 using __esimd_void_t =
typename make_esimd_void<Tys...>::type;
55 template <
class Ty,
class =
void>
56 struct is_esimd_arithmetic_type : std::false_type {};
59 struct is_esimd_arithmetic_type<
60 Ty, __esimd_void_t<
std::enable_if_t<std::is_arithmetic_v<Ty>>,
61 decltype(std::declval<Ty>() + std::declval<Ty>()),
62 decltype(std::declval<Ty>() - std::declval<Ty>()),
63 decltype(std::declval<Ty>() * std::declval<Ty>()),
64 decltype(std::declval<Ty>() / std::declval<Ty>())>>
67 template <
typename Ty>
68 static inline constexpr
bool is_esimd_arithmetic_type_v =
69 is_esimd_arithmetic_type<Ty>::value;
72 template <
typename Ty>
73 struct is_vectorizable : std::conditional_t<is_esimd_arithmetic_type_v<Ty>,
74 std::true_type, std::false_type> {};
76 template <
typename Ty>
77 static inline constexpr
bool is_vectorizable_v = is_vectorizable<Ty>::value;
80 template <
typename Ty,
int N>
struct raw_vector_type {
81 static_assert(!std::is_const_v<Ty>,
"const element type not supported");
82 static_assert(is_vectorizable_v<Ty>,
"element type not supported");
83 static_assert(N > 0,
"zero-element vector not supported");
85 static constexpr
int length = N;
90 template <
typename Ty,
int N>
91 using vector_type_t =
typename raw_vector_type<Ty, N>::type;
96 struct invalid_element_type;
98 template <
class T>
struct is_clang_vector_type : std::false_type {
99 static constexpr
int length = 0;
100 using element_type = invalid_element_type;
103 template <
class T,
int N>
104 struct is_clang_vector_type<T
__attribute__((ext_vector_type(N)))>
106 static constexpr
int length = N;
107 using element_type = T;
110 static inline constexpr
bool is_clang_vector_type_v =
111 is_clang_vector_type<T>::value;
113 template <
class T>
struct vector_element_type;
115 template <
class T,
int N>
struct vector_element_type<vector_type_t<T, N>> {
119 template <
class T,
int N>
120 struct vector_element_type<T
__attribute__((ext_vector_type(N)))> {
125 using vector_element_type_t =
typename vector_element_type<T>::type;
__attribute__((always_inline)) auto invoke_simd(sycl
The invoke_simd free function invokes a SIMD function using all work-items in a sub_group.
ValueT length(const ValueT *a, const int len)
Calculate the square root of the input array.