The simd module contains a unified interface to provide simd types and functions used in seqan3. More...
Typedefs | |
template<typename scalar_t , size_t length> | |
using | seqan3::detail::default_simd_backend = builtin_simd< scalar_t, length > |
seqan3::detail::default_simd_backend is the default used implementation of seqan3::simd::simd_type. More... | |
template<typename scalar_t , size_t length = detail::default_simd_length<scalar_t, detail::default_simd_backend>, template< typename scalar_t_, size_t length_ > typename simd_backend = detail::default_simd_backend> | |
using | seqan3::simd::simd_type_t = typename simd_type< scalar_t, length, simd_backend >::type |
Helper type of seqan3::simd::simd_type. | |
Functions | |
template<uint8_t index, simd::simd_concept simd_t> | |
constexpr simd_t | seqan3::detail::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. More... | |
template<uint8_t index, simd::simd_concept simd_t> | |
constexpr simd_t | seqan3::detail::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 vector. More... | |
template<size_t divisor, simd_concept simd_t> | |
constexpr simd_t | seqan3::detail::extract_impl (simd_t const &src, uint8_t const mask) |
Helper function to extract a part of the given simd vector. More... | |
template<uint8_t index, simd::simd_concept simd_t> | |
constexpr simd_t | seqan3::detail::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. More... | |
template<simd::simd_concept simd_t> | |
constexpr simd_t | seqan3::simd::fill (typename simd_traits< simd_t >::scalar_type const scalar) noexcept |
Fills a seqan3::simd::simd_type vector with a scalar value. More... | |
template<simd::simd_concept simd_t, size_t... I> | |
constexpr simd_t | seqan3::detail::fill_impl (typename simd_traits< simd_t >::scalar_type const scalar, std::index_sequence< I... >) noexcept |
Helper function for seqan3::simd::fill. | |
template<simd::simd_concept simd_t> | |
constexpr simd_t | seqan3::simd::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, ... More... | |
template<simd::simd_concept simd_t, typename scalar_t , scalar_t... I> | |
constexpr simd_t | seqan3::detail::iota_impl (scalar_t const offset, std::integer_sequence< scalar_t, I... >) |
Helper function for seqan3::simd::iota. | |
template<simd::simd_concept simd_t> | |
constexpr simd_t | seqan3::simd::load (void const *mem_addr) |
Load simd_t size bits of integral data from memory. More... | |
template<typename char_t , typename simd_t > | |
debug_stream_type< char_t > & | seqan3::operator<< (debug_stream_type< char_t > &s, simd_t &&simd) |
Overload for debug_stream for simd types. More... | |
template<simd::simd_concept simd_t> | |
constexpr void | seqan3::simd::store (void *mem_addr, simd_t const &simd_vec) |
Store simd_t size bits of integral data into memory. More... | |
template<simd::simd_concept simd_t> | |
constexpr void | seqan3::simd::transpose (std::array< simd_t, simd_traits< simd_t >::length > &matrix) |
Transposes the given simd vector matrix. More... | |
template<simd::simd_concept target_simd_t, simd::simd_concept source_simd_t> | |
constexpr target_simd_t | seqan3::simd::upcast (source_simd_t const &src) |
Upcasts the given vector into the target vector using sign extension of packed values. More... | |
template<simd::simd_concept target_simd_t, simd::simd_concept source_simd_t> | |
constexpr target_simd_t | seqan3::detail::upcast_signed (source_simd_t const &src) |
Upcasts the given vector into the target vector using signed extension of packed values. More... | |
template<simd::simd_concept target_simd_t, simd::simd_concept source_simd_t> | |
constexpr target_simd_t | seqan3::detail::upcast_unsigned (source_simd_t const &src) |
Upcasts the given vector into the target vector using unsigned extension of packed values. More... | |
Variables | |
template<typename scalar_t , template< typename, size_t > typename simd_backend_t> | |
constexpr auto | seqan3::detail::default_simd_length |
seqan3::detail::default_simd_length returns the default length depending on the given scalar_t type, which is used in seqan3::simd::simd_type. More... | |
template<template< typename, size_t > typename simd_backend_t> | |
constexpr auto | seqan3::detail::default_simd_max_length = 0u |
seqan3 auto-detects the maximum number of packable [u]int8_t types. More... | |
template<> | |
constexpr auto | seqan3::detail::default_simd_max_length< builtin_simd > |
This function specializes seqan3::detail::default_simd_max_length for seqan3::detail::builtin_simd. More... | |
template<simd_concept index_simd_t> | |
constexpr detail::iota_simd_view_fn< index_simd_t > | seqan3::views::iota_simd |
An iota view over a simd vector. More... | |
template<typename builtin_simd_t > | |
constexpr bool | seqan3::detail::is_builtin_simd_v = is_builtin_simd<builtin_simd_t>::value |
Helper variable to test whether a type is a simd builtin type. More... | |
template<typename builtin_simd_t > | |
constexpr bool | seqan3::detail::is_native_builtin_simd_v = is_native_builtin_simd<builtin_simd_t>::value |
Helper variable to test whether a type is a native simd builtin type. More... | |
template<simd::simd_concept simd_t> | |
constexpr auto | seqan3::views::to_simd |
A view that transforms a range of ranges into chunks of seqan3::simd vectors. More... | |
The simd module contains a unified interface to provide simd types and functions used in seqan3.
cond DEV
and todo
commands and remove seqan3::simd
from SEQAN3_DOXYGEN_EXCLUDE_SYMBOLS in seqan3-doxygen.cmake
.There are different simd implementations (backends), which are auto-selected by seqan3::simd::simd_type_t. Namely seqan3::detail::builtin_simd.
using seqan3::detail::default_simd_backend = typedef builtin_simd<scalar_t, length> |
seqan3::detail::default_simd_backend is the default used implementation of seqan3::simd::simd_type.
scalar_t | The underlying type of a simd vector |
length | The number of packed values in a simd vector |
|
constexpr |
Extracts one eighth of the given simd vector and stores it in the lower eighth of the target vector.
index | An index value in the range of [0, 1, 2, 3, 4, 5, 6, 7]. |
simd_t | The simd type. |
src | The source to extract the eighth from. |
src
If the simd vector contains less than 8 elements, the unchanged source will be returned.Only the first simd length / 8 elements are defined. The value of the remaining elements is implementation defined.
Example operation for SSE4:
|
constexpr |
Extracts one half of the given simd vector and stores the result in the lower half of the target vector.
index | An index value in the range of [0, 1]. |
simd_t | The simd type. |
src | The source to extract the half from. |
src
If the simd vector contains less than 2 elements, the unchanged source will be returned.Only the first simd length / 2 elements are defined. The value of the remaining elements is implementation defined.
Example operation for SSE4:
|
constexpr |
Helper function to extract a part of the given simd vector.
divisor | The divisor to select the chunk size. |
simd_t | The simd type; must model seqan3::simd::simd_concept. |
[in] | src | The source vector to extract from. |
[in] | mask | The control mask to select which chunk is extracted. |
Extracts the specified part of the source simd vector and stores it in the first chunk starting at offset 0 in the destination vector.
|
constexpr |
Extracts one quarter of the given simd vector and stores it in the lower quarter of the target vector.
index | An index value in the range of [0, 1, 2, 3]. |
simd_t | The simd type. |
src | The source to extract the quarter from. |
src
. If the simd vector contains less than 4 elements, the unchanged source will be returned.Only the first simd length / 4 elements are defined. The value of the remaining elements is implementation defined.
Example operation for SSE4:
|
constexprnoexcept |
Fills a seqan3::simd::simd_type vector with a scalar value.
simd_t | The simd type which satisfies seqan3::simd::simd_concept. |
[in] | scalar | The scalar value to fill the seqan3::simd::simd_type vector. |
|
constexpr |
Fills a seqan3::simd::simd_type vector with the scalar values offset, offset+1, offset+2, ...
simd_t | The simd type which satisfies seqan3::simd::simd_concept. |
[in] | offset | The scalar offset to fill the seqan3::simd::simd_type vector. |
|
constexpr |
Load simd_t size bits of integral data from memory.
simd_t | The simd type; must model seqan3::simd::simd_concept. |
[in] | mem_addr | The memory address to load from. Does not need to be aligned on any particular boundary. |
|
inlineprivate |
Overload for debug_stream for simd types.
private
and todo
commands and remove seqan3::simd
from SEQAN3_DOXYGEN_EXCLUDE_SYMBOLS in seqan3-doxygen.cmake
.
|
constexpr |
Store simd_t size bits of integral data into memory.
simd_t | The simd type; must model seqan3::simd::simd_concept. |
[in] | mem_addr | The memory address to write to. Does not need to be aligned on any particular boundary. |
[in] | simd_vec | The simd vector to read the data from. |
|
constexpr |
Transposes the given simd vector matrix.
simd_t | The simd vector type; must model seqan3::simd::simd_concept and must be a simd built-in type. |
[in,out] | matrix | The matrix that is transposed in place. |
Strong exception guarantee.
Quadratic.
|
constexpr |
Upcasts the given vector into the target vector using sign extension of packed values.
simd_t | The simd type; must model seqan3::simd::simd_concept and must be a builtin simd type. |
|
constexpr |
Upcasts the given vector into the target vector using signed extension of packed values.
target_simd_t | The target simd type; must model seqan3::simd::simd_concept and must be a native builtin simd type. |
source_simd_t | The source simd type; must model seqan3::simd::simd_concept and must be a native builtin simd type. |
[in] | src | The source to upcast into target_simd_t . |
|
constexpr |
Upcasts the given vector into the target vector using unsigned extension of packed values.
target_simd_t | The target simd type; must model seqan3::simd::simd_concept and must be a native builtin simd type. |
source_simd_t | The source simd type; must model seqan3::simd::simd_concept and must be a native builtin simd type. |
[in] | src | The source to upcast into target_simd_t . |
|
constexpr |
seqan3::detail::default_simd_length returns the default length depending on the given scalar_t type, which is used in seqan3::simd::simd_type.
scalar_t | The underlying type of a simd vector |
simd_backend_t | The name of the simd backend. |
|
constexpr |
seqan3 auto-detects the maximum number of packable [u]int8_t
types.
simd_backend_t | The name of the simd backend. |
This value is influenced by compiler flags like -march=native
, -msse4
, -mavx2
, etc and sets this value accordingly.
|
constexpr |
This function specializes seqan3::detail::default_simd_max_length for seqan3::detail::builtin_simd.
The redefinition of default_simd_max_length influences the default length (i.e., seqan3::detail::default_simd_length) of seqan3::simd::simd_type for seqan3::detail::builtin_simd types.
|
inlineconstexpr |
An iota view over a simd vector.
index_simd_t | The represented index type; must model seqan3::simd::simd_concept. |
This view is an equivalent implementation to:
However, benchmarks showed that increasing a simd vector is faster than constructing it every time (up-to 2x speed-up). This speed-up justifies an own class that does this task more efficiently.
This view is a lightweight wrapper around a seqan3::detail::counted_simd_iterator pair. Note the regular std::views::iota view cannot be used with two simd types:
because the return type of the comparison of two simd vector types is not convertible to bool
.
Concepts and traits | rrng_t (returned range type) |
---|---|
std::ranges::input_range | guaranteed |
std::ranges::forward_range | guaranteed |
std::ranges::bidirectional_range | lost |
std::ranges::random_access_range | lost |
std::ranges::contiguous_range | lost |
std::ranges::viewable_range | guaranteed |
std::ranges::view | guaranteed |
std::ranges::sized_range | guaranteed |
std::ranges::common_range | guaranteed |
std::ranges::output_range | lost |
std::ranges::borrowed_range | guaranteed |
seqan3::const_iterable_range | guaranteed |
std::ranges::range_reference_t | index_simd_t |
This is a source view. For more details, see Views.
|
constexpr |
Helper variable to test whether a type is a simd builtin type.
builtin_simd_t | The type to check. |
|
constexpr |
Helper variable to test whether a type is a native simd builtin type.
builtin_simd_t | The type to check. |
|
inlineconstexpr |
A view that transforms a range of ranges into chunks of seqan3::simd vectors.
urng_t | The type of the range being processed. |
simd_t | The target simd vector type. |
[in] | urange | The range being processed. |
[in] | padding | An optional padding value. |
Header File
#include <seqan3/utility/simd/views/to_simd.hpp>
This view can be used to transform a collection of sequences into chunks of simd vectors. This transformation is also known as Array-of-Structure to Structure-of-Array transformation. It is used to transform the memory layout of the sequences to a more efficient form when used in vectorised algorithms. The number of sequences contained in the range to be transformed cannot be larger than the number of elements stored in the target simd vector, i.e. the size of urange
<= simd_traits<simd_t>::length. After applying the transformation one column of the outer range is transposed into a simd vector. This means that the characters of all sequences at a given position x
are stored in a simd vector retaining the original order. The returned range itself is a range-of-ranges. When dereferencing the iterator a std::span over a std::array with at most simd length many vectors is returned. If a sequence is empty or ends before the largest sequence in the collection, it can be padded with an optional value.
Concepts and traits | urng_t (underlying range type) | rrng_t (returned range type) |
---|---|---|
std::ranges::input_range | required | preserved |
std::ranges::forward_range | required | lost |
std::ranges::bidirectional_range | lost | |
std::ranges::random_access_range | lost | |
std::ranges::contiguous_range | lost | |
std::ranges::viewable_range | required | guaranteed |
std::ranges::view | guaranteed | |
std::ranges::sized_range | preserved (iff std::ranges::sized_range<std::ranges::range_value_t<urng_t>> is true ) | |
std::ranges::common_range | lost | |
std::ranges::output_range | lost | |
seqan3::const_iterable_range | lost | |
std::ranges::range_reference_t | std::span<simd_t> |
urng_t
is the type of the range modified by this view (input).std::ranges::input_range<std::ranges::range_value_t<urng_t>
must evaluate to true
std::default_initializable<std::ranges::range_value_t<urng_t>>
must evaluate to true
semialphabet<std::ranges::range_value_t<std::ranges::range_value_t<urng_t>>>
must evaluate to true
rrng_type
is the type of the range returned by this view.The output is as follows: