Vc  1.4.1
SIMD Vector Classes for C++
Containers

Detailed Description

For some problems, standard (or third-party) containers can be used. Simply use a value_type of Vc::Vector<T>. However, this requires:

Therefore, for some problems you need to work with containers over elements of non-Vector type (e.g. of type double or a struct). Vc provides some help:

Classes

struct  array< T, Size >
 This is std::array with additional subscript operators supporting gather and scatter operations. More...
 
class  InterleavedMemoryWrapper< S, V >
 Wraps a pointer to memory with convenience functions to access it via vectors. More...
 
class  Memory< V, Size1, Size2, InitPadding >
 A helper class for fixed-size two-dimensional arrays. More...
 
class  Memory< V, Size, 0u, InitPadding >
 A helper class to simplify usage of correctly aligned and padded memory, allowing both vector and scalar access. More...
 
class  Memory< V, 0u, 0u, true >
 A helper class that is very similar to Memory<V, Size> but with dynamically allocated memory and thus dynamic size. More...
 

Typedefs

template<typename T , typename Allocator = std::allocator<T>>
using vector = Common::AdaptSubscriptOperator< std::vector< T, Allocator > >
 An adapted std::vector container with an additional subscript operator which implements gather and scatter operations. More...
 
template<typename T , ptrdiff_t Extent = dynamic_extent>
using span = Common::AdaptSubscriptOperator< Common::span< T, Extent > >
 An adapted std::span with additional subscript operators supporting gather and scatter operations. More...
 

Functions

template<typename Container , typename T >
constexpr auto makeContainer (std::initializer_list< T > list) -> decltype(make_container_helper< Container, T >::help(list))
 Construct a container of Vc vectors from a std::initializer_list of scalar entries. More...
 

Typedef Documentation

◆ vector

using vector = Common::AdaptSubscriptOperator<std::vector<T, Allocator> >

An adapted std::vector container with an additional subscript operator which implements gather and scatter operations.

The std::vector documentation applies.

Example:

struct Point {
float x, y;
};
data.resize(100);
// initialize values in data
float_v::IndexType indexes = ...; // values between 0-99
float_v x = data[indexes][&Point::x];
float_v y = data[indexes][&Point::y];

Definition at line 55 of file vector.

◆ span

using span = Common::AdaptSubscriptOperator<Common::span<T, Extent> >

An adapted std::span with additional subscript operators supporting gather and scatter operations.

The std::span documentation applies.

Example:

struct Point {
float x, y;
};
Point data[100];
// initialize values in data
float_v::IndexType indexes = ...; // values between 0-99
float_v x = view[indexes][&Point::x];
float_v y = view[indexes][&Point::y];

Definition at line 635 of file span.h.

Function Documentation

◆ makeContainer()

constexpr auto Vc::makeContainer ( std::initializer_list< T >  list) -> decltype(make_container_helper<Container, T>::help(list))

Construct a container of Vc vectors from a std::initializer_list of scalar entries.

Template Parameters
ContainerThe container type to construct.
TThe scalar type to use for the initializer_list.
Parameters
listAn initializer list of arbitrary size. The type of the entries is important! If you pass a list of integers you will get a container filled with Vc::int_v objects. If, instead, you want to have a container of Vc::float_v objects, be sure the include a period (.) and the 'f' postfix in the literals. Alternatively, you can pass the type as second template argument to makeContainer.
Returns
Returns a container of the requested class filled with the minimum number of SIMD vectors to hold the values in the initializer list. If the number of values in list does not match the number of values in the returned container object, the remaining values in the returned object will be zero-initialized.

Example:

auto data = Vc::makeContainer<std::vector<float_v>>({ 1.f, 2.f, 3.f, 4.f, 5.f });
// data.size() == 5 if float_v::Size == 1 (i.e. Vc_IMPL=Scalar)
// data.size() == 2 if float_v::Size == 4 (i.e. Vc_IMPL=SSE)
// data.size() == 1 if float_v::Size == 8 (i.e. Vc_IMPL=AVX)

Definition at line 137 of file makeContainer.h.