T-SIMD v31.1.0
A C++ template SIMD library
Loading...
Searching...
No Matches
Type Conversions

Description

Functions for converting Vec's between different types.

Functions

template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static void simd::convert (const Vec< Tin, SIMD_WIDTH > inVecs[numInVecs< Tout, Tin >()], Vec< Tout, SIMD_WIDTH > outVecs[numOutVecs< Tout, Tin >()])
 Converts (potentially multiple) Vec's between different types.
 
template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static Vec< Tout, SIMD_WIDTH > simd::cvts (const Vec< Tin, SIMD_WIDTH > &a)
 Converts the elements of a Vec between integer and floating point types of the same size.
 
template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static void simd::extend (const Vec< Tin, SIMD_WIDTH > &vIn, Vec< Tout, SIMD_WIDTH > vOut[sizeof(Tout)/sizeof(Tin)])
 Extends the elements of a Vec to a larger or equally sized type.
 
template<typename Tout , typename Tin >
static constexpr size_t simd::numInVecs ()
 Number of input vectors for functions that potentially change the size of the elements but not the number of elements.
 
template<typename Tout , typename Tin >
static constexpr size_t simd::numOutVecs ()
 Number of output vectors for functions that potentially change the size of the elements but not the number of elements.
 
template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static constexpr size_t simd::numSIMDVecsElements ()
 Number of elements in all input vectors for functions that potentially change the size of the elements but not the number of elements.
 
template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static Vec< Tout, SIMD_WIDTH > simd::packs (const Vec< Tin, SIMD_WIDTH > &a, const Vec< Tin, SIMD_WIDTH > &b)
 Packs two Vec's into one by converting the elements into the next smaller type with saturation.
 
template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static Vec< Tout, SIMD_WIDTH > simd::packs (const Vec< Tin, SIMD_WIDTH > a[sizeof(Tin)/sizeof(Tout)])
 Packs multiple Vec's into a single Vec by converting the elements into smaller or equally sized types.
 
template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static Vec< Tout, SIMD_WIDTH > simd::reinterpret (const Vec< Tin, SIMD_WIDTH > &a)
 Reinterprets a given Vec as a Vec with a different element type.
 

Function Documentation

◆ convert()

template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static void simd::convert ( const Vec< Tin, SIMD_WIDTH > inVecs[numInVecs< Tout, Tin >()],
Vec< Tout, SIMD_WIDTH > outVecs[numOutVecs< Tout, Tin >()] )
inlinestatic

Converts (potentially multiple) Vec's between different types.

Combines extend() and packs().

TODO: allowed types

If the input and output types are of the same size, both the input and output are just one Vec. If the types are of different sizes, the input or output consists of multiple Vec's, such that the number of input elements is equal to the number of output elements.

See also
extend()
packs()
Template Parameters
Toutelement type of the output Vec's
Tinelement type of the input Vec's
Parameters
[in]inVecsinput Vec's
[out]outVecsoutput Vec's

◆ cvts()

template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static Vec< Tout, SIMD_WIDTH > simd::cvts ( const Vec< Tin, SIMD_WIDTH > & a)
inlinestatic

Converts the elements of a Vec between integer and floating point types of the same size.

The conversion from floating point type to integer is saturated.

Template Parameters
Touttype of the resulting Vec, must be the same size as Tin and must be a floating point type if Tin is an integer type, and vice versa
Tintype of the input Vec, must be the same size as Tout and must be a floating point type if Tout is an integer type, and vice versa
Parameters
ainput Vec

◆ extend()

template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static void simd::extend ( const Vec< Tin, SIMD_WIDTH > & vIn,
Vec< Tout, SIMD_WIDTH > vOut[sizeof(Tout)/sizeof(Tin)] )
inlinestatic

Extends the elements of a Vec to a larger or equally sized type.

The values are zero-extended or sign-extended, depending on the type.

When converting from a signed to an unsigned type, negative values are saturated to zero.

Multiple output Vec's are produced, where the amount of output Vec's is sizeof(Tout) / sizeof(Tin).

See also
packs()
Template Parameters
Touttype to extend to
Tintype to extend from
Parameters
vIninput Vec
[out]vOutoutput Vec's

◆ numInVecs()

template<typename Tout , typename Tin >
static constexpr size_t simd::numInVecs ( )
inlinestaticconstexpr

Number of input vectors for functions that potentially change the size of the elements but not the number of elements.

Template Parameters
Toutoutput type
Tininput type
Returns
number of input vectors

◆ numOutVecs()

template<typename Tout , typename Tin >
static constexpr size_t simd::numOutVecs ( )
inlinestaticconstexpr

Number of output vectors for functions that potentially change the size of the elements but not the number of elements.

Template Parameters
Toutoutput type
Tininput type
Returns
number of output vectors

◆ numSIMDVecsElements()

template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static constexpr size_t simd::numSIMDVecsElements ( )
inlinestaticconstexpr

Number of elements in all input vectors for functions that potentially change the size of the elements but not the number of elements.

Template Parameters
Toutoutput type
Tininput type
Returns
number of elements in all input vectors

◆ packs() [1/2]

template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static Vec< Tout, SIMD_WIDTH > simd::packs ( const Vec< Tin, SIMD_WIDTH > & a,
const Vec< Tin, SIMD_WIDTH > & b )
inlinestatic

Packs two Vec's into one by converting the elements into the next smaller type with saturation.

Float is converted to an integer type, as there is no 16-bit floating point type.

See also
extend()
Template Parameters
Touttype of the resulting Vec, must be the next smaller type of the elements of the input Vec's
Tintype of the input Vec's
Parameters
a,bThe input Vec's.
Returns
Vec with the elements of a and b packed into one

◆ packs() [2/2]

template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static Vec< Tout, SIMD_WIDTH > simd::packs ( const Vec< Tin, SIMD_WIDTH > a[sizeof(Tin)/sizeof(Tout)])
inlinestatic

Packs multiple Vec's into a single Vec by converting the elements into smaller or equally sized types.

TODO: allowed types

In contrast to packs(const Vec<Tin, SIMD_WIDTH>&, const Vec<Tin, SIMD_WIDTH>&), this function can handle multistage packing, i.e. the number of input can be different from 2.

See also
packs(const Vec<Tin, SIMD_WIDTH>&, const Vec<Tin, SIMD_WIDTH>&)
Template Parameters
Touttype of the resulting Vec
Tintype of the input Vec's
Parameters
[in]aarray of input Vec's
Returns
Vec with the packed elements

◆ reinterpret()

template<typename Tout , typename Tin , size_t SIMD_WIDTH>
static Vec< Tout, SIMD_WIDTH > simd::reinterpret ( const Vec< Tin, SIMD_WIDTH > & a)
inlinestatic

Reinterprets a given Vec as a Vec with a different element type.

Template Parameters
Toutelement type of the resulting Vec
Tinelement type of the given Vec
Parameters
aVec to reinterpret
Returns
reinterpreted Vec