IPU C++ memory intrinsics
Functions that target IPU memory instructions.
#include <ipu_memory_intrinsics>
These intrinsic functions target specific IPU memory instructions and may be used in C++ IPU code. These cover post-incrementing load and store instructions.
Refer to the Tile Vertex Instruction Set Architecture for Mk2 IPUs for more detailed information on the instructions targeted by these intrinsics.
Defines
-
IPU_MEMORY_INTRINSICS_INCLUDED
Variables
-
template<typename T>
static constexpr auto is_int_or_ptr = (std::is_integral<T>::value || std::is_pointer<T>::value)
-
template<typename T0, typename T1>
static constexpr auto both_int_or_ptr = (is_int_or_ptr<T0> && is_int_or_ptr<T1>)
-
namespace ipu
IPU intrinsic functions.
Functions
-
inline half load_postinc(const half **a, int i)
Post-incrementing load, targeting the
ldb16step
instruction.- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as ahalf
.
-
inline void store_postinc(half2 **a, half2 v, int i)
Post-incrementing store, targeting the
st32step
instruction.- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
half2
.i – Value by which to increment
a
after store.
-
inline half2 load_postinc(const half2 **a, int i)
Post-incrementing load, targeting the
ld32step
instruction.- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as ahalf2
.
-
inline void store_postinc(half4 **a, half4 v, int i)
Post-incrementing store, targeting the
st64step
instruction.- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
half4
.i – Value by which to increment
a
after store.
-
inline half4 load_postinc(const half4 **a, int i)
Post-incrementing load, targeting the
ld64step
instruction.- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as ahalf4
.
-
inline void store_postinc(float **a, float v, int i)
Post-incrementing store, targeting the
st32step
instruction.- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
float
.i – Value by which to increment
a
after store.
-
inline float load_postinc(const float **a, int i)
Post-incrementing load, targeting the
ld32step
instruction.- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as afloat
.
-
inline void store_postinc(float2 **a, float2 v, int i)
Post-incrementing store, targeting the
st64step
instruction.- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
float2
.i – Value by which to increment
a
after store.
-
inline float2 load_postinc(const float2 **a, int i)
Post-incrementing load, targeting the
ld64step
instruction.- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as afloat2
.
-
inline void store_postinc(int **a, int v, int i)
Post-incrementing store, targeting the
stm32step
instruction ifi
is a variable stride, andst32step
otherwise.- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
int
.i – Value by which to increment
a
after store.
-
inline int load_postinc(const int **a, int i)
Post-incrementing load, targeting the
ld32step
instruction.- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as anint
.
-
inline void store_postinc(unsigned **a, unsigned v, int i)
Post-incrementing store, targeting the
stm32step
instruction ifi
is a variable stride, andst32step
otherwise.- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
unsigned
.i – Value by which to increment
a
after store.
-
inline unsigned load_postinc(const unsigned **a, int i)
Post-incrementing load, targeting the
ld32step
instruction.- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as anunsigned
.
-
inline void store_postinc(int2 **a, int2 v, int i)
Post-incrementing store.
- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
int2
.i – Value by which to increment
a
after store.
-
inline int2 load_postinc(const int2 **a, int i)
Post-incrementing load.
- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as anint2
.
-
inline void store_postinc(uint2 **a, uint2 v, int i)
Post-incrementing store.
- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
uint2
.i – Value by which to increment
a
after store.
-
inline uint2 load_postinc(const uint2 **a, int i)
Post-incrementing load.
- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as auint2
.
-
inline void store_postinc(short **a, short v, int i)
Post-incrementing store.
- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
short
.i – Value by which to increment
a
after store.
-
inline short load_postinc(const short **a, int i)
Post-incrementing load, targeting the
lds16step
instruction.- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as ashort
.
-
inline void store_postinc(unsigned short **a, unsigned short v, int i)
Post-incrementing store.
- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
unsigned short
.i – Value by which to increment
a
after store.
-
inline unsigned short load_postinc(const unsigned short **a, int i)
Post-incrementing load, targeting the
ldz16step
instruction.- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as anunsigned short
.
-
inline void store_postinc(short2 **a, short2 v, int i)
Post-incrementing store, targeting the
stm32step
instruction ifi
is a variable stride, andst32step
otherwise.- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
short2
.i – Value by which to increment
a
after store.
-
inline short2 load_postinc(const short2 **a, int i)
Post-incrementing load, targeting the
ld32step
instruction.- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as ashort2
.
-
inline void store_postinc(ushort2 **a, ushort2 v, int i)
Post-incrementing store, targeting the
stm32step
instruction ifi
is a variable stride, andst32step
otherwise.- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
ushort2
.i – Value by which to increment
a
after store.
-
inline ushort2 load_postinc(const ushort2 **a, int i)
Post-incrementing load, targeting the
ld32step
instruction.- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as aushort2
.
-
inline void store_postinc(short4 **a, short4 v, int i)
Post-incrementing store.
- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
short4
.i – Value by which to increment
a
after store.
-
inline short4 load_postinc(const short4 **a, int i)
Post-incrementing load.
- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as ashort4
.
-
inline void store_postinc(ushort4 **a, ushort4 v, int i)
Post-incrementing store.
- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
ushort4
.i – Value by which to increment
a
after store.
-
inline ushort4 load_postinc(const ushort4 **a, int i)
Post-incrementing load.
- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as aushort4
.
-
inline void store_postinc(char **a, char v, int i)
Post-incrementing store.
- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
char
.i – Value by which to increment
a
after store.
-
inline char load_postinc(const char **a, int i)
Post-incrementing load, targeting the
lds8step
instruction.- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as achar
.
-
inline void store_postinc(unsigned char **a, unsigned char v, int i)
Post-incrementing store.
- Parameters
a – Address of the variable holding the address to store to. Gets incremented by
i
after the store.v – Value to store, of type
unsigned char
.i – Value by which to increment
a
after store.
-
inline unsigned char load_postinc(const unsigned char **a, int i)
Post-incrementing load, targeting the
ldz8step
instruction.- Parameters
a – Address of the variable holding the address to load from. Gets incremented by
i
after the load.i – Value by which to increment
a
after load.
- Returns
The value in memory whose address is given by
a
, as anunsigned char
.
-
template<typename T0, typename T1, typename = std::enable_if_t<both_int_or_ptr<T0, T1>>>
inline float ldb8(T0 base, T1 delta, int offset) Load and broadcast 8-bit value from memory.
The load address is calculated using the three arguments:
base
+delta
+offset
. Targetsldb8
instruction.- Parameters
base – Base address used in the calculation of the load address.
delta – Unsigned address delta.
offset – Unsigned scaled offset.
- Returns
32-bit value formed by broadcasting (replicating) the loaded 8-bit data value.
-
template<typename T, typename = std::enable_if_t<is_int_or_ptr<T>>>
inline float ldb8(T base, int offset) Load and broadcast 8-bit value from memory.
The load address is calculated using the two arguments:
base
+offset
. Targetsldb8
instruction.- Parameters
base – Base address used in the calculation of the load address.
offset – Unsigned scaled offset.
- Returns
32-bit value formed by broadcasting (replicating) the loaded 8-bit data value.
-
template<typename T0, typename T1, typename = std::enable_if_t<both_int_or_ptr<T0, T1>>>
inline unsigned ldz8(T0 base, T1 delta, int offset) Load and zero-extend 8-bit value from memory.
The load address is calculated using the three arguments:
base
+delta
+offset
. Targetsldz8
instruction.- Parameters
base – Base address used in the calculation of the load address.
delta – Unsigned address delta.
offset – Unsigned scaled offset.
- Returns
32-bit value formed by zero-extending the loaded 8-bit data value.
-
template<typename T, typename = std::enable_if_t<is_int_or_ptr<T>>>
inline unsigned ldz8(T base, int offset) Load and zero-extend 8-bit value from memory.
The load address is calculated using the two arguments:
base
+offset
. Targetsldz8
instruction.- Parameters
base – Base address used in the calculation of the load address.
offset – Unsigned scaled offset.
- Returns
32-bit value formed by zero-extending the loaded 8-bit data value.
-
inline half load_postinc(const half **a, int i)