HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
simd::vint4 Class Reference

Integer 4-vector, accelerated by SIMD instructions when available. More...

#include <simd.h>

Public Types

enum  { elements = 4 }
 
enum  { paddedelements =4 }
 
enum  { bits = 128 }
 
typedef int value_t
 Underlying equivalent scalar value type. More...
 
typedef simd_raw_t< int,
elements >::type 
simd_t
 the native SIMD type used More...
 
typedef vbool4 vbool_t
 bool type of the same length More...
 
typedef vfloat4 vfloat_t
 float type of the same length More...
 
typedef vint4 vint_t
 int type of the same length More...
 
typedef vbool4 bool_t
 
typedef vfloat4 float_t
 

Public Member Functions

 vint4 ()
 Default constructor (contents undefined) More...
 
 vint4 (int a)
 Construct from a single value (store it in all slots) More...
 
 vint4 (int a, int b)
 Construct from 2 values – (a,a,b,b) More...
 
 vint4 (int a, int b, int c, int d)
 Construct from 4 values. More...
 
 vint4 (const int *vals)
 Construct from a pointer to values. More...
 
 vint4 (const unsigned short *vals)
 Construct from a pointer to unsigned short values. More...
 
 vint4 (const short *vals)
 Construct from a pointer to signed short values. More...
 
 vint4 (const unsigned char *vals)
 Construct from a pointer to unsigned char values (0 - 255) More...
 
 vint4 (const char *vals)
 Construct from a pointer to signed char values (-128 - 127) More...
 
 vint4 (const vint4 &other)
 Copy construct from another vint4. More...
 
 vint4 (const vfloat4 &f)
 Convert a vfloat to an vint. Equivalent to i = (int)f;. More...
 
 vint4 (const simd_t &m)
 Construct from the underlying SIMD type. More...
 
 operator simd_t () const
 Return the raw SIMD type. More...
 
simd_t simd () const
 
simd_tsimd ()
 
const value_tdata () const
 Return a pointer to the underlying scalar type. More...
 
value_tdata ()
 
void clear ()
 Sset all components to 0. More...
 
const vint4operator= (int a)
 Assign one value to all components. More...
 
const vint4operator= (const vint4 &other)
 Assignment from another vint4. More...
 
int operator[] (int i) const
 Component access (get) More...
 
intoperator[] (int i)
 Component access (set) More...
 
void setcomp (int i, int value)
 Component access (set). More...
 
value_t x () const
 
value_t y () const
 
value_t z () const
 
value_t w () const
 
void set_x (value_t val)
 
void set_y (value_t val)
 
void set_z (value_t val)
 
void set_w (value_t val)
 
void load (int a)
 Helper: load a single int into all components. More...
 
void load (int a, int b, int c, int d)
 Helper: load separate values into each component. More...
 
void load (const int *values)
 Load from an array of 4 values. More...
 
void load (const int *values, int n)
 
void load (const unsigned short *values)
 Load from an array of 4 unsigned short values, convert to vint4. More...
 
void load (const short *values)
 Load from an array of 4 unsigned short values, convert to vint4. More...
 
void load (const unsigned char *values)
 Load from an array of 4 unsigned char values, convert to vint4. More...
 
void load (const char *values)
 Load from an array of 4 unsigned char values, convert to vint4. More...
 
void store (int *values) const
 Store the values into memory. More...
 
void store (int *values, int n) const
 Store the first n values into memory. More...
 
void store (unsigned short *values) const
 
void store (unsigned char *values) const
 
void load_mask (int mask, const value_t *values)
 
void load_mask (const vbool_t &mask, const value_t *values)
 
void store_mask (int mask, value_t *values) const
 
void store_mask (const vbool_t &mask, value_t *values) const
 
template<int scale = 4>
void gather (const value_t *baseptr, const vint_t &vindex)
 Load values from addresses (char*)basepatr + vindex[i]*scale. More...
 
template<int scale = 4>
void gather_mask (const vbool_t &mask, const value_t *baseptr, const vint_t &vindex)
 Gather elements defined by the mask, leave others unchanged. More...
 
template<int scale = 4>
void gather_mask (int mask, const value_t *baseptr, const vint_t &vindex)
 
template<int scale = 4>
void scatter (value_t *baseptr, const vint_t &vindex) const
 Store values at addresses (char*)basepatr + vindex[i]*scale. More...
 
template<int scale = 4>
void scatter_mask (const vbool_t &mask, value_t *baseptr, const vint_t &vindex) const
 Scatter elements defined by the mask. More...
 
template<int scale = 4>
void scatter_mask (int mask, value_t *baseptr, const vint_t &vindex) const
 
template<int scale>
OIIO_FORCEINLINE void gather (const value_t *baseptr, const vint_t &vindex)
 
template<int scale>
OIIO_FORCEINLINE void gather_mask (const vbool_t &mask, const value_t *baseptr, const vint_t &vindex)
 
template<int scale>
OIIO_FORCEINLINE void scatter (value_t *baseptr, const vint_t &vindex) const
 
template<int scale>
OIIO_FORCEINLINE void scatter_mask (const vbool_t &mask, value_t *baseptr, const vint_t &vindex) const
 

Static Public Member Functions

static const char * type_name ()
 
static constexpr size_t size () noexcept
 
static const vint4 Zero ()
 Return an vint4 with all components set to 0. More...
 
static const vint4 One ()
 Return an vint4 with all components set to 1. More...
 
static const vint4 NegOne ()
 Return an vint4 with all components set to -1 (aka 0xffffffff) More...
 
static const vint4 Iota (int start=0, int step=1)
 
static const vint4 Giota ()
 Return an vint4 with "geometric" iota: (1, 2, 4, 8). More...
 

Friends

vint4 operator+ (const vint4 &a, const vint4 &b)
 
vint4 operator- (const vint4 &a)
 
vint4 operator- (const vint4 &a, const vint4 &b)
 
vint4 operator* (const vint4 &a, const vint4 &b)
 
vint4 operator/ (const vint4 &a, const vint4 &b)
 
vint4 operator% (const vint4 &a, const vint4 &b)
 
const vint4operator+= (vint4 &a, const vint4 &b)
 
const vint4operator-= (vint4 &a, const vint4 &b)
 
const vint4operator*= (vint4 &a, const vint4 &b)
 
const vint4operator/= (vint4 &a, const vint4 &b)
 
const vint4operator%= (vint4 &a, const vint4 &b)
 
vint4 operator& (const vint4 &a, const vint4 &b)
 
vint4 operator| (const vint4 &a, const vint4 &b)
 
vint4 operator^ (const vint4 &a, const vint4 &b)
 
const vint4operator&= (vint4 &a, const vint4 &b)
 
const vint4operator|= (vint4 &a, const vint4 &b)
 
const vint4operator^= (vint4 &a, const vint4 &b)
 
vint4 operator~ (const vint4 &a)
 
vint4 operator<< (const vint4 &a, unsigned int bits)
 
vint4 operator>> (const vint4 &a, unsigned int bits)
 
const vint4operator<<= (vint4 &a, unsigned int bits)
 
const vint4operator>>= (vint4 &a, unsigned int bits)
 
vbool4 operator== (const vint4 &a, const vint4 &b)
 
vbool4 operator!= (const vint4 &a, const vint4 &b)
 
vbool4 operator< (const vint4 &a, const vint4 &b)
 
vbool4 operator> (const vint4 &a, const vint4 &b)
 
vbool4 operator>= (const vint4 &a, const vint4 &b)
 
vbool4 operator<= (const vint4 &a, const vint4 &b)
 
std::ostream & operator<< (std::ostream &cout, const vint4 &a)
 Stream output. More...
 

Detailed Description

Integer 4-vector, accelerated by SIMD instructions when available.

Definition at line 958 of file simd.h.

Member Typedef Documentation

Definition at line 970 of file simd.h.

Definition at line 972 of file simd.h.

the native SIMD type used

Definition at line 965 of file simd.h.

Underlying equivalent scalar value type.

Definition at line 961 of file simd.h.

bool type of the same length

Definition at line 966 of file simd.h.

float type of the same length

Definition at line 967 of file simd.h.

int type of the same length

Definition at line 968 of file simd.h.

Member Enumeration Documentation

anonymous enum
Enumerator
elements 

Definition at line 962 of file simd.h.

anonymous enum
Enumerator
paddedelements 

Definition at line 963 of file simd.h.

anonymous enum
Enumerator
bits 

Definition at line 964 of file simd.h.

Constructor & Destructor Documentation

simd::vint4::vint4 ( )
inline

Default constructor (contents undefined)

Definition at line 976 of file simd.h.

OIIO_FORCEINLINE simd::vint4::vint4 ( int  a)

Construct from a single value (store it in all slots)

Definition at line 4328 of file simd.h.

OIIO_FORCEINLINE simd::vint4::vint4 ( int  a,
int  b 
)

Construct from 2 values – (a,a,b,b)

Definition at line 4330 of file simd.h.

OIIO_FORCEINLINE simd::vint4::vint4 ( int  a,
int  b,
int  c,
int  d 
)

Construct from 4 values.

Definition at line 4332 of file simd.h.

OIIO_FORCEINLINE simd::vint4::vint4 ( const int vals)

Construct from a pointer to values.

Definition at line 4339 of file simd.h.

OIIO_FORCEINLINE simd::vint4::vint4 ( const unsigned short *  vals)
explicit

Construct from a pointer to unsigned short values.

Definition at line 4340 of file simd.h.

OIIO_FORCEINLINE simd::vint4::vint4 ( const short *  vals)
explicit

Construct from a pointer to signed short values.

Definition at line 4341 of file simd.h.

OIIO_FORCEINLINE simd::vint4::vint4 ( const unsigned char *  vals)
explicit

Construct from a pointer to unsigned char values (0 - 255)

Definition at line 4342 of file simd.h.

OIIO_FORCEINLINE simd::vint4::vint4 ( const char *  vals)
explicit

Construct from a pointer to signed char values (-128 - 127)

Definition at line 4343 of file simd.h.

simd::vint4::vint4 ( const vint4 other)
inline

Copy construct from another vint4.

Definition at line 1003 of file simd.h.

OIIO_FORCEINLINE simd::vint4::vint4 ( const vfloat4 f)
explicit

Convert a vfloat to an vint. Equivalent to i = (int)f;.

Definition at line 7325 of file simd.h.

simd::vint4::vint4 ( const simd_t m)
inline

Construct from the underlying SIMD type.

Definition at line 1009 of file simd.h.

Member Function Documentation

OIIO_FORCEINLINE void simd::vint4::clear ( )

Sset all components to 0.

Definition at line 4454 of file simd.h.

const value_t* simd::vint4::data ( ) const
inline

Return a pointer to the underlying scalar type.

Definition at line 1017 of file simd.h.

value_t* simd::vint4::data ( )
inline

Definition at line 1018 of file simd.h.

template<int scale = 4>
void simd::vint4::gather ( const value_t baseptr,
const vint_t vindex 
)

Load values from addresses (char*)basepatr + vindex[i]*scale.

template<int scale>
OIIO_FORCEINLINE void simd::vint4::gather ( const value_t baseptr,
const vint_t vindex 
)

Definition at line 4408 of file simd.h.

template<int scale = 4>
void simd::vint4::gather_mask ( const vbool_t mask,
const value_t baseptr,
const vint_t vindex 
)

Gather elements defined by the mask, leave others unchanged.

template<int scale = 4>
void simd::vint4::gather_mask ( int  mask,
const value_t baseptr,
const vint_t vindex 
)
template<int scale>
OIIO_FORCEINLINE void simd::vint4::gather_mask ( const vbool_t mask,
const value_t baseptr,
const vint_t vindex 
)

Definition at line 4419 of file simd.h.

OIIO_FORCEINLINE const vint4 simd::vint4::Giota ( )
static

Return an vint4 with "geometric" iota: (1, 2, 4, 8).

Definition at line 4497 of file simd.h.

OIIO_FORCEINLINE const vint4 simd::vint4::Iota ( int  start = 0,
int  step = 1 
)
static

Return an vint4 with incremented components (e.g., 0,1,2,3). Optional arguments can give a non-zero starting point and step size.

Definition at line 4492 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::load ( int  a)

Helper: load a single int into all components.

Definition at line 4198 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::load ( int  a,
int  b,
int  c,
int  d 
)

Helper: load separate values into each component.

Definition at line 4210 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::load ( const int values)

Load from an array of 4 values.

Definition at line 4232 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::load ( const int values,
int  n 
)

Definition at line 4243 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::load ( const unsigned short *  values)

Load from an array of 4 unsigned short values, convert to vint4.

Definition at line 4279 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::load ( const short *  values)

Load from an array of 4 unsigned short values, convert to vint4.

Definition at line 4290 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::load ( const unsigned char *  values)

Load from an array of 4 unsigned char values, convert to vint4.

Definition at line 4301 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::load ( const char *  values)

Load from an array of 4 unsigned char values, convert to vint4.

Definition at line 4317 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::load_mask ( int  mask,
const value_t values 
)

Masked load – read from values[] where mask is 1, load zero where mask is 0.

Definition at line 4362 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::load_mask ( const vbool_t mask,
const value_t values 
)

Definition at line 4373 of file simd.h.

OIIO_FORCEINLINE const vint4 simd::vint4::NegOne ( )
static

Return an vint4 with all components set to -1 (aka 0xffffffff)

Definition at line 4475 of file simd.h.

OIIO_FORCEINLINE const vint4 simd::vint4::One ( )
static

Return an vint4 with all components set to 1.

Definition at line 4473 of file simd.h.

simd::vint4::operator simd_t ( ) const
inline

Return the raw SIMD type.

Definition at line 1012 of file simd.h.

OIIO_FORCEINLINE const vint4 & simd::vint4::operator= ( int  a)

Assign one value to all components.

Definition at line 4345 of file simd.h.

OIIO_FORCEINLINE const vint4 & simd::vint4::operator= ( const vint4 other)

Assignment from another vint4.

Definition at line 4177 of file simd.h.

OIIO_FORCEINLINE int simd::vint4::operator[] ( int  i) const

Component access (get)

Definition at line 4182 of file simd.h.

OIIO_FORCEINLINE int & simd::vint4::operator[] ( int  i)

Component access (set)

Definition at line 4187 of file simd.h.

template<int scale = 4>
void simd::vint4::scatter ( value_t baseptr,
const vint_t vindex 
) const

Store values at addresses (char*)basepatr + vindex[i]*scale.

template<int scale>
OIIO_FORCEINLINE void simd::vint4::scatter ( value_t baseptr,
const vint_t vindex 
) const

Definition at line 4430 of file simd.h.

template<int scale = 4>
void simd::vint4::scatter_mask ( const vbool_t mask,
value_t baseptr,
const vint_t vindex 
) const

Scatter elements defined by the mask.

template<int scale = 4>
void simd::vint4::scatter_mask ( int  mask,
value_t baseptr,
const vint_t vindex 
) const
template<int scale>
OIIO_FORCEINLINE void simd::vint4::scatter_mask ( const vbool_t mask,
value_t baseptr,
const vint_t vindex 
) const

Definition at line 4442 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::set_w ( value_t  val)

Definition at line 4870 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::set_x ( value_t  val)

Definition at line 4867 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::set_y ( value_t  val)

Definition at line 4868 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::set_z ( value_t  val)

Definition at line 4869 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::setcomp ( int  i,
int  value 
)

Component access (set).

Definition at line 4192 of file simd.h.

simd_t simd::vint4::simd ( ) const
inline

Definition at line 1013 of file simd.h.

simd_t& simd::vint4::simd ( )
inline

Definition at line 1014 of file simd.h.

static constexpr size_t simd::vint4::size ( void  )
inlinestaticnoexcept

Definition at line 973 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::store ( int values) const

Store the values into memory.

Definition at line 4348 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::store ( int values,
int  n 
) const

Store the first n values into memory.

Definition at line 4754 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::store ( unsigned short *  values) const

Store the least significant 16 bits of each element into adjacent unsigned shorts.

Definition at line 4776 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::store ( unsigned char *  values) const

Store the least significant 8 bits of each element into adjacent unsigned chars.

Definition at line 4798 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::store_mask ( int  mask,
value_t values 
) const

Masked store – write to values[] where mask is enabled, don't touch values[] where it's not.

Definition at line 4384 of file simd.h.

OIIO_FORCEINLINE void simd::vint4::store_mask ( const vbool_t mask,
value_t values 
) const

Definition at line 4395 of file simd.h.

static const char* simd::vint4::type_name ( )
inlinestatic

Definition at line 960 of file simd.h.

OIIO_FORCEINLINE int simd::vint4::w ( ) const

Definition at line 4866 of file simd.h.

OIIO_FORCEINLINE int simd::vint4::x ( ) const

Definition at line 4863 of file simd.h.

OIIO_FORCEINLINE int simd::vint4::y ( ) const

Definition at line 4864 of file simd.h.

OIIO_FORCEINLINE int simd::vint4::z ( ) const

Definition at line 4865 of file simd.h.

OIIO_FORCEINLINE const vint4 simd::vint4::Zero ( )
static

Return an vint4 with all components set to 0.

Definition at line 4464 of file simd.h.

Friends And Related Function Documentation

vbool4 operator!= ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4713 of file simd.h.

vint4 operator% ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4589 of file simd.h.

const vint4& operator%= ( vint4 a,
const vint4 b 
)
friend

Definition at line 4596 of file simd.h.

vint4 operator& ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4608 of file simd.h.

const vint4& operator&= ( vint4 a,
const vint4 b 
)
friend

Definition at line 4619 of file simd.h.

vint4 operator* ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4566 of file simd.h.

const vint4& operator*= ( vint4 a,
const vint4 b 
)
friend

Definition at line 4577 of file simd.h.

vint4 operator+ ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4502 of file simd.h.

const vint4& operator+= ( vint4 a,
const vint4 b 
)
friend

Definition at line 4512 of file simd.h.

vint4 operator- ( const vint4 a)
friend

Definition at line 4517 of file simd.h.

vint4 operator- ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4528 of file simd.h.

const vint4& operator-= ( vint4 a,
const vint4 b 
)
friend

Definition at line 4539 of file simd.h.

vint4 operator/ ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4581 of file simd.h.

const vint4& operator/= ( vint4 a,
const vint4 b 
)
friend

Definition at line 4587 of file simd.h.

vbool4 operator< ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4728 of file simd.h.

vint4 operator<< ( const vint4 a,
unsigned int  bits 
)
friend

Definition at line 4660 of file simd.h.

std::ostream& operator<< ( std::ostream &  cout,
const vint4 a 
)
friend

Stream output.

Definition at line 4746 of file simd.h.

const vint4& operator<<= ( vint4 a,
unsigned int  bits 
)
friend

Definition at line 4670 of file simd.h.

vbool4 operator<= ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4742 of file simd.h.

vbool4 operator== ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4703 of file simd.h.

vbool4 operator> ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4718 of file simd.h.

vbool4 operator>= ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4738 of file simd.h.

vint4 operator>> ( const vint4 a,
unsigned int  bits 
)
friend

Definition at line 4675 of file simd.h.

const vint4& operator>>= ( vint4 a,
unsigned int  bits 
)
friend

Definition at line 4685 of file simd.h.

vint4 operator^ ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4636 of file simd.h.

const vint4& operator^= ( vint4 a,
const vint4 b 
)
friend

Definition at line 4647 of file simd.h.

vint4 operator| ( const vint4 a,
const vint4 b 
)
friend

Definition at line 4623 of file simd.h.

const vint4& operator|= ( vint4 a,
const vint4 b 
)
friend

Definition at line 4633 of file simd.h.

vint4 operator~ ( const vint4 a)
friend

Definition at line 4650 of file simd.h.

Member Data Documentation

simd_t simd::vint4::m_simd

Definition at line 1166 of file simd.h.

value_t simd::vint4::m_val[elements]

Definition at line 1167 of file simd.h.


The documentation for this class was generated from the following file: