Vitis-Tutorials icon indicating copy to clipboard operation
Vitis-Tutorials copied to clipboard

How to benchmark AI Engine code on hardware

Open nhkrishna opened this issue 2 years ago • 4 comments

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.

nhkrishna avatar Dec 23 '22 18:12 nhkrishna

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

  • https://docs.xilinx.com/r/en-US/ug1076-ai-engine-environment/Profiling-Graph-Latency
  • https://github.com/Xilinx/Vitis-Tutorials/blob/2022.2/AI_Engine_Development/Feature_Tutorials/09-debug-walkthrough/Debug6_pr.md
  • https://github.com/Xilinx/Vitis-Tutorials/blob/2022.2/AI_Engine_Development/Feature_Tutorials/09-debug-walkthrough/Debug4_et.md#Number-of-event-trace-streams-methodology

cc @JithinPillai

imrickysu avatar Jan 03 '23 08:01 imrickysu

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 avatar Jan 06 '23 11:01 Hari-MathWorks

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

Hari-MathWorks avatar Jan 09 '23 15:01 Hari-MathWorks

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

SURUTHI1605 avatar Feb 09 '23 06:02 SURUTHI1605