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

Versal ACAP AI Engine Programming Environment User Guide (UG1076)

Document ID
Release Date
2022.1 English

ADF APIs are used to control graph execution in the top-level application, or host code, as described in Introduction to 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: The use of graph.end() terminates the graph. It will not recover after end() has been called.

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 in the graph. In hardware emulation and hardware flows, the ADF API is calling the XRT API, and adf::registerXRT() is used to manage the relationship between them.

Important: adf::registerXRT() must be called before any ADF API control or interaction with the graph.

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

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

In the preceding example, specifies a run of 16 iterations.

In graph.wait(), the application waits for the AI Engine kernels to complete.

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);