A kernel reads from its input buffers and writes to its output buffers. By default, the synchronization that is required to wait for an input buffer of data is performed before entering the kernel. The synchronization that is required to provide an empty output buffer is also performed before entering the kernel. There is no synchronization needed for synchronous buffer ports within the kernel to read or write the individual samples of data after the kernel has started execution.
Buffer port size can be declared via dimensions()
API or with
kernel function prototype.
- Option 1
- Configure with
dimensions()
API in graph.connect netN(in.out[0], k.in[0]); dimensions(k.in[0])={INPUT_SAMPLE_SIZE};
- Option 2
- Configure with kernel function prototype where function prototypes are
declared in kernel header files and which is referenced in graph code.
Graph code specifies connection.
connect netN(in.out[0], k.in[0]);
Kernel code specifies data type and buffer size.
void simple(input_buffer<int32, adf::extents<INPUT_SAMPLE_SIZE>> & in, output_buffer<int32, adf::extents<OUTPUT_SAMPLE_SIZE>> & out);
The kernel's buffer lock mechanism is handled in the tiles main
function. The kernel starts only when all input
and output buffers have been locked for reading and writing respectively. The
minimum latency for a lock acquisition is seven clock cycles if the buffer is ready
to be acquired. If it's already locked by another kernel, it stalls until it becomes
available (indicated in red in the figure).
You can see in the diagram that the lock acquisition occurs alternatively on the ping then pong buffer. The selection of the ping or pong buffer is automatic, no user decision is needed at this point.
When a synchronous buffer port is used, the lock on the output buffer of the kernel is released after the kernel execution has finished. This buffer can then either be acquired by its consumer kernel or transferred by DMA to its destination (destination such as a PLIO). It is important to note that the synchronous output buffer will be acquired and released during every iteration of the kernel, regardless of the number of samples written into the buffer by the kernel.