Controlling the AI Engine Graph with the ADF API - 2020.2 English

Versal ACAP AI Engine Programming Environment User Guide (UG1076)

Document ID
Release Date
2020.2 English

ADF APIs are used to control graph execution in the top-level application, or host code, as described in AI Engine Programming. For example, the following code is for a synchronous update of run-time parameters for AI Engine kernels in the graph:

// ADF API:run and update graph parameters (RTP);
Tip: Using of graph.end() terminates the graph. It will not recover after end() has been called. Instead, you can use graph.wait() to wait for runs to be completed.

Running in Linux, the ADF API is used to update run-time parameters (RTPs) for PL kernels that are inside the graph. In the host application (host.cpp), the graph.update() function is called to update the RTPs, and is called to launch the AI Engine kernels and PL kernels inside the graph. Internally, the ADF API is calling the XRT API, and adf::registerXRT() is used to manage the relationship between them.

The following is example code showing RTP update and execution by the ADF API:

// update graph parameters (RTP) & run
adf::registerXRT(dhdl, uuid);
gr.update(gr.size, 1024);//update PL kernel RTP;//start PL kernel & AIE kernel

For PL kernels inside the graph, graph.update() must be called before In the example shown above, specifies a run of 16 iterations. In each call, the PL kernels inside the graph are only started once, no matter the number of iterations specified for the run. However, the AI Engine kernels run the number of iterations specified for the run.

In graph.wait(), the application waits for both the AI Engine kernels and PL kernels inside the graph to complete. Thus, it is your responsibility to make sure the AI Engine kernels and PL kernels inside graph can start and complete in synchronous mode.

The code example shows that adf::registerXRT() requires the device handle (dhdl) and UUID of the XCLBIN image. They can be obtained using the XRT APIs:

auto dhdl = xrtDeviceOpen(0);//device index=0
xuid_t uuid;
xrtDeviceGetXclbinUUID(dhdl, uuid);