29template <simd::simd_concept simd_t,
size_t... I>
32 return simd_t{((void)I, scalar)...};
37template <simd::simd_concept simd_t,
typename scalar_t, scalar_t... I>
40 return simd_t{
static_cast<scalar_t
>(
offset + I)...};
57template <
size_t divisor, simd_concept simd_t>
63 for (
size_t i = 0; i < chunk; ++i)
77template <simd::simd_concept target_simd_t, simd::simd_concept source_simd_t>
81 "Target vector has different byte size.");
84 return upcast_signed_sse4<target_simd_t>(src);
86 return upcast_signed_avx2<target_simd_t>(src);
88 return upcast_signed_avx512<target_simd_t>(src);
101template <simd::simd_concept target_simd_t, simd::simd_concept source_simd_t>
105 "Target vector has different byte size.");
108 return upcast_unsigned_sse4<target_simd_t>(src);
110 return upcast_unsigned_avx2<target_simd_t>(src);
112 return upcast_unsigned_avx512<target_simd_t>(src);
139template <u
int8_t index, simd::simd_concept simd_t>
142 static_assert(index < 2,
"The index must be in the range of [0, 1]");
144 return detail::extract_impl<2>(src, index);
148template <u
int8_t index, simd::simd_concept simd_t>
149 requires detail::is_builtin_simd_v<simd_t> && detail::is_native_builtin_simd_v<simd_t>
152 static_assert(index < 2,
"The index must be in the range of [0, 1]");
157 return detail::extract_half_sse4<index>(src);
159 return detail::extract_half_avx2<index>(src);
161 return detail::extract_half_avx512<index>(src);
163 return detail::extract_impl<2>(src, index);
189template <u
int8_t index, simd::simd_concept simd_t>
192 static_assert(index < 4,
"The index must be in the range of [0, 1, 2, 3]");
194 return detail::extract_impl<4>(src, index);
198template <u
int8_t index, simd::simd_concept simd_t>
199 requires detail::is_builtin_simd_v<simd_t> && detail::is_native_builtin_simd_v<simd_t>
202 static_assert(index < 4,
"The index must be in the range of [0, 1, 2, 3]");
207 return detail::extract_quarter_sse4<index>(src);
209 return detail::extract_quarter_avx2<index>(src);
210#if defined(__AVX512DQ__)
212 return detail::extract_quarter_avx512<index>(src);
215 return detail::extract_impl<4>(src, index);
241template <u
int8_t index, simd::simd_concept simd_t>
244 return detail::extract_impl<8>(src, index);
248template <u
int8_t index, simd::simd_concept simd_t>
249 requires detail::is_builtin_simd_v<simd_t> && detail::is_native_builtin_simd_v<simd_t>
252 static_assert(index < 8,
"The index must be in the range of [0, 1, 2, 3, 4, 5, 6, 7]");
257 return detail::extract_eighth_sse4<index>(src);
259 return detail::extract_eighth_avx2<index>(src);
260#if defined(__AVX512DQ__)
262 return detail::extract_eighth_avx512<index>(src);
265 return detail::extract_impl<8>(src, index);
270template <simd::simd_concept simd_t>
275 for (
size_t i = 0; i < matrix.size(); ++i)
276 for (
size_t j = 0; j < matrix.size(); ++j)
277 tmp[j][i] = matrix[i][j];
299template <simd::simd_concept simd_t>
315template <simd::simd_concept simd_t>
332template <simd::simd_concept simd_t>
333constexpr simd_t
load(
void const * mem_addr)
335 assert(mem_addr !=
nullptr);
338 for (
size_t i = 0; i < simd_traits<simd_t>::length; ++i)
345template <simd::simd_concept simd_t>
346 requires detail::is_builtin_simd_v<simd_t> && detail::is_native_builtin_simd_v<simd_t>
347constexpr simd_t
load(
void const * mem_addr)
349 assert(mem_addr !=
nullptr);
352 return detail::load_sse4<simd_t>(mem_addr);
354 return detail::load_avx2<simd_t>(mem_addr);
356 return detail::load_avx512<simd_t>(mem_addr);
359 "Unsupported simd type.");
373template <simd::simd_concept simd_t>
374constexpr void store(
void * mem_addr, simd_t
const & simd_vec)
376 assert(mem_addr !=
nullptr);
379 for (
size_t i = 0; i < simd_traits<simd_t>::length; ++i)
380 *(
static_cast<scalar_t *
>(mem_addr) + i) = simd_vec[i];
384template <simd::simd_concept simd_t>
385 requires detail::is_builtin_simd_v<simd_t> && detail::is_native_builtin_simd_v<simd_t>
386constexpr void store(
void * mem_addr, simd_t
const & simd_vec)
388 assert(mem_addr !=
nullptr);
391 detail::store_sse4<simd_t>(mem_addr, simd_vec);
393 detail::store_avx2<simd_t>(mem_addr, simd_vec);
395 detail::store_avx512<simd_t>(mem_addr, simd_vec);
398 "Unsupported simd type.");
419template <simd::simd_concept simd_t>
422 detail::transpose(matrix);
427template <simd::simd_concept simd_t>
428 requires detail::is_builtin_simd_v<simd_t> && detail::is_native_builtin_simd_v<simd_t>
436#if defined(__AVX512BW__)
441 detail::transpose(matrix);
453template <simd::simd_concept target_simd_t, simd::simd_concept source_simd_t>
454constexpr target_simd_t
upcast(source_simd_t
const & src)
458 "The length of the target simd type must be greater or equal than the length of the source simd type.");
461 for (
unsigned i = 0; i < simd_traits<target_simd_t>::length; ++i)
468template <simd::simd_concept target_simd_t, simd::simd_concept source_simd_t>
469 requires detail::is_builtin_simd_v<target_simd_t> && detail::is_builtin_simd_v<source_simd_t>
470 && detail::is_native_builtin_simd_v<source_simd_t>
471constexpr target_simd_t
upcast(source_simd_t
const & src)
475 "The length of the target simd type must be greater or equal than the length of the source simd type.");
480 "Target vector has a different byte size.");
481 return reinterpret_cast<target_simd_t
>(src);
483 else if constexpr (std::signed_integral<typename simd_traits<source_simd_t>::scalar_type>)
485 return detail::upcast_signed<target_simd_t>(src);
489 static_assert(std::unsigned_integral<typename simd_traits<source_simd_t>::scalar_type>,
490 "Expected unsigned scalar type.");
491 return detail::upcast_unsigned<target_simd_t>(src);
Provides seqan3::detail::builtin_simd, seqan3::detail::is_builtin_simd and seqan3::simd::simd_traits<...
Implementation of a masked alphabet to be used for tuple composites.
Definition mask.hpp:35
@ offset
Sequence (seqan3::field::seq) relative start position (0-based), unsigned value.
constexpr void transpose(std::array< simd_t, simd_traits< simd_t >::length > &matrix)
Transposes the given simd vector matrix.
Definition algorithm.hpp:420
constexpr simd_t extract_impl(simd_t const &src, uint8_t const mask)
Helper function to extract a part of the given simd vector.
Definition algorithm.hpp:58
constexpr target_simd_t upcast(source_simd_t const &src)
Upcasts the given vector into the target vector using sign extension of packed values.
Definition algorithm.hpp:454
constexpr simd_t iota(typename simd_traits< simd_t >::scalar_type const offset)
Fills a seqan3::simd::simd_type vector with the scalar values offset, offset+1, offset+2,...
Definition algorithm.hpp:316
constexpr simd_t extract_eighth(simd_t const &src)
Extracts one eighth of the given simd vector and stores it in the lower eighth of the target vector.
Definition algorithm.hpp:242
constexpr simd_t iota_impl(scalar_t const offset, std::integer_sequence< scalar_t, I... >)
Helper function for seqan3::simd::iota.
Definition algorithm.hpp:38
constexpr simd_t fill_impl(typename simd_traits< simd_t >::scalar_type const scalar, std::index_sequence< I... >) noexcept
Helper function for seqan3::simd::fill.
Definition algorithm.hpp:30
constexpr simd_t extract_quarter(simd_t const &src)
Extracts one quarter of the given simd vector and stores it in the lower quarter of the target vector...
Definition algorithm.hpp:190
constexpr void store(void *mem_addr, simd_t const &simd_vec)
Store simd_t size bits of integral data into memory.
Definition algorithm.hpp:374
constexpr simd_t load(void const *mem_addr)
Load simd_t size bits of integral data from memory.
Definition algorithm.hpp:333
constexpr target_simd_t upcast_unsigned(source_simd_t const &src)
Upcasts the given vector into the target vector using unsigned extension of packed values.
Definition algorithm.hpp:102
constexpr simd_t fill(typename simd_traits< simd_t >::scalar_type const scalar) noexcept
Fills a seqan3::simd::simd_type vector with a scalar value.
Definition algorithm.hpp:300
constexpr simd_t extract_half(simd_t const &src)
Extracts one half of the given simd vector and stores the result in the lower half of the target vect...
Definition algorithm.hpp:140
constexpr target_simd_t upcast_signed(source_simd_t const &src)
Upcasts the given vector into the target vector using signed extension of packed values.
Definition algorithm.hpp:78
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
void transpose_matrix_avx512(std::array< simd_t, simd_traits< simd_t >::length > &matrix)
Transposes the given simd vector matrix.
void transpose_matrix_sse4(std::array< simd_t, simd_traits< simd_t >::length > &matrix)
Transposes the given simd vector matrix.
void transpose_matrix_avx2(std::array< simd_t, simd_traits< simd_t >::length > &matrix)
Transposes the given simd vector matrix.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
Provides specific algorithm implementations for AVX2 instruction set.
Provides specific algorithm implementations for AVX512 instruction set.
Provides specific algorithm implementations for SSE4 instruction set.
Provides seqan3::simd::simd_traits.
seqan3::simd::simd_traits is the trait class that provides uniform interface to the properties of sim...
Definition simd_traits.hpp:38
static constexpr auto length
The number of packed values in a simd vector (is not defined if simd_t does not model seqan3::simd::s...
Definition simd_traits.hpp:46
static constexpr auto max_length
The maximum number of packable values in a simd vector, if the underlying type would be [u]int8_t (is...
Definition simd_traits.hpp:51
Provides seqan3::simd::simd_concept.