41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#ifndef TULIP_SIMD_AVX2_HPP
|
|
#define TULIP_SIMD_AVX2_HPP
|
|
|
|
#include "./traits.hpp"
|
|
|
|
namespace tulip {
|
|
namespace simd {
|
|
namespace detail {
|
|
|
|
#ifdef TULIP_AVX2_SUPPORTED
|
|
template <>
|
|
struct traits<float, avx2_isa> {
|
|
using pack_type = __m256;
|
|
|
|
static constexpr std::size_t width = 8;
|
|
|
|
static pack_type load(const float* ptr) noexcept { return _mm256_loadu_ps(ptr); }
|
|
static void store(float* ptr, pack_type value) noexcept { _mm256_storeu_ps(ptr, value); }
|
|
|
|
static pack_type add(pack_type lhs, pack_type rhs) noexcept { return _mm256_add_ps(lhs, rhs); }
|
|
};
|
|
|
|
template <>
|
|
struct traits<double, avx2_isa> {
|
|
using pack_type = __m256d;
|
|
|
|
static constexpr std::size_t width = 4;
|
|
|
|
static pack_type load(const double* ptr) noexcept { return _mm256_loadu_pd(ptr); }
|
|
static void store(double* ptr, pack_type value) noexcept { _mm256_storeu_pd(ptr, value); }
|
|
|
|
static pack_type add(pack_type lhs, pack_type rhs) noexcept { return _mm256_add_pd(lhs, rhs); }
|
|
};
|
|
#endif // TULIP_AVX2_SUPPORTED
|
|
|
|
} // namespace detail
|
|
} // namespace simd
|
|
} // namespace tulip
|
|
|
|
#endif // TULIP_SIMD_AVX2_HPP
|