Skip to content

Commit

Permalink
sycl::vec overload for sine
Browse files Browse the repository at this point in the history
  • Loading branch information
ndgrigorian committed Nov 25, 2023
1 parent a0959d0 commit b9afb64
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ template <typename argT, typename resT> struct SinFunctor
// constant value, if constant
// constexpr resT constant_value = resT{};
// is function defined for sycl::vec
using supports_vec = typename std::false_type;
using supports_vec = typename std::negation<
std::disjunction<is_complex<resT>, is_complex<argT>>>;
// do both argTy and resTy support sugroup store/load operation
using supports_sg_loadstore = typename std::negation<
std::disjunction<is_complex<resT>, is_complex<argT>>>;
Expand Down Expand Up @@ -181,6 +182,20 @@ template <typename argT, typename resT> struct SinFunctor
return std::sin(in);
}
}

template <int vec_sz>
sycl::vec<resT, vec_sz> operator()(const sycl::vec<argT, vec_sz> &in)
{
auto const &res_vec = sycl::sin(in);
using deducedT = typename std::remove_cv_t<
std::remove_reference_t<decltype(res_vec)>>::element_type;
if constexpr (std::is_same_v<resT, deducedT>) {
return res_vec;
}
else {
return vec_cast<resT, deducedT, vec_sz>(res_vec);
}
}
};

template <typename argTy,
Expand Down

0 comments on commit b9afb64

Please sign in to comment.