Working in Hardware Flow - 2020.2 English

Versal ACAP AI Engine Programming Environment User Guide (UG1076)

Document ID
Release Date
2020.2 English

GMIO is not only used as a virtual platform for the AI Engine simulator, but can also work in hardware flow. To allow it to work in hardware flow, the following code can be added to graph.cpp:

#if !defined(__AIESIM__) && !defined(__ADF_FRONTEND__)
    #include "adf/adf_api/XRTConfig.h"
    #include "experimental/xrt_kernel.h"
    // Create XRT device handle for ADF API
    char* xclbinFilename = argv[1];
    auto dhdl = xrtDeviceOpen(0);//device index=0
    xuid_t uuid;
    xrtDeviceGetXclbinUUID(dhdl, uuid);
    adf::registerXRT(dhdl, uuid);

Using the guard macro __AIESIM__ and __ADF_FRONTEND__, the same version of graph.cpp can work for the AI Engine simulator and hardware flow. Note that the preceding code should be placed before calling the graph or the GMIO ADF APIs. At the end of the program, close the device using the xrtDeviceClose() API.

#if !defined(__AIESIM__) && !defined(__ADF_FRONTEND__)

To compile the code for hardware flow, see Programming the PS Host Application.

While it is recommended to use ADF APIs to control the GMIO, it is possible to use XRT. However, only synchronous mode GMIO transactions are supported. The API to perform synchronous transferring data can be found in experimental/xrt_aie.h:

 * xrtAIESyncBO() - Transfer data between DDR and Shim DMA channel
 * @handle:          Handle to the device
 * @bohdl:           BO handle.
 * @gmioName:        GMIO name
 * @dir:             GM to AIE or AIE to GM
 * @size:            Size of data to synchronize
 * @offset:          Offset within the BO
 * Return:          0 on success, or appropriate error number.
 * Synchronize the buffer contents between GMIO and AIE.
 * Note: Upon return, the synchronization is done or error out
xrtAIESyncBO(xrtDeviceHandle handle, xrtBufferHandle bohdl, const char *gmioName, enum xclBOSyncDirection dir, size_t size, size_t offset);