Vc 1.4.5
SIMD Vector Classes for C++
 
Loading...
Searching...
No Matches
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, N >
 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.
 
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.
 

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.
 

Typedef Documentation

◆ vector

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.

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];
Vc::fixed_size_simd< int, VectorTraits< T, Abi >::size()> IndexType
The type of the vector used for indexes in gather and scatter operations.
Definition vector.h:177
Common::AdaptSubscriptOperator< std::vector< T, Allocator > > vector
An adapted std::vector container with an additional subscript operator which implements gather and sc...
Definition vector:55
Vector< float > float_v
vector of single precision
Definition vector.h:54

Definition at line 55 of file vector.

◆ span

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.

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];
Common::AdaptSubscriptOperator< Common::span< T, Extent > > span
An adapted std::span with additional subscript operators supporting gather and scatter operations.
Definition span.h:639

Definition at line 639 of file span.h.

Function Documentation

◆ makeContainer()

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

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)
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.

Definition at line 137 of file makeContainer.h.

Referenced by Vc::makeContainer().