The reset and reload flow requires that the host application uses the AI
Engine XCLBIN and PL only XCLBIN generated in the previous steps. Every XCLBIN file has a
universal unique identifier (UUID). The UUID can be obtained using XRT load_xclbin
API. The host application needs to load the PL only
XCLBIN and AI Engine only XCLBIN by obtaining the UUIDs associated with the XCLBIN
files.
The host application code includes the following sequence of operations:
- Open the device.
- Load PL-only XCLBIN and get PL UUID.
- Load AI Engine-only XCLBIN and get the AI Engine UUID.
- Use PL UUID with XRT API operating on the PL kernels.
- Use AI Engine UUID with XRT API operating on the AI Engine graphs.
- Operate on the PL kernels and the AI Engine graphs.
An example host code is as
follows:
int open_xclbin(char* pl_xclbinFilename,char* aie_xclbinFilename,xrt::device &device, xrt::uuid &pl_id, xrt::uuid &aie_id){
int ret=0;
// Open the device
device = xrt::device(0); //device index=0
//Load PL-only XCLBIN and get PL UUID.
pl_id = device.load_xclbin(pl_xclbinFilename);
//Load AI Engine-only XCLBIN and get AI Engine UUID.
aie_id = device.load_xclbin(aie_xclbinFilename);
return ret;
}
int run_graph(const xrt::device &device,const xrt::uuid &pl_id,const xrt::uuid &aie_id,int iterations){
int output_size_in_bytes=iterations*WINDOW_SIZE_in_Bytes;
int OUTPUT_SIZE=output_size_in_bytes/4;
//Use PL UUID with XRT API operating on PL kernels.
auto s2mm = xrt::kernel(device, pl_id, "s2mm");
auto mm2s = xrt::kernel(device, pl_id, "datagen");
// output memory
auto out_bo = xrt::bo(device, output_size_in_bytes, s2mm.group_id(0));
auto host_out=out_bo.map<int*>();
auto s2mm_run = s2mm(out_bo, nullptr, OUTPUT_SIZE);//1st run for s2mm has started
auto mm2s_run = mm2s(nullptr, OUTPUT_SIZE);
//Use AI Engine UUID with XRT API operating on AI Engine graphs.
auto gr=xrt::graph(device,aie_id,"gr_pl");
gr.run(iterations);
int match=0;
s2mm_run.wait();
out_bo.sync(XCL_BO_SYNC_BO_FROM_DEVICE);
for(int i=0;i<OUTPUT_SIZE;i++){
if(host_out[i]!=i+1){
match=1;
}
}
return match;
}
int main(int argc, char* argv[]) {
if(argc < 4) {
std::cout << "Usage: " << argv[0] << " <pl_xclbin> <aie_xclbin> <iterations>" << std::endl;
return EXIT_FAILURE;
}
char* pl_xclbinFilename=argv[1];
char* aie_xclbinFilename=argv[2];
int iterations=atoi(argv[3]);
xrt::device device;
xrt::uuid pl_id,aie_id;
int ret;
ret=open_xclbin(pl_xclbinFilename,aie_xclbinFilename,device,pl_id,aie_id);
if(ret==0){
std::cout<<"Download PL Xclbin successfully"<<std::endl;
std::cout<<"Download AIE Xclbin successfully"<<std::endl;
}
ret=run_graph(device,pl_id,aie_id,iterations);
std::cout << "TEST " << (ret ? " FAILED" : " PASSED") << std::endl;
return (ret ? EXIT_FAILURE : EXIT_SUCCESS);
}