#ifndef TULIP_KERNELS_ELEMENTWISE_HPP #define TULIP_KERNELS_ELEMENTWISE_HPP #include "../simd/simd.hpp" #include namespace tulip { namespace kernels { template void elementwise_scalar(T* dst, const Expr& expr, std::size_t size) { for (std::size_t idx = 0; idx < size; ++idx) { dst[idx] = expr.coeff(idx); } } template void elementwise(T* dst, const Expr& expr, std::size_t size) { std::size_t idx = 0; constexpr std::size_t width = simd::detail::width_v; for (; idx + width <= size; idx += width) { auto value = expr.template eval_pack(idx); simd::detail::store(dst + idx, value); } for (; idx < size; ++idx) { dst[idx] = expr.coeff(idx); } } } // namespace kernels } // namespace tulip #endif // TULIP_KERNELS_ELEMENTWISE_HPP