Process Execution Modes - 2020.2 English

Vitis Unified Software Platform Documentation: Application Acceleration Development (UG1393)

Document ID
UG1393
Release Date
2021-03-22
Version
2020.2 English

As discussed in Kernel Execution Modes, there are three types of execution modes. These modes are determined by block protocols assigned to the kernels on the function return. The block protocol can be assigned using #pragma HLS INTERFACE. The modes and block protocol to enable them are listed below:

Pipeline
Enabled by the default block protocol of ap_ctrl_chain
Sequential
Serial access mode enabled by ap_ctrl_hs
Free-Running
Enabled by ap_ctrl_none

For more information on how XRT supports these execution modes, refer to Supported Kernel Execution Models.

Pipeline Mode

If a kernel can accept more data while it is still operating on data from previous transactions, XRT can send the next batch of data as described in Temporal Data Parallelism: Host-to-Kernel Dataflow. Pipeline mode lets the kernel overlap multiple kernel enqueues, which improves the overall throughput.

To support pipeline mode, the kernel has to use the ap_ctrl_chain protocol, the default protocol used by HLS. This protocol can also be enabled by assigning the #pragma HLS INTERFACE to the function return as shown in the following example.

void kernel_name( int *inputs,
                  ...         )// Other input or Output ports
{
#pragma HLS INTERFACE  .....   // Other interface pragmas
#pragma HLS INTERFACE ap_ctrl_chain port=return bundle=control

For pipeline mode to be successful, the kernel should have a longer latency for the queue of the kernel, or else there would be insufficient time for the kernel to process each batch of data, and you would not see the benefit of the pipeline.

Important: To take advantage of the host-to-kernel dataflow, the kernel must also be written to process data in stages, such as pipelined at the loop-level, as discussed in Loop Pipelining, or pipelined at the task-level, as discussed in Dataflow Optimization.

For legacy reasons, the kernel also supports sequential mode that can be configured using the ap_ctrl_hs block protocol for the function return in the #pragma HLS INTERFACE. If a pipelined kernel is unable to process data in a pipelined manner, it reverts to sequential mode.

Free-Running Mode

By default Vitis HLS generates a kernel with synchronization controlled by the host application. The host controls and monitors the start and end of the kernel. However, in some cases the kernel does not need to be controlled by the host, such as in a continuously running process or data stream. This is called a free running kernel, as it is free of any control handshake. The Vitis tool supports this using the ap_ctrl_none block protocol in the #pragma HLS INTERFACE as shown in the following example.

void kernel_top(hls::stream<ap_axiu >& input, hls::stream<ap_axiu >& output) 
{ 
#pragma HLS interface axis port=input 
#pragma HLS interface axis port=output 
#pragma HLS interface ap_ctrl_none port=return // Special pragma for Free running kernel 
#pragma HLS DATAFLOW 
// The kernel is using DATAFLOW optimization 
while(1) { ... } 
}

The kernel will run only when there is data available at the input if configured using the AXI4-Stream interface. Otherwise the kernel stalls and waits for more data. For additional details, refer to Streaming Data Transfers.