Section 2: Simulate the AI Engine Graph using the aiesimulator and Viewing Trace and Profile Results in Vitis Analyzer - 2024.2 English - XD100

Vitis Tutorials: AI Engine Development (XD100)

Document ID
XD100
Release Date
2024-12-06
Version
2024.2 English

After the graph has been compiled, you can simulate your design with the aiesimulator command. This uses a cycle-approximate model to test your graph and get preliminary throughput information early in the design cycle, while the PL developers continue to work on the platform for the application.

Note: Simulating the design with VCD will increase simulation runtime. To learn more about this feature, see AI Engine SystemC Simulator.

  1. To run simulation use the command:

    make sim TARGET=hw
    

    or

    aiesimulator --profile --dump-vcd=tutorial --pkg-dir=./Work
    
| Flag | Description |
| ---- | ----------- |
| --profile | Profiles all kernels, or select kernels (col,row)...(col,row).|
| --dump-vcd | Grabs internal signals of tiles and dumps it in a VCD file. |
| --pkg-dir | The ***Work*** directory. |
  1. When simulation has completed, use a terminal to navigate to the aiesimulator_output directory by running: cd aiesimulator_output; ls

    You should see something similar to this:

    aiesim_options.txt      profile_funct_24_0.xml  profile_funct_25_0.xml  profile_instr_24_0.xml  profile_instr_25_0.xml
    data                    profile_funct_24_1.txt  profile_funct_25_1.txt  profile_instr_24_1.txt  profile_instr_25_1.txt  
    default.aierun_summary  profile_funct_24_1.xml  profile_funct_25_1.xml  profile_instr_24_1.xml  profile_instr_25_1.xml
    profile_funct_24_0.txt  profile_funct_25_0.txt  profile_instr_24_0.txt  profile_instr_25_0.txt
    

    The files prefixed with profile_ are the outputs of the profiling and calculated per tile. In this tutorial, profiling is done for all tiles that are used, but you can limit profiling to specific tiles by providing the row and column of the tile. For more information about profiling with aiesimulator see here. You can open up these files to see what was calculated, but it is better to view it in Vitis Analyzer where it is curated. The data directory is generated here with the output file(s) you have in the graph.cpp for the PLIO objects. Finally, the default.aierun_summary is generated, which contains all the information generated by aiesimulator with profiling and trace information. Opening this file in Vitis Analyzer allows you to browse all the output files, and profile/trace data.

    NOTE: The tutorial.vcd is generated on the same level as the ./Work directory.

    You can now open the generated default.aierun_summary from the aiesimulator_output directory for Vitis Analyzer.

  2. To do this,run the command:

    vitis_analyzer -a ./aiesimulator_output/default.aierun_summary
    

    With this tool you can use a variety of views to debug and potentially optimize your graph.

    The Summary view provides an overview of running aiesimulator. As you can see in the following figure, it provides information on status, version used, time, platform used, and the command line used to execute.

    Vitis Analyzer Summary

  3. Click Profile.

    The Profile View provides detailed information collected during the simulation. Information includes cycle count, total instructions executed, program memory, and specific information per functions in the two tiles that the kernels are programmed.

    Vitis Analyzer Profile

    This is the top-level view of the profile. The left column allows you to select one of many types of reports generated per function.

  4. Select the first Total Function Time from this column. You will see the following.

    Vitis Analyzer Profile 1 Kernel

    In this chart you can see what function is called most, function time, etc. This information can be useful in determining if the tile is under- or over-utilized in your design.

  5. Click Graph.

    The Graph view provides an overview of your graph and how the graph is designed in a logical fashion. In this view, you can see all the PLIO ports, kernels, buffers, and net connections for the entire ADF Graph.

    Note: This view, as well as the Array view have cross-probe selection, meaning selecting an object in this view will select it in the other and vice versa.

    Vitis Analyzer Graph

  6. Click Array.

    The Array view provides a logical device view of the AI Engine, kernel placement, and how they are connected to each other as well as the shim.

    Vitis Analyzer Array

    • Cross probe to kernel and graph source files.

    • The table at the bottom shows the following:

      • Kernel - The kernels in the graph.

      • PL - Shows connections between the graph and PLIO.

      • Buffer - Shows all the buffers used for inputs/outputs of the graph and the buffers for kernels.

      • Port - Shows all the ports of each kernel and ADF Graph.

      • Net - Shows all nets, named and generated, mapped in the ADF Graph.

      • Tile - Shows tile data (kernels, buffers) of mapped tiles and their grid location.

    Tip: For more detailed information about these tables, see Section: “Viewing Compilation Results in the Vitis Analyzer”.

    You can zoom into the view to get finer detail of the AI Engine and see how tiles are made up as seen in the following screenshot.

  7. To zoom in, click and drag from the upper-left to the lower-right of the area you want to view to have a box show up around the area to zoom. Below is a zoomed-in area.

    Vitis Analyzer Array Zoom-In

    In this zoomed in location you can see how the kernels are connected to a variety of tiles and how the shim is connected to the PLIO ports of this design.

  8. Click Simulator Output.

    Finally, the Simulator Output view. This will print out the output.txt generated by the graph. This is a timestamped output.

    Note: If you need to compare this file to a golden one, you will need have to remove the -T ####ns- from the file.

    Vitis Analyzer Output

    If you need to make any changes to the ADF Graph or the kernels inside based on results of the aiesimulator you can do so and re-run the compiler and view the results in Vitis Analyzer to see the changes you have made.

  9. When you are done with Vitis Analyzer, close it by clicking File > Exit.