AI Engine API User Guide (AIE) 2023.2
|
Each AIE core has access to up to 4 Data Memories (DM). More...
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 the aie::load_v and aie::store_v functions. The following code block shows example usages of the aligned access functions:
while unaligned accesses are performed using aie::load_unaligned_v and aie::store_unaligned_v functions. These unaligned access functions are demostrated below.
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 from aie_dm_resource that can be used to bind individual accesses to a virtual resource.
The AIE API provides two kinds of iterators that map semantically to the C++ standard library's LegacyForwardIterator and LegacyRandomAccessIterator. The functionality exposed by these iterators are shown in the table below:
Type | Operation | Code Example |
---|---|---|
Forward Iterator | Dereference | *it |
Equality/Inequality | it1 == it2 / it1 != it2 | |
Pre/post-increment | ++it / it++ | |
Random Access Iterator | Pre/post-decrement | --it / it-- |
Arbitrary increment/decrement | it += offset / it -= offset | |
Random Access | it[offset] |
Note that the forward iterator is a subset of the random access iterator meaning that all operations implemeneted for forward iterators are also implemented for random access iterators. With these iterators defined, the types of iterators offered by the AIE API are outlined below with the iterator kind expressing the operators defined for each iterator:
Type | Constructor | Iterator Kind | |
---|---|---|---|
Scalar | Basic | aie::begin | Forward Iterator |
Circular | aie::begin_circular | Forward Iterator | |
Random Circular | aie::begin_random_circular | Random Access Iterator | |
Pattern | aie::begin_pattern | Forward Iterator | |
Vector | Basic | aie::begin_vector | Random Access Iterator |
Circular | aie::begin_vector_circular | Forward Iterator | |
Random Circular | aie::begin_vector_random_circular | Random Access Iterator | |
Restrict | aie::begin_restrict_vector | Random Access Iterator | |
Unaligned | aie::begin_unaligned_vector | Forward Iterator |
All iterators also have const alternatives, which follow the naming convention laid out by the C++ standard library i.e. the const version of an iterator created with aie::begin_vector_circular
can be created with aie::cbegin_vector_circular
.
In cases where iterators are inappropriate due to either semantic or performance issues, buffer streams are provided. Buffer streams do not conform to an iterator interface but rather a stream interface, similar to iostreams, which implies that a read or write operation will advance the stream, altering its state.
input
or output
the stream will only support reading or writing respectively.Operation | Stream operator | Member function |
---|---|---|
Read | operator>>(value_type&) | value_type pop() |
Write | operator<<(value_type&) | value_type push() |
Tensor buffer streams are an abtraction provided by the AIE API to handle multi-dimensional addressing.
An aie::tensor_descriptor object serves as a mapping from a multidimensional tensor to a 1-D memory space. A tensor descriptor is constructed from an element type, the number of elements that make up a vector block within the tensor, and a list of aie::tensor_dim objects, which are pairs of size-step pairs that describe each dimension of the tensor.
The following illustration shows how a 3-D volume can be described. Here the element type is int8
, and the number of elements per block is 32, resulting in segments of the tensor being aie::vector<int8, 32>
. The size of each dimension is given in the first paremeter of each aie::tensor_dim, while the size of the increment required to take a step in each dimension given as the second parameter. Note that this example assumes that the data is laid out in row-major order. This tensor representation allows a subvolume of the tensor to be iterated over a number of times by adding an additional aie::tensor_dim with step set to zero snd the size set to the desired number of iterations. See Tensor Buffer Stream Composition for an example.
Such a tensor descriptor may be used to construct a tensor buffer stream as shown below. The returned stream serializes the accesses to the buffer as it is read, which is also illustraded below.
Tensor descriptors and associated buffer streams are composible to arbitrary dimensions; however, the underlying mechanisms on which the abstractions are built upon in AIE-ML are three-dimensional. To overcome this, the tensor buffer streams are defined recursively, decomposing an N-dimensional tensor into (N-1)/3
nested streams, with a final N%3
leaf stream. To access an inner stream, the containing outer stream must be read with a .pop()
call, which will advance the outer stream and return the inner stream. This recursive definition is illustrated below with a corresponding code snippet:
For a practical example, see GEMM leveraging multidimensional addressing.
In the case that the automatic decomposition described in Tensor Buffer Stream Composition is not desired, it is possible to manually decompose the tensor using native integer, aie::dim_2d, and aie::dim_3d descriptions of the increments to be carried out. The arguments to aie::dim_2d and aie::dim_3d differ from the aie::tensor_dim description as the num
values represent the number of increments to carry out rather than the dimension size, and the increment at each dimension assumes that all previous increments have already been carried out.
As with the aie::tensor_dim description, dimensions can be composed arbitrarily using int
, aie::dim_2d, and aie::dim_3d increments:
The exact increment values may also be set using aie::make_tensor_descriptor_from_native_bytes.
A buffer with appropriately prepared sparse data can be read using aie::sparse_vector_input_buffer_stream
.
The supported sparse data layout requires a minimum of 50% sparsity. Specifically, two zero values within each group of four consecutive values. This 50% is a lower bound on the sparsity, meaning that further compression is possible if more zeroes are present. Loading sparse data from memory will interpret the first 64 bits as a mask. If a mask bit is not set, then 8 bits will be initialised to zero at its corresponding position. If the bit is set, then the 8 bits will be loading from the incompressible data that follows the mask. Hence, masks describe the layout of 512 bit after decompression.
Each mask must be aligned to a 32b boundary. Failure to meet this requirement will result in the sparse data being parsed incorrectly.
When loading sparse data, a partial decompression is carried out to reconstruct the data such that a 64b mask is paired with 256b partially decompressed data. This partial decompression is carried out as described in the following table. Note that 4 bits of the mask are used to represent two elements of the partially decompressed data.
Mask bits | Partially decompressed data | ||||
---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 1 | 0 | A |
0 | 0 | 1 | 0 | 0 | B |
0 | 0 | 1 | 1 | B | A |
0 | 1 | 0 | 0 | C | 0 |
0 | 1 | 0 | 1 | C | A |
0 | 1 | 1 | 0 | C | B |
1 | 0 | 0 | 0 | D | 0 |
1 | 0 | 0 | 1 | D | A |
1 | 0 | 1 | 0 | D | B |
1 | 1 | 0 | 0 | D | C |
The following example demonstrates how a 128 element sparse vector is read from memory. It requires two sets of sparse data, each comprised of a 64b mask and the associated data.
For a more comprehensive sparse matrix multiplication example, see Supported Sparse Matrix Multiplication Modes.
Typedefs | |
template<typename T , size_t Elems = dynamic_extent, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::circular_iterator = detail::circular_iterator< T, Elems, 1, Resource > |
Implements an iterator that wraps around when it reaches the end of the buffer and, thus, has no end. | |
template<typename T , size_t Elems = dynamic_extent, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::const_circular_iterator = detail::const_circular_iterator< T, Elems, 1, Resource > |
Same as circular_iterator, but the contents of the iterated array cannot be modified. | |
template<typename T , size_t Elems = dynamic_extent, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::const_random_circular_iterator = detail::const_random_circular_iterator< T, Elems, 1, Resource > |
Same as random_circular_iterator, but the contents of the iterated array cannot be modified. | |
template<DecoratedElemBaseType T, unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::const_unaligned_vector_iterator = detail::unaligned_vector_iterator< T, Elems, Resource > |
Same as unaligned_vector_iterator, but the contents of the iterated array cannot be modified. | |
template<typename T , unsigned N, size_t Elems = dynamic_extent, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::const_vector_circular_iterator = detail::const_vector_circular_iterator< T, N, Elems, 1, Resource > |
Same as vector_circular_iterator, but the contents of the iterated array cannot be modified. | |
template<DecoratedElemBaseType T, unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::const_vector_iterator = detail::const_vector_iterator< T, Elems, 1, Resource > |
Same as vector_iterator, but the contents of the iterated array cannot be modified. | |
template<typename T , unsigned Elems, size_t ArrayElems = dynamic_extent, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::const_vector_random_circular_iterator = detail::const_vector_random_circular_iterator< T, Elems, ArrayElems, 1, Resource > |
Same as vector_random_circular_iterator, but the contents of the iterated array cannot be modified. | |
template<typename T , size_t Elems = dynamic_extent, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::random_circular_iterator = detail::random_circular_iterator< T, Elems, 1, Resource > |
Implements an iterator that wraps around when it reaches the end or the beginning of the buffer and, thus, has no end. | |
template<DecoratedElemBaseType T, unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::sparse_vector_input_buffer_stream = detail::sparse_vector_input_buffer_stream< T, Elems, Resource > |
Implements an input stream that reads sparse vectors from a memory buffer. | |
template<DecoratedElemBaseType T, unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::unaligned_vector_input_buffer_stream = detail::unaligned_vector_input_buffer_stream< T, Elems, Resource > |
Implements an input stream that reads from a memory buffer with vector granularity. | |
template<DecoratedElemBaseType T, unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::unaligned_vector_iterator = detail::unaligned_vector_iterator< T, Elems, Resource > |
Implements an iterator that traverses an array using vectors instead of scalar values. | |
template<DecoratedElemBaseType T, unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::unaligned_vector_output_buffer_stream = detail::unaligned_vector_output_buffer_stream< T, Elems, Resource > |
Implements an output stream that writes into a memory buffer with vector granularity. | |
template<typename T , unsigned N, size_t Elems = dynamic_extent, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::vector_circular_iterator = detail::vector_circular_iterator< T, N, Elems, 1, Resource > |
Implements a vector iterator that wraps around when it reaches the end of the buffer and, thus, has no end. | |
template<DecoratedElemBaseType T, unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::vector_input_buffer_stream = detail::vector_input_buffer_stream< T, Elems, Resource > |
Implements an input stream that reads from a memory buffer with vector granularity. | |
template<DecoratedElemBaseType T, unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::vector_iterator = detail::vector_iterator< T, Elems, 1, Resource > |
Implements an iterator that traverses an array using vectors instead of scalar values. | |
template<DecoratedElemBaseType T, unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::vector_output_buffer_stream = detail::vector_output_buffer_stream< T, Elems, Resource > |
Implements an output stream that writes into a memory buffer with vector granularity. | |
template<typename T , unsigned Elems, size_t ArrayElems = dynamic_extent, aie_dm_resource Resource = aie_dm_resource::none> | |
using | aie::vector_random_circular_iterator = detail::vector_random_circular_iterator< T, Elems, ArrayElems, 1, Resource > |
Implements a vector iterator that wraps around when it reaches the end or the beginning of the buffer and, thus, has no end. | |
Functions | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::begin (T *base, size_t n) |
Returns an iterator for the array described by the given address and size. | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T , unsigned Elems> | |
constexpr auto | aie::begin (T(&base)[Elems]) |
Returns an iterator for the given statically-sized array. | |
template<size_t Elems, aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::begin_circular (T *base) |
Returns a circular iterator for the array described by the given address and size. | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::begin_circular (T *base, size_t n) |
Returns a circular iterator for the array described by the given address and size. | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T , size_t Elems> | |
constexpr auto | aie::begin_circular (T(&base)[Elems]) |
Returns a circular iterator for the given statically-sized array. | |
template<unsigned Steps, typename T , typename... Offsets> | |
constexpr auto | aie::begin_pattern (T *base, Offsets &&... offsets) |
Returns a forward iterator for the array described by the given address. | |
template<size_t Elems, aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::begin_random_circular (T *base) |
Returns a random-access circular iterator for the array described by the given address and size. | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::begin_random_circular (T *base, size_t n) |
Returns a random-access circular iterator for the array described by the given address and size. | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T , size_t Elems> | |
constexpr auto | aie::begin_random_circular (T(&base)[Elems]) |
Returns a random-access circular iterator for the array described by the given address and size. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
constexpr auto | aie::begin_restrict_vector (const T *base) |
Same as begin_vector, but the given pointer is considered restrict. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
constexpr auto | aie::begin_restrict_vector (T *base) |
Same as begin_vector, but the given pointer is considered restrict. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
constexpr auto | aie::begin_unaligned_vector (T *base) |
Returns a vector iterator starting at the given address. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
constexpr auto | aie::begin_vector (const T *base) |
Returns a vector iterator starting at the given address. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
constexpr auto | aie::begin_vector (T *base) |
Returns a vector iterator starting at the given address. | |
template<unsigned Elems, size_t ArrayElems, aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::begin_vector_circular (T *base) |
Returns a circular iterator for the array described by the given address and size. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::begin_vector_circular (T *base, size_t n) |
Returns a circular iterator for the array described by the given address and size. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, typename T , size_t ArrayElems> | |
constexpr auto | aie::begin_vector_circular (T(&base)[ArrayElems]) |
Returns a circular iterator for the array described by the given address and size. | |
template<unsigned Elems, size_t ArrayElems, aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::begin_vector_random_circular (T *base) |
Returns a circular iterator for the array described by the given address and size. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::begin_vector_random_circular (T *base, size_t n) |
Returns a circular iterator for the array described by the given address and size. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, typename T , size_t ArrayElems> | |
constexpr auto | aie::begin_vector_random_circular (T(&base)[ArrayElems]) |
Returns a circular iterator for the array described by the given address and size. | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::cbegin (const T *base, size_t n) |
Returns an iterator for the constant array described by the given address and size. | |
template<size_t Elems, aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr const_circular_iterator< T, Elems, Resource > | aie::cbegin_circular (const T *base) |
Similar to begin_circular, but the returned iterator is constant. | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr const_circular_iterator< T, dynamic_extent, Resource > | aie::cbegin_circular (const T *base, size_t n) |
Similar to begin_circular, but the returned iterator is constant. | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T , size_t Elems> | |
constexpr const_circular_iterator< T, Elems, Resource > | aie::cbegin_circular (const T(&base)[Elems]) |
Similar to begin_circular, but the returned iterator is constant. | |
template<unsigned Steps, typename T , typename... Offsets> | |
constexpr const_pattern_iterator< T, Steps > | aie::cbegin_pattern (const T *base, Offsets &&... offsets) |
Similar to begin_pattern, but the returned iterator is constant. | |
template<size_t Elems, aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::cbegin_random_circular (const T *base) |
Similar to begin_random_circular, but the returned iterator is constant. | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::cbegin_random_circular (const T *base, size_t n) |
Similar to begin_random_circular, but the returned iterator is constant. | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T , size_t Elems> | |
constexpr auto | aie::cbegin_random_circular (const T(&base)[Elems]) |
Similar to begin_random_circular, but the returned iterator is constant. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
constexpr auto | aie::cbegin_restrict_vector (const T *base) |
Same as begin_vector, but the given pointer is considered restrict. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
constexpr auto | aie::cbegin_unaligned_vector (T *base) |
Returns a vector iterator starting at the given address. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
constexpr auto | aie::cbegin_vector (const T *base) |
Same as begin_vector. | |
template<unsigned Elems, size_t ArrayElems, aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::cbegin_vector_circular (const T *base) |
Similar to begin_circular, but the returned iterator is constant. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::cbegin_vector_circular (const T *base, size_t n) |
Similar to begin_circular, but the returned iterator is constant. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, typename T , size_t ArrayElems> | |
constexpr auto | aie::cbegin_vector_circular (const T(&base)[ArrayElems]) |
Similar to begin_circular, but the returned iterator is constant. | |
template<unsigned Elems, size_t ArrayElems, aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::cbegin_vector_random_circular (const T *base) |
Similar to begin_circular, but the returned iterator is constant. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::cbegin_vector_random_circular (const T *base, size_t n) |
Similar to begin_circular, but the returned iterator is constant. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, typename T , size_t ArrayElems> | |
constexpr auto | aie::cbegin_vector_random_circular (const T(&base)[ArrayElems]) |
Similar to begin_circular, but the returned iterator is constant. | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::cend (const T *base, size_t n) |
Returns an iterator that points at the end of the constant array described by the given address and size. | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T > | |
constexpr auto | aie::end (T *base, size_t n) |
Returns an iterator that points at the end of the array described by the given address and size. | |
template<aie_dm_resource Resource = aie_dm_resource::none, typename T , unsigned Elems> | |
constexpr auto | aie::end (T(&base)[Elems]) |
Returns an iterator that points at the end of the given statically-sized array. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
auto | aie::load_floor_bytes_v (const T *ptr, size_t bytes) -> vector< aie_dm_resource_remove_t< T >, Elems > |
Load a vector of Elems size whose elements have type T. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
auto | aie::load_floor_v (const T *ptr, unsigned n=Elems) -> vector< aie_dm_resource_remove_t< T >, Elems > |
Load a vector of Elems size whose elements have type T. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
auto | aie::load_unaligned_v (const T *ptr, unsigned aligned_elems=1) -> vector< aie_dm_resource_remove_t< T >, Elems > |
Load a vector of Elems size whose elements have type T. | |
template<aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
auto | aie::load_unaligned_v (const T *ptr, unsigned aligned_elems=1) -> vector< aie_dm_resource_remove_t< T >, native_vector_length_v< T > > |
Load a vector whose elements have type T. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
auto | aie::load_v (const T *ptr) -> vector< aie_dm_resource_remove_t< T >, Elems > |
Load a vector of Elems size whose elements have type T. | |
template<aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T> | |
auto | aie::load_v (const T *ptr) -> vector< aie_dm_resource_remove_t< T >, native_vector_length_v< T > > |
Load a vector whose elements have type T. | |
template<unsigned Elems, aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T1, ElemBaseType T2> requires (std::is_same_v<T2, aie_dm_resource_remove_t<T1>>) | |
T1 * | aie::store_unaligned_v (T1 *ptr, const vector< T2, Elems > &v, unsigned aligned_elems=1) |
Store a vector of Elems size whose elements have type T. | |
template<aie_dm_resource Resource = aie_dm_resource::none, DecoratedElemBaseType T1, ElemBaseType T2, unsigned Elems> requires (std::is_same_v<aie_dm_resource_remove_t<T1>, aie_dm_resource_remove_t<T2>>) | |
T1 * | aie::store_v (T1 *ptr, const vector< T2, Elems > &v) |
Store a vector of Elems size whose elements have type T. | |
using aie::circular_iterator = typedef detail::circular_iterator<T, Elems, 1, Resource> |
Implements an iterator that wraps around when it reaches the end of the buffer and, thus, has no end.
The interface meets forward 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. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
using aie::const_circular_iterator = typedef detail::const_circular_iterator<T, Elems, 1, Resource> |
Same as circular_iterator, but the contents of the iterated array cannot be modified.
using aie::const_random_circular_iterator = typedef detail::const_random_circular_iterator<T, Elems, 1, Resource> |
Same as random_circular_iterator, but the contents of the iterated array cannot be modified.
using aie::const_unaligned_vector_iterator = typedef detail::unaligned_vector_iterator<T, Elems, Resource> |
Same as unaligned_vector_iterator, but the contents of the iterated array cannot be modified.
using aie::const_vector_circular_iterator = typedef detail::const_vector_circular_iterator<T, N, Elems, 1, Resource> |
Same as vector_circular_iterator, but the contents of the iterated array cannot be modified.
using aie::const_vector_iterator = typedef detail::const_vector_iterator<T, Elems, 1, Resource> |
Same as vector_iterator, but the contents of the iterated array cannot be modified.
using aie::const_vector_random_circular_iterator = typedef detail::const_vector_random_circular_iterator<T, Elems, ArrayElems, 1, Resource> |
Same as vector_random_circular_iterator, but the contents of the iterated array cannot be modified.
using aie::random_circular_iterator = typedef detail::random_circular_iterator<T, Elems, 1, Resource> |
Implements an iterator that wraps around when it reaches the end or the beginning of the buffer and, thus, has no end.
The interface meets random 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. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
using aie::sparse_vector_input_buffer_stream = typedef detail::sparse_vector_input_buffer_stream<T, Elems, Resource> |
Implements an input stream that reads sparse vectors from a memory buffer.
T | Type of the elements in the array. |
Elems | Size of the sparse vector. |
Resource | Data Memory resource to be used for the access when reading from the buffer. |
using aie::unaligned_vector_input_buffer_stream = typedef detail::unaligned_vector_input_buffer_stream<T, Elems, Resource> |
Implements an input stream that reads from a memory buffer with vector granularity.
T | Type of the elements in the array. |
Elems | Size of the vector. |
Resource | Data Memory resource to be used for the access when reading from the buffer. |
using aie::unaligned_vector_iterator = typedef detail::unaligned_vector_iterator<T, Elems, Resource> |
Implements an iterator that traverses an array using vectors instead of scalar values.
The interface meets random access iterator.
T | Type of the elements in the array. |
Elems | Size of the vector. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
using aie::unaligned_vector_output_buffer_stream = typedef detail::unaligned_vector_output_buffer_stream<T, Elems, Resource> |
Implements an output stream that writes into a memory buffer with vector granularity.
T | Type of the elements in the array. |
Elems | Size of the vector. |
Resource | Data Memory resource to be used for the access when reading from the buffer. |
using aie::vector_circular_iterator = typedef detail::vector_circular_iterator<T, N, Elems, 1, Resource> |
Implements a vector iterator that wraps around when it reaches the end of the buffer and, thus, has no end.
The interface meets forward iterator.
T | Type of the elements in the array. |
N | Size of the vector returned when dereferencing the iterator. |
Elems | Size of the array if it is different than dynamic_extent. Otherwise, the size is not known at compile time. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
using aie::vector_input_buffer_stream = typedef detail::vector_input_buffer_stream<T, Elems, Resource> |
Implements an input stream that reads from a memory buffer with vector granularity.
The buffer being traversed needs to meet the alignment requirements to load vectors.
T | Type of the elements in the array. |
Elems | Size of the vector. |
Resource | Data Memory resource to be used for the access when reading from the buffer. |
using aie::vector_iterator = typedef detail::vector_iterator<T, Elems, 1, Resource> |
Implements an iterator that traverses an array using vectors instead of scalar values.
The buffer being traversed needs to meet the alignment requirements to load/store vectors.
The interface meets random access iterator.
T | Type of the elements in the array. |
Elems | Size of the vector. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
using aie::vector_output_buffer_stream = typedef detail::vector_output_buffer_stream<T, Elems, Resource> |
Implements an output stream that writes into a memory buffer with vector granularity.
The buffer being traversed needs to meet the alignment requirements to store vectors.
T | Type of the elements in the array. |
Elems | Size of the vector. |
Resource | Data Memory resource to be used for the access when reading from the buffer. |
using aie::vector_random_circular_iterator = typedef detail::vector_random_circular_iterator<T, Elems, ArrayElems, 1, Resource> |
Implements a vector iterator that wraps around when it reaches the end or the beginning of the buffer and, thus, has no end.
The interface meets random access iterator.
T | Type of the elements in the array. |
Elems | Size of the vector returned when dereferencing the iterator. |
ArrayElems | Size of the array if it is different than dynamic_extent. Otherwise, the size is not known at compile time. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
|
constexpr |
Returns an iterator for the array described by the given address and size.
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Starting address for the iterator. |
n | Number of elements in the array. |
|
constexpr |
Returns an iterator for the given statically-sized array.
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Statically-sized array. |
|
constexpr |
Returns a circular iterator for the array described by the given address and size.
Elems | Number of elements in the array. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Starting address for the iterator. |
|
constexpr |
Returns a circular iterator for the array described by the given address and size.
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Starting address for the iterator. |
n | Number of elements in the array. |
|
constexpr |
Returns a circular iterator for the given statically-sized array.
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Statically-sized array. |
|
constexpr |
Returns a forward iterator for the array described by the given address.
On increment, the iterator is advanced by the number of elements described in the offset argument. While the pattern iterator is a forward iterator, the offsets are described by a circular iterator. For example:
will output
base | Starting address for the iterator. |
offsets | A parameter pack describing the stride of the iterator at each increment. |
|
constexpr |
Returns a random-access circular iterator for the array described by the given address and size.
Elems | Number of elements in the array. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Starting address for the iterator. |
|
constexpr |
Returns a random-access circular iterator for the array described by the given address and size.
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
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.
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Statically-sized array. |
|
constexpr |
Same as begin_vector, but the given pointer is considered restrict.
The returned iterator 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.
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 iterator 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. |
Resource | Data Memory resource to be used for the access when dereferencing 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. |
Resource | Data Memory resource to be used for the access when dereferencing 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. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Statically-sized 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. |
ArrayElems | Number of elements in the array. |
Resource | Data Memory resource to be used for the access when dereferencing 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. |
Resource | Data Memory resource to be used for the access when dereferencing 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. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Statically-sized array. |
|
constexpr |
Returns an iterator for the constant array described by the given address and size.
Resource | Data Memory resource to be used for the access when dereferencing 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 array. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Starting address for the iterator. |
|
constexpr |
Similar to begin_circular, but the returned iterator is constant.
Resource | Data Memory resource to be used for the access when dereferencing 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.
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Statically-sized array. |
|
constexpr |
Similar to begin_pattern, but the returned iterator is constant.
base | Starting address for the iterator. |
offsets | A parameter pack describing the stride of the iterator at each increment. |
|
constexpr |
Similar to begin_random_circular, but the returned iterator is constant.
Elems | Number of elements in the array. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Starting address for the iterator. |
|
constexpr |
Similar to begin_random_circular, but the returned iterator is constant.
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
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.
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Statically-sized array. |
|
constexpr |
Same as begin_vector, but the given pointer is considered restrict.
The returned iterator 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 returned iterator 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 iterator 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. |
Resource | Data Memory resource to be used for the access when dereferencing 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. |
Resource | Data Memory resource to be used for the access when dereferencing 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. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Statically-sized array. |
|
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. |
Resource | Data Memory resource to be used for the access when dereferencing 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. |
Resource | Data Memory resource to be used for the access when dereferencing 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. |
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Statically-sized array. |
|
constexpr |
Returns an iterator that points at the end of the constant array described by the given address and size.
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Starting address for the iterator. |
n | Number of elements in the array. |
|
constexpr |
Returns an iterator that points at the end of the array described by the given address and size.
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Starting address for the iterator. |
n | Number of elements in the array. |
|
constexpr |
Returns an iterator that points at the end of the given statically-sized array.
Resource | Data Memory resource to be used for the access when dereferencing the iterator. |
base | Statically-sized array. |
auto aie::load_floor_bytes_v | ( | const T * | ptr, |
size_t | bytes | ||
) | -> vector<aie_dm_resource_remove_t<T>, Elems> |
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 |
bytes | 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<T>, Elems> |
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<T>, Elems> |
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<T>, native_vector_length_v<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<T>, Elems> |
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<T>, native_vector_length_v<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, |
const vector< 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 | Vector to 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, |
const vector< 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 | Vector to be written to memory |