AI Engine API User Guide
(AIE) 2021.2
|
Each AIE core has access to up to 4 Data Memories (DM). Global variables, graph communication buffers (such as windows), and the stack are placed by the linker on these memories.
The AIE API provides a number of functions and types that allow applications to efficiently read and write vector data stored on DM.
Applications can load from DM into vector registers and store the contents of vector registers into DM. Memory instructions in the AIE that operate on vectors have alignment requirements. Therefore, functions are provided for both aligned and unaligned accesses. Aligned accesses are done using theaie::load_vandaie::store_vfunctions, while unaligned accesses are performed usingaie::load_unaligned_vandaie::store_unaligned_vfunctions. Unaligned accesses may incur additional overhead depending on the amount of misalignment.
Users can ensure that buffers are aligned using standard C/C++ facilities such as alignas. The API provides a global constant value (aie::vector_decl_align) that can be used to align the buffer to a boundary that works for any vector size.
AIE cores are able to perform several vector load/store operations per instruction. However, in order for them to be executed in parallel, they must target different memory banks. aiecompiler will try to evenly distribute buffers from communication primitives, and users can manually place buffers on specific banks by specifying the address range in the linker script file.
In general the compiler will try to schedule many accesses in the same instruction when possible. However, in scenarios in which this would translate into bank conflicts, this behavior might not be desirable. The compiler provides type annotations to associate memory accesses to virtual resources. Accesses using types that are associated to the same virtual resource will not be scheduled in the same instruction.
Also, most memory access functions in the AIE API accept an enum value fromaie_dm_resourcethat can be used to bind individual accesses to a virtual resource.
Typedefs |
|
template |
|
using | aie::circular_iterator=detail::circular_iterator< T, Elems, 1, Resource > |
More... |
|
template |
|
using | aie::const_circular_iterator=detail::const_circular_iterator< T, Elems, 1, Resource > |
More... |
|
template |
|
using | aie::const_random_circular_iterator=detail::const_random_circular_iterator< T, Elems, 1 > |
More... |
|
template |
|
using | aie::random_circular_iterator=detail::random_circular_iterator< T, Elems, 1 > |
More... |
|
Functions |
|
template |
|
constexpr auto | aie::begin_circular(T *base) |
More... |
|
template<aie_dm_resourceResource = aie_dm_resource::none, typename T = void> | |
constexpr auto | aie::begin_circular(T *base, size_t n) |
More... |
|
template<aie_dm_resourceResource = aie_dm_resource::none, typename T = void, size_t Elems = 0> | |
constexpr auto | aie::begin_circular(T(&base)[Elems]) |
More... |
|
template |
|
constexpr auto | aie::begin_random_circular(T *base) |
More... |
|
template |
|
constexpr auto | aie::begin_random_circular(T *base, size_t n) |
More... |
|
template |
|
constexpr auto | aie::begin_random_circular(T(&base)[Elems]) |
More... |
|
template |
|
constexpr auto | aie::begin_restrict_vector(const T *base) |
More... |
|
template |
|
constexpr auto | aie::begin_restrict_vector(T *base) |
More... |
|
template |
|
constexpr auto | aie::begin_vector(const T *base) |
More... |
|
template |
|
constexpr auto | aie::begin_vector(T *base) |
More... |
|
template |
|
constexpr auto | aie::begin_vector_circular(T *base) |
More... |
|
template |
|
constexpr auto | aie::begin_vector_circular(T *base, size_t n) |
More... |
|
template |
|
constexpr auto | aie::begin_vector_circular(T(&base)[ArrayElems]) |
More... |
|
template |
|
constexprconst_circular_iterator< T, Elems, Resource > | aie::cbegin_circular(const T *base) |
More... |
|
template<aie_dm_resourceResource = aie_dm_resource::none, typename T = void> | |
constexprconst_circular_iterator< T, dynamic_extent, Resource > | aie::cbegin_circular(const T *base, size_t n) |
More... |
|
template<aie_dm_resourceResource = aie_dm_resource::none, typename T = void, size_t Elems = 0> | |
constexprconst_circular_iterator< T, Elems, Resource > | aie::cbegin_circular(const T(&base)[Elems]) |
More... |
|
template |
|
constexpr auto | aie::cbegin_random_circular(const T *base) |
More... |
|
template |
|
constexpr auto | aie::cbegin_random_circular(const T *base, size_t n) |
More... |
|
template |
|
constexpr auto | aie::cbegin_random_circular(const T(&base)[Elems]) |
More... |
|
template |
|
constexpr auto | aie::cbegin_restrict_vector(const T *base) |
More... |
|
template |
|
constexpr auto | aie::cbegin_vector(const T *base) |
More... |
|
template |
|
constexpr auto | aie::cbegin_vector_circular(const T *base) |
More... |
|
template |
|
constexpr auto | aie::cbegin_vector_circular(const T *base, size_t n) |
More... |
|
template |
|
constexpr auto | aie::cbegin_vector_circular(const T(&base)[ArrayElems]) |
More... |
|
template |
|
auto | aie::load_floor_bytes_v(const T *ptr, size_t bytes) ->vector<aie_dm_resource_remove_t< T >, Elems > |
More... |
|
template |
|
auto | aie::load_floor_v(const T *ptr, unsigned n=Elems) ->vector<aie_dm_resource_remove_t< T >, Elems > |
More... |
|
template |
|
auto | aie::load_unaligned_v(const T *ptr, unsigned aligned_elems=1) ->vector<aie_dm_resource_remove_t< T >, Elems > |
More... |
|
template<aie_dm_resourceResource = aie_dm_resource::none,DecoratedElemBaseTypeT = void> | |
auto | aie::load_unaligned_v(const T *ptr, unsigned aligned_elems=1) ->vector<aie_dm_resource_remove_t< T >, native_vector_length_v< T >> |
More... |
|
template |
|
auto | aie::load_v(const T *ptr) ->vector<aie_dm_resource_remove_t< T >, Elems > |
More... |
|
template<aie_dm_resourceResource = aie_dm_resource::none,DecoratedElemBaseTypeT = void> | |
auto | aie::load_v(const T *ptr) ->vector<aie_dm_resource_remove_t< T >, native_vector_length_v< T >> |
More... |
|
template |
|
T1 * | aie::store_unaligned_v(T1 *ptr, constvector< T2, Elems > &v, unsigned aligned_elems=1) |
More... |
|
template<aie_dm_resourceResource = aie_dm_resource::none,DecoratedElemBaseTypeT1 = void,ElemBaseTypeT2, unsigned Elems = 0> | |
T1 * | aie::store_v(T1 *ptr, constvector< T2, Elems > &v) |
More... |
|
usingaie::circular_iterator= typedefdetail::circular_iterator |
Implements an iterator that wraps around when it reaches the end of the buffer and, thus, has no end.
The interface meetsforward iterator.
T | Type of the elements in the array. |
Elems | Size of the array if it is different than dynamic_extent. Otherwise, the size is not known at compile time. |
usingaie::const_circular_iterator= typedefdetail::const_circular_iterator |
Same ascircular_iterator, but the contents of the iterated array cannot be modified.
usingaie::const_random_circular_iterator= typedefdetail::const_random_circular_iterator |
Same asrandom_circular_iterator, but the contents of the iterated array cannot be modified.
usingaie::random_circular_iterator= typedefdetail::random_circular_iterator |
Implements an iterator that wraps around when it reaches the end or the beginning of the buffer and, thus, has no end.
The interface meetsrandom access iterator.
T | Type of the elements in the array. |
Elems | Size of the array if it is different than dynamic_extent. Otherwise, the size is not known at compile time. |
|
constexpr |
Returns a circular iterator for the array described by the given address and size.
Elems | Number of elements in the array. |
base | Starting address for the iterator. |
|
constexpr |
Returns a circular iterator for the array described by the given address and size.
base | Starting address for the iterator. |
n | Number of elements in the array. |
|
constexpr |
Returns a circular iterator for the array described by the given address and size.
base | Statically-sized array. |
|
constexpr |
Returns a random-access circular iterator for the array described by the given address and size.
Elems | Number of elements in the array. |
base | Starting address for the iterator. |
|
constexpr |
Returns a random-access circular iterator for the array described by the given address and size.
base | Starting address for the iterator. |
n | Number of elements in the array. |
|
constexpr |
Returns a random-access circular iterator for the array described by the given address and size.
base | Statically-sized array. |
|
constexpr |
Same as begin_vector, but the given pointer is considered restrict.
The returned pointer is const.
Elems | Number of elements in the vectors returned by the iterator. |
base | Starting address for the iterator. |
|
constexpr |
Same as begin_vector, but the given pointer is considered restrict.
Elems | Number of elements in the vectors returned by the iterator. |
base | Starting address for the iterator. |
|
constexpr |
Returns a vector iterator starting at the given address. Elements in the vector will have the same type of the pointer parameter, and the size of the vector is specified via a template argument. The pointer is assumed to meet the alignment requirements for a vector load of this size.
The returned pointer is const.
Elems | Number of elements in the vectors returned by the iterator. |
base | Starting address for the iterator. |
|
constexpr |
Returns a vector iterator starting at the given address. Elements in the vector will have the same type of the pointer parameter, and the size of the vector is specified via a template argument. The pointer is assumed to meet the alignment requirements for a vector load of this size.
Elems | Number of elements in the vectors returned by the iterator. |
base | Starting address for the iterator. |
|
constexpr |
Returns a circular iterator for the array described by the given address and size.
Elems | Number of elements in the vectors returned by the iterator. |
ArrayElems | Number of elements in the array. |
base | Starting address for the iterator. |
|
constexpr |
Returns a circular iterator for the array described by the given address and size.
Elems | Number of elements in the vectors returned by the iterator. |
base | Starting address for the iterator. |
n | Number of elements in the array. |
|
constexpr |
Returns a circular iterator for the array described by the given address and size.
Elems | Number of elements in the vectors returned by the iterator. |
base | Statically-sized array. |
|
constexpr |
Similar to begin_circular, but the returned iterator is constant.
Elems | Number of elements in the array. |
base | Starting address for the iterator. |
|
constexpr |
Similar to begin_circular, but the returned iterator is constant.
base | Starting address for the iterator. |
n | Number of elements in the array. |
|
constexpr |
Similar to begin_circular, but the returned iterator is constant.
base | Statically-sized array. |
|
constexpr |
Similar to begin_random_circular, but the returned iterator is constant.
Elems | Number of elements in the array. |
base | Starting address for the iterator. |
|
constexpr |
Similar to begin_random_circular, but the returned iterator is constant.
base | Starting address for the iterator. |
n | Number of elements in the array. |
|
constexpr |
Similar to begin_random_circular, but the returned iterator is constant.
base | Statically-sized array. |
|
constexpr |
Same as begin_vector, but the given pointer is considered restrict.
The returned pointer is const.
Elems | Number of elements in the vectors returned by the iterator. |
base | Starting address for the iterator. |
|
constexpr |
Same as begin_vector.
The returned pointer is const.
Elems | Number of elements in the vectors returned by the iterator. |
base | Starting address for the iterator. |
|
constexpr |
Similar to begin_circular, but the returned iterator is constant.
Elems | Number of elements in the vectors returned by the iterator. |
ArrayElems | Number of elements in the array. |
base | Starting address for the iterator. |
|
constexpr |
Similar to begin_circular, but the returned iterator is constant.
Elems | Number of elements in the vectors returned by the iterator. |
base | Starting address for the iterator. |
n | Number of elements in the array. |
|
constexpr |
Similar to begin_circular, but the returned iterator is constant.
Elems | Number of elements in the vectors returned by the iterator. |
base | Statically-sized array. |
auto aie::load_floor_bytes_v | ( | const T * | ptr, |
size_t | bytes | ||
) | ->vector<aie_dm_resource_remove_t |
Load a vector of Elems size whose elements have type T. The pointer will be aligned to bytes.
Elems | Size of the vector to be read from memory |
ptr | Address data is read from |
n | Numbers of bytes to which the input pointer is aligned. Must be a power of two. |
auto aie::load_floor_v | ( | const T * | ptr, |
unsigned | n=Elems |
||
) | ->vector<aie_dm_resource_remove_t |
Load a vector of Elems size whose elements have type T. The pointer will be aligned to n * sizeof(T).
Elems | Size of the vector to be read from memory |
ptr | Address data is read from |
n | Numbers of elements of type T to which the input pointer is aligned. Must be a power of two. |
auto aie::load_unaligned_v | ( | const T * | ptr, |
unsigned | aligned_elems=1 |
||
) | ->vector<aie_dm_resource_remove_t |
Load a vector of Elems size whose elements have type T. The pointer is assumed to be aligned to T.
Elems | Size of the vector to be read from memory |
ptr | Address data is read from |
aligned_elems | Number of elements the pointer is aligned to. If unspecified, the default value is 1. |
auto aie::load_unaligned_v | ( | const T * | ptr, |
unsigned | aligned_elems=1 |
||
) | ->vector<aie_dm_resource_remove_t |
Load a vector whose elements have type T. The size is automatically chosen with the optimal size for the current architecture. The pointer is assumed to be aligned to T.
ptr | Address data is read from |
aligned_elems | Number of elements the pointer is aligned to. If unspecified, the default value is 1. |
auto aie::load_v | ( | const T * | ptr | ) | ->vector<aie_dm_resource_remove_t |
Load a vector of Elems size whose elements have type T. The pointer is assumed to meet the alignment requirements for a vector load of this size.
Elems | Size of the vector to be read from memory |
ptr | Address data is read from |
auto aie::load_v | ( | const T * | ptr | ) | ->vector<aie_dm_resource_remove_t |
Load a vector whose elements have type T. The size is automatically chosen with the optimal size for the current architecture. The pointer is assumed to meet the alignment requirements for a vector load of this size.
ptr | Address data is read from |
T1* aie::store_unaligned_v | ( | T1 * | ptr, |
constvector< T2, Elems > & | v, | ||
unsigned | aligned_elems=1 |
||
) |
Store a vector of Elems size whose elements have type T. The pointer is assumed to be aligned to T.
ptr | Address data is written to |
v | Vectorto be written to memory |
aligned_elems | Number of elements the pointer is aligned to. If unspecified, the default value is 1. |
T1* aie::store_v | ( | T1 * | ptr, |
constvector< T2, Elems > & | v | ||
) |
Store a vector of Elems size whose elements have type T. The pointer is assumed to meet the alignment requirements for a vector store of this size.
ptr | Address data is written to |
v | Vectorto be written to memory |