Alignment - Alignment - 2026.1 English - UG1603

AI Engine-ML Kernel and Graph Programming Guide (UG1603)

Document ID
UG1603
Release Date
2026-07-08
Version
2026.1 English

Applications can load from data memory (DM) into vector registers and store the contents of vector registers into DM. Memory instructions in the AI Engine that operate on vectors have alignment requirements. Therefore, functions are provided for both aligned and unaligned accesses.

The following functions are assumed to operate on pointers that meet the alignment requirements for a vector load or store of the size:

  • aie::load_v
  • aie::store_v
Note: The 128-bit vector load and store operations in the AI Engine require that data aligns on 128 bits. The 256-bit vector load and store operations in the AI Engine require that data aligns on 256 bits. Using aligned vector load and store operations on unaligned pointers can produce unexpected results.
Note: For AIE-ML v2 devices, the 512-bit vector load and store operations in the AI Engine require that data aligns on 512 bits.

The following functions are assumed to operate on pointers that only align to the element of the vector:

  • aie::load_unaligned_v
  • aie::store_unaligned_v

Vector load and store that operate on memory that has met the vector operation alignment requirement use fewer cycles relative to unaligned accesses. Unaligned accesses can incur additional overhead depending on the amount of misalignment.

alignas(aie::vector_decl_align) int32 buffer[16];
int32* pv=buffer;
aie::vector<int32,8> v1=aie::load_v<8>(pv);
aie::vector<int32,8> v2=aie::load_unaligned_v<8>(pv+1);
Note: Kernel buffer interfaces ensure that buffers have the required alignment for vector loads.

You can use the alignas standard C specifier to ensure proper alignment of local memory. In the following example, reals aligns to a 16-byte boundary.

alignas(16) const int32 reals[8] = 
       {32767, 23170, 0, -23170, -32768, -23170, 0, 23170};

The API provides a global constant value (aie::vector_decl_align) that you can use to align the buffer to a boundary that works for any vector size.

alignas(aie::vector_decl_align) static cint16 my_buffer[8]={{0,0},{1,-1},{2,-2},{3,-3},{4,-4},{5,-5},{6,-6},{7,-7}};
Note: The alignment requirement might change with future architectures. It is recommended that you use aie::vector_decl_align for portability.