Buffer Allocation Control - 2023.2 English

AI Engine Kernel and Graph Programming Guide (UG1079)

Document ID
UG1079
Release Date
2023-12-04
Version
2023.2 English

The aiecompiler automatically allocates the desired number of buffers for each memory connection. There are several different cases.

  • Lookup tables are always allocated as single buffers because they are expected to be read-only and private to a kernel. No locks are needed to synchronize lookup table accesses because they are expected to be accessed in an exclusive manner.
  • Buffer connections are usually assigned double buffers if the producer and consumer kernels are mapped to different processors or if the producer or the consumer is a DMA. This enables the two agents to operate in a pipelined manner using ping-pong synchronization with two locks. The aiecompiler automatically generates this synchronization in the respective processor main functions.
  • If the producer and consumer kernels are mapped to the same processor, then the buffer connection is given only one buffer and no lock synchronization is needed because the kernels are executed sequentially.
  • Run-time parameter connections can be assigned double buffers (default) along with a selector word to choose the next buffer to be accessed.

Run-time parameter connections can also be assigned single buffers. Sometimes, with buffer connections, it is desirable to use only single buffer synchronization instead of double buffers. This is useful when the local data memory is at a premium and the performance penalty of using a single buffer for data transfer is not critical. This can be achieved using the single_buffer(port<T>&) constraint.

single_buffer(first.in[0]); //For buffer input or RTP input
single_buffer(first.inout[0]); //For RTP output