Skip to content

Commit

Permalink
Adds sycl::vec overload to sin function
Browse files Browse the repository at this point in the history
  • Loading branch information
ndgrigorian committed Jun 8, 2023
1 parent 19fc395 commit 85a5cb3
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,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 All @@ -66,6 +67,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 85a5cb3

Please sign in to comment.