Controlling AI Engine GMIO Transfers - 2023.1 English

AI Engine Tools and Flows User Guide (UG1076)

Document ID
UG1076
Release Date
2023-06-23
Version
2023.1 English
AI Engine GMIO supports both synchronous and asynchronous transferring. Following example code shows an asynchronous GMIO implementation with XRT API:
char* xclbinFilename = argv[1];
// Open xclbin
auto device = xrt::device(0); //device index=0
auto uuid = device.load_xclbin(xclbinFilename);

auto din_buffer = xrt::aie::bo (device, BLOCK_SIZE_in_Bytes, xrt::bo::flags::normal, /*memory group*/0); //Only non-cacheable buffer is supported
int* dinArray= din_buffer.map<int*>();
auto dout_buffer = xrt::aie::bo (device, BLOCK_SIZE_in_Bytes, xrt::bo::flags::normal, /*memory group*/0); //Only non-cacheable buffer is supported
int* doutArray= dout_buffer.map<int*>();

int ret=0;
int error=0;
//Initialization
for(int i=0;i<ITERATION*1024/4;i++){
  dinArray[i]=i;
}

din_buffer.async("gr.gmioIn",XCL_BO_SYNC_BO_GMIO_TO_AIE,BLOCK_SIZE_in_Bytes,/*offset*/0);

auto ghdl=xrt::graph(device,uuid,"gr");
ghdl.run(ITERATION);

auto out_buffer_run=dout_buffer.async("gr.gmioOut",XCL_BO_SYNC_BO_AIE_TO_GMIO,BLOCK_SIZE_in_Bytes,/*offset*/0);

ghdl.wait();//Wait for graph to complete
dout_buffer_run.wait();//Wait for gmioOut to complete

//Post-processing
...
Note: Only non-cacheable buffers are supported for AI Engine GMIO buffers.