AI Engine GMIO supports
both synchronous and asynchronous transferring, both of which are supported by ADF
APIs, and XRT APIs. 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);
int* dinArray= din_buffer.map<int*>();
auto dout_buffer = xrt::aie::bo (device, BLOCK_SIZE_in_Bytes, xrt::bo::flags::normal, /*memory group*/0);
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);
dout_buffer.async("gr.gmioOut",XCL_BO_SYNC_BO_AIE_TO_GMIO,BLOCK_SIZE_in_Bytes,/*offset*/0);
ghdl.wait();
//Post-processing
...