Vc
1.3.2-dev
SIMD Vector Classes for C++
|
|
Vector Classes Namespace.
All functions and types of Vc are defined inside the Vc namespace.
Classes | |
struct | AlignedBase |
Helper class to ensure a given alignment. More... | |
class | Allocator |
An allocator that uses global new and supports over-aligned types, as per [C++11 20.6.9]. More... | |
class | CpuId |
This class is available for x86 / AMD64 systems to read and interpret information about the CPU's capabilities. More... | |
struct | Exclusive |
Hint for Prefetch to select prefetches that mark the memory as exclusive. More... | |
struct | ImplementationT |
This class identifies the specific implementation Vc uses in the current translation unit in terms of a type. More... | |
class | Mask |
The main SIMD mask class. More... | |
struct | Prefetch |
struct | Shared |
Hint for Prefetch to select prefetches that mark the memory as shared. More... | |
class | SimdArray |
Data-parallel arithmetic type with user-defined number of elements. More... | |
class | SimdMaskArray |
Data-parallel mask type with user-defined number of boolean elements. More... | |
class | Vector |
The main vector class for expressing data parallelism. More... | |
Typedefs | |
using | CurrentImplementation = ImplementationT< > |
Identifies the Vc implementation used in the current translation unit. More... | |
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... | |
using | VectorAlignedBase = AlignedBase< Detail::max(alignof(Vector< float >), alignof(Vector< double >), alignof(Vector< ullong >), alignof(Vector< llong >), alignof(Vector< ulong >), alignof(Vector< long >), alignof(Vector< uint >), alignof(Vector< int >), alignof(Vector< ushort >), alignof(Vector< short >), alignof(Vector< uchar >), alignof(Vector< schar >))> |
Helper type to ensure suitable alignment for any Vc::Vector<T> type (using the default VectorAbi). More... | |
template<typename V > | |
using | VectorAlignedBaseT = AlignedBase< alignof(V)> |
Variant of the above type ensuring suitable alignment only for the specified vector type V . More... | |
using | MemoryAlignedBase = AlignedBase< Detail::max(Vector< float >::MemoryAlignment, Vector< double >::MemoryAlignment, Vector< ullong >::MemoryAlignment, Vector< llong >::MemoryAlignment, Vector< ulong >::MemoryAlignment, Vector< long >::MemoryAlignment, Vector< uint >::MemoryAlignment, Vector< int >::MemoryAlignment, Vector< ushort >::MemoryAlignment, Vector< short >::MemoryAlignment, Vector< uchar >::MemoryAlignment, Vector< schar >::MemoryAlignment)> |
Helper class to ensure suitable alignment for arrays of scalar objects for any Vc::Vector<T> type (using the default VectorAbi). More... | |
template<typename V > | |
using | MemoryAlignedBaseT = AlignedBase< V::MemoryAlignment > |
Variant of the above type ensuring suitable alignment only for the specified vector type V . More... | |
typedef UnalignedTag | DefaultLoadTag |
The default load tag type uses unaligned (non-streaming) loads. | |
typedef UnalignedTag | DefaultStoreTag |
The default store tag type uses unaligned (non-streaming) stores. | |
template<typename T , size_t N = 0, typename MT = void> | |
using | simdize = SimdizeDetail::simdize< T, N, MT > |
using | llong = long long |
long long shorthand | |
using | ullong = unsigned long long |
unsigned long long shorthand | |
using | ulong = unsigned long |
unsigned long shorthand | |
using | uint = unsigned int |
unsigned int shorthand | |
using | ushort = unsigned short |
unsigned short shorthand | |
using | uchar = unsigned char |
unsigned char shorthand | |
using | schar = signed char |
signed char shorthand | |
Vector Type Aliases | |
using | double_v = Vector< double > |
vector of double precision | |
using | float_v = Vector< float > |
vector of single precision | |
using | int_v = Vector< int > |
vector of signed integers | |
using | uint_v = Vector< uint > |
vector of unsigned integers | |
using | short_v = Vector< short > |
vector of signed short integers | |
using | ushort_v = Vector< ushort > |
vector of unsigned short integers | |
using | llong_v = Vector< llong > |
using | ullong_v = Vector< ullong > |
using | long_v = Vector< long > |
using | ulong_v = Vector< ulong > |
using | schar_v = Vector< schar > |
using | uchar_v = Vector< uchar > |
Mask Type Aliases | |
using | double_m = Mask< double > |
mask type for double_v vectors | |
using | float_m = Mask< float > |
mask type for float_v vectors | |
using | llong_m = Mask< llong > |
using | ullong_m = Mask< ullong > |
using | long_m = Mask< long > |
using | ulong_m = Mask< ulong > |
using | int_m = Mask< int > |
mask type for int_v vectors | |
using | uint_m = Mask< uint > |
mask type for uint_v vectors | |
using | short_m = Mask< short > |
mask type for short_v vectors | |
using | ushort_m = Mask< ushort > |
mask type for ushort_v vectors | |
using | schar_m = Mask< schar > |
using | uchar_m = Mask< uchar > |
Enumerations | |
enum | MallocAlignment { AlignOnVector, AlignOnCacheline, AlignOnPage } |
Enum that specifies the alignment and padding restrictions to use for memory allocation with Vc::malloc. More... | |
enum | Implementation : std::uint_least32_t { ScalarImpl, SSE2Impl, SSE3Impl, SSSE3Impl, SSE41Impl, SSE42Impl, AVXImpl, AVX2Impl, MICImpl } |
Enum to identify a certain SIMD instruction set. More... | |
enum | ExtraInstructions : std::uint_least32_t { Float16cInstructions = 0x01000, Fma4Instructions = 0x02000, XopInstructions = 0x04000, PopcntInstructions = 0x08000, Sse4aInstructions = 0x10000, FmaInstructions = 0x20000, VexInstructions = 0x40000, Bmi2Instructions = 0x80000 } |
The list of available instructions is not easily described by a linear list of instruction sets. More... | |
Functions | |
const char * | versionString () |
constexpr unsigned int | versionNumber () |
template<typename T , typename Abi > | |
std::ostream & | operator<< (std::ostream &out, const Vc::Vector< T, Abi > &v) |
Prints the contents of a vector into a stream object. More... | |
template<typename T , typename Abi > | |
std::ostream & | operator<< (std::ostream &out, const Vc::Mask< T, Abi > &m) |
Prints the contents of a mask into a stream object. More... | |
Vc::Vector< T > | sqrt (const Vc::Vector< T > &v) |
Returns the square root of v . | |
Vc::Vector< T > | rsqrt (const Vc::Vector< T > &v) |
Returns the reciprocal square root of v . | |
Vc::Vector< T > | reciprocal (const Vc::Vector< T > &v) |
Returns the reciprocal of v . | |
Vc::Vector< T > | abs (const Vc::Vector< T > &v) |
Returns the absolute value of v . | |
Vc::Vector< T > | round (const Vc::Vector< T > &v) |
Returns the closest integer to v ; 0.5 is rounded to even. | |
Vc::Vector< T > | log (const Vc::Vector< T > &v) |
Vc::Vector< T > | log2 (const Vc::Vector< T > &v) |
Vc::Vector< T > | log10 (const Vc::Vector< T > &v) |
Vc::Vector< T > | exp (const Vc::Vector< T > &v) |
Vc::Vector< T > | sin (const Vc::Vector< T > &v) |
Vc::Vector< T > | cos (const Vc::Vector< T > &v) |
Vc::Vector< T > | asin (const Vc::Vector< T > &v) |
Vc::Vector< T > | atan (const Vc::Vector< T > &v) |
Vc::Vector< T > | atan2 (const Vc::Vector< T > &y, const Vc::Vector< T > &x) |
Calculates the angle given the lengths of the opposite and adjacent legs in a right triangle. More... | |
Vc::Vector< T > | min (const Vc::Vector< T > &x, const Vc::Vector< T > &y) |
Vc::Vector< T > | max (const Vc::Vector< T > &x, const Vc::Vector< T > &y) |
Vc::Vector< T > | frexp (const Vc::Vector< T > &x, Vc::SimdArray< int, size()> *e) |
Convert floating-point number to fractional and integral components. More... | |
Vc::Vector< T > | ldexp (Vc::Vector< T > x, Vc::SimdArray< int, size()> e) |
Multiply floating-point number by integral power of 2. More... | |
Vc::Mask< T > | isfinite (const Vc::Vector< T > &x) |
Vc::Mask< T > | isnan (const Vc::Vector< T > &x) |
Vc::Vector< T > | fma (Vc::Vector< T > a, Vc::Vector< T > b, Vc::Vector< T > c) |
Multiplies a with b and then adds c , without rounding between the multiplication and the addition. More... | |
template<typename V , typename M , typename A > | |
void | deinterleave (V *a, V *b, const M *memory, A align) |
template<typename Mask , typename T > | |
enable_if< is_simd_mask< Mask >::value &&is_simd_vector< T >::value, T > | iif (const Mask &condition, const T &trueValue, const T &falseValue) |
Function to mimic the ternary operator '?:' (inline-if). More... | |
template<typename Mask , typename T > | |
enable_if< is_simd_mask< Mask >::value &&!is_simd_vector< T >::value, T > | iif (const Mask &, const T &, const T &)=delete |
Function to mimic the ternary operator '?:' (inline-if). More... | |
template<typename T > | |
constexpr T | iif (bool condition, const T &trueValue, const T &falseValue) |
Overload of the above for boolean conditions. More... | |
template<typename V , typename = enable_if<Traits::is_simd_vector<V>::value>> | |
std::pair< V, V > | interleave (const V &a, const V &b) |
Interleaves the entries from a and b into two vectors of the same type. More... | |
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... | |
template<typename T , Vc::MallocAlignment A> | |
T * | malloc (size_t n) |
Allocates memory on the Heap with alignment and padding suitable for vectorized access. More... | |
template<typename T > | |
void | free (T *p) |
Frees memory that was allocated with Vc::malloc. More... | |
template<typename To , typename From > | |
To | simd_cast (From &&x, enable_if< std::is_same< To, Traits::decay< From >>::value >=nullarg) |
Casts the argument x from type From to type To . More... | |
template<typename To > | |
To | simd_cast () |
A cast from nothing results in default-initialization of To . More... | |
template<typename T , typename Abi , typename = enable_if<std::is_floating_point<T>::value>> | |
Vector< T, Abi > | copysign (Vector< T, Abi > magnitude, Vector< T, Abi > sign) |
Copies the sign(s) of sign to the value(s) in magnitude and returns the resulting vector. More... | |
template<typename T , typename Abi , typename = enable_if<std::is_floating_point<T>::value>> | |
Vector< T, Abi > | exponent (Vector< T, Abi > x) |
Extracts the exponent of each floating-point vector component. More... | |
template<typename T , typename Abi > | |
Vector< T, Abi >::MaskType | isnegative (Vector< T, Abi > x) |
Returns for each vector component whether it stores a negative value. More... | |
template<typename V , typename T , typename Abi > | |
enable_if< (V::size()==Vector< T, Abi >::size()&&sizeof(typename V::VectorEntryType)==sizeof(typename Vector< T, Abi >::VectorEntryType)&&sizeof(V)==sizeof(Vector< T, Abi >)&&alignof(V)<=alignof(Vector< T, Abi >)), V > | reinterpret_components_cast (const Vector< T, Abi > &x) |
Constructs a new Vector object of type V from the Vector x , reinterpreting the bits of x for the new type V . More... | |
template<typename M > | |
constexpr WhereImpl::WhereMask< M > | where (const M &mask) |
Conditional assignment. More... | |
Micro-Architecture Feature Tests | |
unsigned int | extraInstructionsSupported () |
Determines the extra instructions supported by the current CPU. More... | |
bool | isImplementationSupported (Vc::Implementation impl) |
Tests whether the given implementation is supported by the system the code is executing on. More... | |
Vc::Implementation | bestImplementationSupported () |
Determines the best supported implementation for the current system. More... | |
bool | currentImplementationSupported () |
Tests that the CPU and Operating System support the vector unit which was compiled for. More... | |
non-member begin & end | |
Implement the non-member begin & end functions in the Vc namespace so that ADL works and | |
template<typename T , std::size_t N> | |
auto | begin (array< T, N > &arr) -> decltype(arr.begin()) |
template<typename T , std::size_t N> | |
auto | begin (const array< T, N > &arr) -> decltype(arr.begin()) |
template<typename T , std::size_t N> | |
auto | end (array< T, N > &arr) -> decltype(arr.end()) |
template<typename T , std::size_t N> | |
auto | end (const array< T, N > &arr) -> decltype(arr.end()) |
Boolean Reductions | |
template<typename Mask > | |
constexpr bool | all_of (const Mask &m) |
Returns whether all entries in the mask m are true . | |
constexpr bool | all_of (bool b) |
Returns b . | |
template<typename Mask > | |
constexpr bool | any_of (const Mask &m) |
Returns whether at least one entry in the mask m is true . | |
constexpr bool | any_of (bool b) |
Returns b . | |
template<typename Mask > | |
constexpr bool | none_of (const Mask &m) |
Returns whether all entries in the mask m are false . | |
constexpr bool | none_of (bool b) |
Returns !b . | |
template<typename Mask > | |
constexpr bool | some_of (const Mask &m) |
Returns whether at least one entry in m is true and at least one entry in m is false . | |
constexpr bool | some_of (bool) |
Returns false . | |
Math functions | |
These functions evaluate the | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | min (const SimdArray< T, N, V, M > &x, const SimdArray< T, N, V, M > &y) |
Applies the std:: min function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | max (const SimdArray< T, N, V, M > &x, const SimdArray< T, N, V, M > &y) |
Applies the std:: max function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | abs (const SimdArray< T, N, V, M > &x) |
Applies the std:: abs function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | asin (const SimdArray< T, N, V, M > &x) |
Applies the std:: asin function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | atan (const SimdArray< T, N, V, M > &x) |
Applies the std:: atan function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | atan2 (const SimdArray< T, N, V, M > &x, const SimdArray< T, N, V, M > &y) |
Applies the std:: atan2 function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | ceil (const SimdArray< T, N, V, M > &x) |
Applies the std:: ceil function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | copysign (const SimdArray< T, N, V, M > &x, const SimdArray< T, N, V, M > &y) |
Applies the std:: copysign function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | cos (const SimdArray< T, N, V, M > &x) |
Applies the std:: cos function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | exp (const SimdArray< T, N, V, M > &x) |
Applies the std:: exp function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | exponent (const SimdArray< T, N, V, M > &x) |
Applies the std:: exponent function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | floor (const SimdArray< T, N, V, M > &x) |
Applies the std:: floor function component-wise and concurrently. | |
template<typename T , std::size_t N> | |
SimdArray< T, N > | fma (const SimdArray< T, N > &a, const SimdArray< T, N > &b, const SimdArray< T, N > &c) |
Applies the std::fma function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdMaskArray< T, N, V, M > | isfinite (const SimdArray< T, N, V, M > &x) |
Applies the std:: isfinite function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdMaskArray< T, N, V, M > | isinf (const SimdArray< T, N, V, M > &x) |
Applies the std:: isinf function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdMaskArray< T, N, V, M > | isnan (const SimdArray< T, N, V, M > &x) |
Applies the std:: isnan function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdMaskArray< T, N, V, M > | isnegative (const SimdArray< T, N, V, M > &x) |
Applies the std:: isnegative function component-wise and concurrently. | |
template<typename T , std::size_t N> | |
SimdArray< T, N > | frexp (const SimdArray< T, N > &x, SimdArray< int, N > *e) |
Applies the std::frexp function component-wise and concurrently. | |
template<typename T , std::size_t N> | |
SimdArray< T, N > | ldexp (const SimdArray< T, N > &x, const SimdArray< int, N > &e) |
Applies the std::ldexp function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | log (const SimdArray< T, N, V, M > &x) |
Applies the std:: log function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | log10 (const SimdArray< T, N, V, M > &x) |
Applies the std:: log10 function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | log2 (const SimdArray< T, N, V, M > &x) |
Applies the std:: log2 function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | reciprocal (const SimdArray< T, N, V, M > &x) |
Applies the std:: reciprocal function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | round (const SimdArray< T, N, V, M > &x) |
Applies the std:: round function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | rsqrt (const SimdArray< T, N, V, M > &x) |
Applies the std:: rsqrt function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | sin (const SimdArray< T, N, V, M > &x) |
Applies the std:: sin function component-wise and concurrently. | |
template<typename T , std::size_t N> | |
void | sincos (const SimdArray< T, N > &x, SimdArray< T, N > *sin, SimdArray< T, N > *cos) |
Determines sine and cosine concurrently and component-wise on x . | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | sqrt (const SimdArray< T, N, V, M > &x) |
Applies the std:: sqrt function component-wise and concurrently. | |
template<typename T , std::size_t N, typename V , std::size_t M> | |
SimdArray< T, N, V, M > | trunc (const SimdArray< T, N, V, M > &x) |
Applies the std:: trunc function component-wise and concurrently. | |
Arithmetic and Bitwise Operators | |
Applies the operator component-wise and concurrently on This operator only participates in overload resolution if:
The return type of the operator is a SimdArray type using the more precise EntryType of | |
template<typename L , typename R > | |
result_vector_type< L, R > | operator+ (L &&lhs, R &&rhs) |
Applies + component-wise and concurrently. | |
template<typename L , typename R > | |
result_vector_type< L, R > | operator- (L &&lhs, R &&rhs) |
Applies - component-wise and concurrently. | |
template<typename L , typename R > | |
result_vector_type< L, R > | operator* (L &&lhs, R &&rhs) |
Applies * component-wise and concurrently. | |
template<typename L , typename R > | |
result_vector_type< L, R > | operator/ (L &&lhs, R &&rhs) |
Applies / component-wise and concurrently. | |
template<typename L , typename R > | |
result_vector_type< L, R > | operator% (L &&lhs, R &&rhs) |
Applies % component-wise and concurrently. | |
template<typename L , typename R > | |
result_vector_type< L, R > | operator| (L &&lhs, R &&rhs) |
Applies | component-wise and concurrently. | |
template<typename L , typename R > | |
result_vector_type< L, R > | operator& (L &&lhs, R &&rhs) |
Applies & component-wise and concurrently. | |
template<typename L , typename R > | |
result_vector_type< L, R > | operator^ (L &&lhs, R &&rhs) |
Applies ^ component-wise and concurrently. | |
Compare Operators | |
Applies the operator component-wise and concurrently on This operator only participates in overload resolution if (same rules as above):
The return type of the operator is a SimdMaskArray type using the more precise EntryType of | |
template<typename L , typename R > | |
result_vector_type< L, R >::mask_type | operator== (L &&lhs, R &&rhs) |
Applies == component-wise and concurrently. | |
template<typename L , typename R > | |
result_vector_type< L, R >::mask_type | operator!= (L &&lhs, R &&rhs) |
Applies != component-wise and concurrently. | |
template<typename L , typename R > | |
result_vector_type< L, R >::mask_type | operator<= (L &&lhs, R &&rhs) |
Applies <= component-wise and concurrently. | |
template<typename L , typename R > | |
result_vector_type< L, R >::mask_type | operator>= (L &&lhs, R &&rhs) |
Applies >= component-wise and concurrently. | |
template<typename L , typename R > | |
result_vector_type< L, R >::mask_type | operator< (L &&lhs, R &&rhs) |
Applies < component-wise and concurrently. | |
template<typename L , typename R > | |
result_vector_type< L, R >::mask_type | operator> (L &&lhs, R &&rhs) |
Applies > component-wise and concurrently. | |
Variables | |
constexpr std::size_t | VectorAlignment = alignof(VectorAlignedBase) |
Specifies the most conservative memory alignment necessary for Vector<T> objects with default VectorAbi. More... | |
constexpr std::size_t | MemoryAlignment = alignof(MemoryAlignedBase) |
Specifies the most conservative memory alignment necessary for aligned loads and stores of Vector types. More... | |
constexpr AlignedTag | Aligned |
Use this object for a flags parameter to request aligned loads and stores. More... | |
constexpr UnalignedTag | Unaligned |
Use this object for a flags parameter to request unaligned loads and stores. More... | |
constexpr StreamingTag | Streaming |
Use this object for a flags parameter to request streaming loads and stores. More... | |
constexpr LoadStoreFlags::LoadStoreFlags< PrefetchFlag<> > | PrefetchDefault |
Use this object for a flags parameter to request default software prefetches to be emitted. | |
constexpr VectorSpecialInitializerZero | Zero = {} |
The special object Vc::Zero can be used to construct Vector and Mask objects initialized to zero/false . | |
constexpr VectorSpecialInitializerOne | One = {} |
The special object Vc::One can be used to construct Vector and Mask objects initialized to one/true . | |
constexpr VectorSpecialInitializerIndexesFromZero | IndexesFromZero = {} |
The special object Vc::IndexesFromZero can be used to construct Vector objects initialized to values 0, 1, 2, 3, 4, ... | |
|
inline |
Casts the argument x
from type From
to type To
.
This function implements the trivial case where To
and From
are the same type.
x | The object of type From to be converted to type To . |
To
with all vector components converted according to standard conversion behavior as mandated by the C++ standard for the underlying arithmetic types. Definition at line 52 of file simd_cast.h.
|
inline |
A cast from nothing results in default-initialization of To
.
This function can be useful in generic code where a parameter pack expands to nothing.
To
. Definition at line 64 of file simd_cast.h.