SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::detail::view_to_simd< urng_t, simd_t > Class Template Reference

Transforms a range of ranges into chunks of seqan3::simd vectors. More...

#include <seqan3/utility/simd/views/to_simd.hpp>

+ Inheritance diagram for seqan3::detail::view_to_simd< urng_t, simd_t >:

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_simdoperator= (view_to_simd const &)=default
 Defaulted.
 
constexpr view_to_simdoperator= (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_chunkscached_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.
 

Detailed Description

template<std::ranges::view urng_t, simd::simd_concept simd_t>
class seqan3::detail::view_to_simd< urng_t, simd_t >

Transforms a range of ranges into chunks of seqan3::simd vectors.

Template Parameters
urng_tThe underlying range type; must model std::ranges::forward_range.
simd_tThe 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:

  • they must model std::ranges::contiguous_range
  • the iterator and sentinel types must model std::sized_sentinel_for
  • the size of the rank type of the underlying alphabet must be 1.

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.

Member Typedef Documentation

◆ scalar_type

template<std::ranges::view urng_t, simd::simd_concept simd_t>
using seqan3::detail::view_to_simd< urng_t, simd_t >::scalar_type = typename simd_traits<simd_t>::scalar_type
private

The scalar type.

Constructor & Destructor Documentation

◆ view_to_simd()

template<std::ranges::view urng_t, simd::simd_concept simd_t>
constexpr seqan3::detail::view_to_simd< urng_t, simd_t >::view_to_simd ( urng_t  urng,
scalar_type const  padding_value = alphabet_size 
)
inlineconstexpr

Construction from the underlying range.

Parameters
[in]urngThe underlying range.
[in]padding_valueThe value used to fill up smaller sequences.

Member Function Documentation

◆ size()

template<std::ranges::view urng_t, simd::simd_concept simd_t>
constexpr size_t seqan3::detail::view_to_simd< urng_t, simd_t >::size ( ) const
inlineconstexprnoexcept

Returns the size of this range.

Only available if the inner range types model std::ranges::sized_range.

Member Data Documentation

◆ fast_load

template<std::ranges::view urng_t, simd::simd_concept simd_t>
constexpr bool seqan3::detail::view_to_simd< urng_t, simd_t >::fast_load
staticconstexprprivate
Initial value:
=
std::ranges::contiguous_range<inner_range_type>
&& std::sized_sentinel_for<std::ranges::iterator_t<inner_range_type>, std::ranges::sentinel_t<inner_range_type>>
&& sizeof(alphabet_rank_t<std::ranges::range_value_t<inner_range_type>>) == 1

Check if fast load is enabled.


The documentation for this class was generated from the following file:
Hide me