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) gr.run(4); gr.update(gr.trigger,10); gr.update(gr.trigger,10); gr.update(gr.trigger,100); gr.update(gr.trigger,100); gr.wait();
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.
In the host application (host.cpp), the
graph.update() function is called to update the
graph.run() 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.
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 gr.run(16);//start AIE kernel gr.wait();
In the preceding example,
a run of 16 iterations.
graph.wait(), the application waits for the
AI Engine kernels to complete.
The code example shows that
adf::registerXRT() requires the device handle (
UUID of the XCLBIN image. They
can be obtained using the XRT APIs:
auto dhdl = xrtDeviceOpen(0);//device index=0 xrtDeviceLoadXclbinFile(dhdl,xclbinFilename); xuid_t uuid; xrtDeviceGetXclbinUUID(dhdl, uuid);