Vc  1.1.0
SIMD Vector Classes for C++
Vc Namespace Reference

Detailed Description

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 type with (somewhat) arbitrary number of components. 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 >
enable_if< std::is_same< To, Traits::decay< From > >::value, To > simd_cast (From &&x)
 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 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 begin(some_vc_array) always works.

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.
 

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

Function Documentation

enable_if<std::is_same<To, Traits::decay<From> >::value, To> Vc::simd_cast ( From &&  x)
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.

Parameters
xThe object of type From to be converted to type To.
Returns
An object of type 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 49 of file simd_cast.h.

Referenced by simd_cast(), and SimdArray< T, N, VectorType, size_t >::SimdArray().

To Vc::simd_cast ( )
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.

Returns
A zero-initialized object of type To.

Definition at line 61 of file simd_cast.h.