控制 AI 引擎 GMIO 传输 - 2023.2 简体中文

AI 引擎工具和流程用户指南 (UG1076)

Document ID
UG1076
Release Date
2023-12-04
Version
2023.2 简体中文
AI 引擎 GMIO 支持同步传输和异步传输。以下代码示例显示了利用 XRT API 执行的异步 GMIO 实现:
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
...
注释: AI 引擎 GMIO 缓冲器仅支持不可缓存的缓冲器。