32template <simd::simd_concept simd_t,
size_t... I>
35 return simd_t{((void)I, scalar)...};
40template <simd::simd_concept simd_t,
typename scalar_t, scalar_t... I>
43 return simd_t{
static_cast<scalar_t
>(
offset + I)...};
60template <
size_t divisor, simd_concept simd_t>
66 for (
size_t i = 0; i <
chunk; ++i)
80template <simd::simd_concept target_simd_t, simd::simd_concept source_simd_t>
84 "Target vector has different byte size.");
87 return upcast_signed_sse4<target_simd_t>(src);
89 return upcast_signed_avx2<target_simd_t>(src);
91 return upcast_signed_avx512<target_simd_t>(src);
104template <simd::simd_concept target_simd_t, simd::simd_concept source_simd_t>
108 "Target vector has different byte size.");
111 return upcast_unsigned_sse4<target_simd_t>(src);
113 return upcast_unsigned_avx2<target_simd_t>(src);
115 return upcast_unsigned_avx512<target_simd_t>(src);
142template <u
int8_t index, simd::simd_concept simd_t>
145 static_assert(index < 2,
"The index must be in the range of [0, 1]");
147 return detail::extract_impl<2>(src, index);
151template <u
int8_t index, simd::simd_concept simd_t>
152 requires detail::is_builtin_simd_v<simd_t> && detail::is_native_builtin_simd_v<simd_t>
155 static_assert(index < 2,
"The index must be in the range of [0, 1]");
160 return detail::extract_half_sse4<index>(src);
162 return detail::extract_half_avx2<index>(src);
164 return detail::extract_half_avx512<index>(src);
166 return detail::extract_impl<2>(src, index);
192template <u
int8_t index, simd::simd_concept simd_t>
195 static_assert(index < 4,
"The index must be in the range of [0, 1, 2, 3]");
197 return detail::extract_impl<4>(src, index);
201template <u
int8_t index, simd::simd_concept simd_t>
202 requires detail::is_builtin_simd_v<simd_t> && detail::is_native_builtin_simd_v<simd_t>
205 static_assert(index < 4,
"The index must be in the range of [0, 1, 2, 3]");
210 return detail::extract_quarter_sse4<index>(src);
212 return detail::extract_quarter_avx2<index>(src);
213#if defined(__AVX512DQ__)
215 return detail::extract_quarter_avx512<index>(src);
218 return detail::extract_impl<4>(src, index);
244template <u
int8_t index, simd::simd_concept simd_t>
247 return detail::extract_impl<8>(src, index);
251template <u
int8_t index, simd::simd_concept simd_t>
252 requires detail::is_builtin_simd_v<simd_t> && detail::is_native_builtin_simd_v<simd_t>
255 static_assert(index < 8,
"The index must be in the range of [0, 1, 2, 3, 4, 5, 6, 7]");
260 return detail::extract_eighth_sse4<index>(src);
262 return detail::extract_eighth_avx2<index>(src);
263#if defined(__AVX512DQ__)
265 return detail::extract_eighth_avx512<index>(src);
268 return detail::extract_impl<8>(src, index);
273template <simd::simd_concept simd_t>
278 for (
size_t i = 0; i < matrix.size(); ++i)
279 for (
size_t j = 0; j < matrix.size(); ++j)
280 tmp[j][i] = matrix[i][j];
302template <simd::simd_concept simd_t>
318template <simd::simd_concept simd_t>
335template <simd::simd_concept simd_t>
336constexpr simd_t
load(
void const * mem_addr)
338 assert(mem_addr !=
nullptr);
341 for (
size_t i = 0; i < simd_traits<simd_t>::length; ++i)
348template <simd::simd_concept simd_t>
349 requires detail::is_builtin_simd_v<simd_t> && detail::is_native_builtin_simd_v<simd_t>
350constexpr simd_t
load(
void const * mem_addr)
352 assert(mem_addr !=
nullptr);
355 return detail::load_sse4<simd_t>(mem_addr);
357 return detail::load_avx2<simd_t>(mem_addr);
359 return detail::load_avx512<simd_t>(mem_addr);
362 "Unsupported simd type.");
376template <simd::simd_concept simd_t>
377constexpr void store(
void * mem_addr, simd_t
const & simd_vec)
379 assert(mem_addr !=
nullptr);
382 for (
size_t i = 0; i < simd_traits<simd_t>::length; ++i)
383 *(
static_cast<scalar_t *
>(mem_addr) + i) = simd_vec[i];
387template <simd::simd_concept simd_t>
388 requires detail::is_builtin_simd_v<simd_t> && detail::is_native_builtin_simd_v<simd_t>
389constexpr void store(
void * mem_addr, simd_t
const & simd_vec)
391 assert(mem_addr !=
nullptr);
394 detail::store_sse4<simd_t>(mem_addr, simd_vec);
396 detail::store_avx2<simd_t>(mem_addr, simd_vec);
398 detail::store_avx512<simd_t>(mem_addr, simd_vec);
401 "Unsupported simd type.");
422template <simd::simd_concept simd_t>
430template <simd::simd_concept simd_t>
431 requires detail::is_builtin_simd_v<simd_t> && detail::is_native_builtin_simd_v<simd_t>
439#if defined(__AVX512BW__)
456template <simd::simd_concept target_simd_t, simd::simd_concept source_simd_t>
457constexpr target_simd_t
upcast(source_simd_t
const & src)
461 "The length of the target simd type must be greater or equal than the length of the source simd type.");
464 for (
unsigned i = 0; i < simd_traits<target_simd_t>::length; ++i)
471template <simd::simd_concept target_simd_t, simd::simd_concept source_simd_t>
472 requires detail::is_builtin_simd_v<target_simd_t> && detail::is_builtin_simd_v<source_simd_t>
473 && detail::is_native_builtin_simd_v<source_simd_t>
474constexpr target_simd_t
upcast(source_simd_t
const & src)
478 "The length of the target simd type must be greater or equal than the length of the source simd type.");
483 "Target vector has a different byte size.");
484 return reinterpret_cast<target_simd_t
>(src);
486 else if constexpr (std::signed_integral<typename simd_traits<source_simd_t>::scalar_type>)
488 return detail::upcast_signed<target_simd_t>(src);
492 static_assert(std::unsigned_integral<typename simd_traits<source_simd_t>::scalar_type>,
493 "Expected unsigned scalar type.");
494 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:38
@ 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:423
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:61
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:457
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:319
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:245
constexpr simd_t iota_impl(scalar_t const offset, std::integer_sequence< scalar_t, I... >)
Helper function for seqan3::simd::iota.
Definition: algorithm.hpp:41
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:33
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:193
constexpr void store(void *mem_addr, simd_t const &simd_vec)
Store simd_t size bits of integral data into memory.
Definition: algorithm.hpp:377
constexpr simd_t load(void const *mem_addr)
Load simd_t size bits of integral data from memory.
Definition: algorithm.hpp:336
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:105
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:303
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:143
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:81
constexpr auto chunk
Divide a range in chunks.
Definition: chunk.hpp:835
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
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:29
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:41
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:49
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:54
Provides seqan3::simd::simd_concept.