69 inline namespace _V1 {
71 template <
typename... Ts>
73 ((... && is_scalar_arithmetic_v<Ts>) || (... && is_marray_v<Ts>) ||
74 (... && is_vec_or_swizzle_v<Ts>)) &&
78 template <
typename... Ts>
84 #ifdef __SYCL_DEVICE_ONLY__
85 template <
typename T>
auto convert_arg(T &&
x) {
86 using no_cv_ref = std::remove_cv_t<std::remove_reference_t<T>>;
87 if constexpr (is_vec_v<no_cv_ref>) {
89 using converted_elem_type =
90 decltype(convert_arg(std::declval<elem_type>()));
92 constexpr
auto N = no_cv_ref::size();
93 using result_type = std::conditional_t<N == 1, converted_elem_type,
97 return bit_cast<result_type>(
static_cast<typename no_cv_ref::vector_t
>(
x));
98 }
else if constexpr (is_swizzle_v<no_cv_ref>) {
101 static_assert(is_scalar_arithmetic_v<no_cv_ref> ||
102 is_multi_ptr_v<no_cv_ref> || std::is_pointer_v<no_cv_ref> ||
103 std::is_same_v<no_cv_ref, half>);
108 template <
typename RetTy,
typename T>
auto convert_result(T &&
x) {
109 if constexpr (is_vec_v<RetTy>) {
110 return bit_cast<typename RetTy::vector_t>(
x);
112 return std::forward<T>(
x);
118 template <
typename FuncTy,
typename... Ts>
120 using ret_elem_type = decltype(F(
x[0]...));
122 marray<ret_elem_type, T::size()> Res;
123 constexpr
auto N = T::size();
124 for (
size_t I = 0; I < N / 2; ++I) {
125 auto PartialRes = [&]() {
127 if constexpr (std::is_integral_v<elem_ty>)
133 std::memcpy(&Res[I * 2], &PartialRes,
sizeof(decltype(PartialRes)));
136 Res[N - 1] = F(
x[N - 1]...);
140 template <
typename FuncTy,
typename... Ts>
148 if constexpr ((... || is_marray_v<Ts>)) {
155 template <
typename FuncTy,
typename... Ts>
158 static_assert(is_vec_or_swizzle_v<T> || is_marray_v<T>);
160 constexpr
auto Size = T::size();
161 using ret_elem_type = decltype(F(
x[0]...));
166 if constexpr (is_marray_v<T>) {
167 for (
size_t i = 0; i < Size; ++i)
170 loop<Size>([&](
auto idx) {
r[idx] = F(
x[idx]...); });
176 template <
typename T>
178 : std::bool_constant<
179 check_type_in_v<get_elem_type_t<T>, float, double, half>> {};
180 template <
typename T>
182 : std::bool_constant<check_type_in_v<get_elem_type_t<T>, float>> {};
184 template <
typename... Ts>
187 template <
typename... Ts>
189 all_same_v<get_elem_type_t<Ts>...>> {
192 template <
typename>
struct any_shape : std::true_type {};
194 template <
typename T>
195 struct scalar_only : std::bool_constant<is_scalar_arithmetic_v<T>> {};
197 template <
typename T>
208 template <
template <
typename>
typename RetTypeTrait,
209 template <
typename>
typename ElemTypeChecker,
210 template <
typename>
typename ShapeChecker,
211 template <
typename...>
typename ExtraConditions,
typename... Ts>
214 ElemTypeChecker<typename first_type<Ts...>::type>::value &&
215 ShapeChecker<typename first_type<Ts...>::type>::value &&
216 ExtraConditions<Ts...>::value,
217 typename RetTypeTrait<
218 simplify_if_swizzle_t<typename first_type<Ts...>::type>>::type> {
220 #define BUILTIN_CREATE_ENABLER(NAME, RET_TYPE_TRAIT, ELEM_TYPE_CHECKER, \
221 SHAPE_CHECKER, EXTRA_CONDITIONS) \
223 template <typename... Ts> \
225 typename builtin_enable<RET_TYPE_TRAIT, ELEM_TYPE_CHECKER, \
226 SHAPE_CHECKER, EXTRA_CONDITIONS, Ts...>::type; \
Provides a cross-platform math array class template that works on SYCL devices as well as in host C++...
class sycl::vec ///////////////////////// Provides a cross-patform vector class template that works e...
auto convertToOpenCLType(T &&x)
typename get_fixed_sized_int< T >::type get_fixed_sized_int_t
constexpr bool builtin_same_shape_v
auto builtin_delegate_to_scalar(FuncTy F, const Ts &...x)
auto builtin_marray_impl(FuncTy F, const Ts &...x)
typename get_elem_type< T >::type get_elem_type_t
auto builtin_default_host_impl(FuncTy F, const Ts &...x)
vec< T, 2 > to_vec2(marray< T, N > X, size_t Start)
__attribute__((destructor(110))) static void syclUnload()
typename simplify_if_swizzle< T >::type simplify_if_swizzle_t
constexpr bool builtin_same_or_swizzle_v
get_elem_type_t< T > type