SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
|
Transforms a range of ranges into chunks of seqan3::simd vectors. More...
#include <seqan3/utility/simd/views/to_simd.hpp>
Classes | |
class | iterator_type |
Iterator that transposes the underlying range of ranges and transforms that to SIMD types. More... | |
Public Member Functions | |
constexpr bool | empty () const noexcept |
Checks whether the range is empty. | |
constexpr size_t | size () const noexcept |
Returns the size of this range. | |
Constructors, destructor and assignment | |
constexpr | view_to_simd ()=default |
Defaulted. | |
constexpr | view_to_simd (view_to_simd const &)=default |
Defaulted. | |
constexpr | view_to_simd (view_to_simd &&)=default |
Defaulted. | |
constexpr view_to_simd & | operator= (view_to_simd const &)=default |
Defaulted. | |
constexpr view_to_simd & | operator= (view_to_simd &&)=default |
Defaulted. | |
~view_to_simd ()=default | |
Defaulted. | |
constexpr | view_to_simd (urng_t urng, scalar_type const padding_value=alphabet_size) |
Construction from the underlying range. | |
template<typename other_urng_t > requires (!std::same_as<std::remove_cvref_t<other_urng_t>, view_to_simd>) && (!std::same_as<other_urng_t, urng_t>) && std::ranges::viewable_range<other_urng_t> | |
constexpr | view_to_simd (other_urng_t &&urng, scalar_type const padding_value=alphabet_size) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
Iterators | |
constexpr iterator_type | begin () noexcept |
The iterator to begin of this range. | |
constexpr void | begin () const noexcept=delete |
Const iteration is disabled. | |
constexpr std::default_sentinel_t | end () noexcept |
A sentinel representing the end of this range. | |
constexpr void | end () const noexcept=delete |
Const iteration is disabled. | |
Private Types | |
Auxiliary types | |
using | inner_range_type = std::ranges::range_value_t< urng_t > |
The inner range type. | |
using | chunk_type = std::array< simd_t, simd_traits< simd_t >::length > |
The underlying type to hold the chunks. | |
using | scalar_type = typename simd_traits< simd_t >::scalar_type |
using | max_simd_type = simd_type_t< uint8_t, simd_traits< simd_t >::max_length > |
The SIMD type with maximal number of lanes for the current arch. | |
Private Attributes | |
std::array< chunk_type, total_chunks > | cached_simd_chunks {} |
The cached chunks of transformed simd vectors. | |
simd_t | padding_simd_vector {} |
A cached simd vector with the padding symbol. | |
scalar_type | padding_value {} |
The padding value used to fill the corresponding simd vector element. | |
urng_t | urng {} |
The underlying range. | |
Static Private Attributes | |
Auxiliary variables | |
static constexpr bool | fast_load |
Check if fast load is enabled. | |
static constexpr uint8_t | chunk_size = simd_traits<simd_t>::length |
The size of one chunk. Equals the number of elements in the simd vector. | |
static constexpr uint8_t | chunks_per_load = simd_traits<simd_t>::max_length / chunk_size |
The number of chunks that can be gathered with a single load. | |
static constexpr uint8_t | total_chunks = fast_load ? (chunks_per_load * chunks_per_load) : 1 |
The total number of chunks that can be cached. | |
static constexpr auto | alphabet_size = seqan3::alphabet_size<std::ranges::range_value_t<inner_range_type>> |
The alphabet size. | |
Transforms a range of ranges into chunks of seqan3::simd vectors.
urng_t | The underlying range type; must model std::ranges::forward_range. |
simd_t | The simd type to convert to. |
This view applies an Array-of-Structure to Structure-of-Array transformation on a set of sequences. The typical application is to transform the memory layout of sequences such that they can be efficiently used in vectorised algorithms. Accordingly, this view transforms the memory already into chunks of simd vectors. The number of sequences must correspond to the length of the target simd vector, i.e. there are exactly as many sequences as their are simd vector elements. The output range will be a range over chunks, where each chunk represents a quadratic std::array over simd vectors (the size of the chunk is equal to the number of elements in the target simd vector).
Depending on the types of the input ranges a more efficient transformation using simd instructions is used. The following requirements must be fulfilled by the inner range type of the underlying range:
If one of these requirements is not fulfilled a standard fallback algorithm is used which might be slower to transform the sequences, depending on the auto-vectorisation capabilities of the used compiler.
|
private |
The scalar type.
|
inlineconstexpr |
Construction from the underlying range.
[in] | urng | The underlying range. |
[in] | padding_value | The value used to fill up smaller sequences. |
|
inlineconstexprnoexcept |
Returns the size of this range.
Only available if the inner range types model std::ranges::sized_range.
|
staticconstexprprivate |
Check if fast load is enabled.