Xilinx / Vitis-Tutorials

Vitis In-Depth Tutorials
https://Xilinx.github.io/Vitis-Tutorials/
MIT License
1.22k stars 552 forks source link

How to benchmark AI Engine code on hardware #344

Open nhkrishna opened 1 year ago

nhkrishna commented 1 year ago

Hello Everyone, I would like to benchmark the AI Engine code on the hardware. Can anyone let me know, any XILINX tool that used for timing the CODE that running on the AI Engine only on the hardware (VCK190). I would like to insert the timing code in the LeNet tutorial.

imrickysu commented 1 year ago

Hi @nhkrishna , please check whether the following articles are helpful:

cc @JithinPillai

Hari-MathWorks commented 1 year ago

Hi @SURUTHI1605 , @imrickysu , @JithinPillai

I have seen failures while using event handlers to benchmark AIE kernels for the 01-aie_lenet_tutorial. I tried event handles as below around the xrtGraphRun(..).

myGraph* myGraphHandle = static_cast<myGraph*>(graphHandle);
event::handle handle = event::start_profiling(*attr_i1, *attr_o1, event::event::io_stream_start_difference_cycles);
if(handle == event::invalid_handle){
    printf("ERROR::Invalid handle.. \n");
    return 1;
}

ret = xrtGraphRun(myGraphHandle, GRAPH_ITER_CNT);
if (ret) {
    throw std::runtime_error("Unable to run graph");
    return 1;
}

xrtGraphWait(myGraphHandle, 0);
long long cycle_count = event::read_profiling(handle);
printf("Latency cycles = : %ld \n", cycle_count);
event::stop_profiling(handle);

In this example, I would like to benchmark the first convolution layer that was running on the core01. That's the reason i have provided *attr_i1 and *attr_o1 to the event::start_profiling.

Below is the error screenshot: image

Is there anything wrong in the event handler usage. Can you please let me know if there is an issue.

Thanks, Hari

Hari-MathWorks commented 1 year ago

Hi,

I tried to follow 13-aie-performance-analysis, It was using event handlers to profile the graphObj.run(). But, In my case, I'm trying to to use profiling code in the 01-aie_lenet_tutorial where it will not use graphObj.run() instead it will use xrtGraph... API's. I couldn't find any example that profiles xrtGraph API's. Can you please let me know how we can get the profiling results in tutorial examples where we use the xrtGrap API's in host file.

Thanks, Hari

SURUTHI1605 commented 1 year ago

Hi @Hari-MathWorks , Which Vitis build you are using(2022.2/2023.1) ? Can you send your files in zip format?