Viewing the Operator Simulation Pipeline

The msOpGen tool parses dump files generated by users, and generates operator simulation pipeline files (trace.json).

  1. Run the install.sh file in the ${git_clone_path}/samples/operator/ascendc/0_introduction/1_add_frameworklaunch directory to generate the CustomOp folder. For details, see Link.

    This sample project does not support Atlas Training Series Product .

    ./install.sh -v Ascendxxxyy    # xxxyy indicates the processor type.
  2. Build the operator project.
    1. Complete build configurations by referring to Preparations.
    2. Run the following command in the CustomOp operator project directory to build the operator project:
      After the build is complete, the .run operator package is generated in the build_out directory.
      ./build.sh
  3. In the directory where the custom operator package is stored, run the following command to deploy the operator package:
    1
    ./build_out/custom_opp_<target_os>_<target_architecture>.run
    
  4. Switch to the ${git_clone_path}/samples/operator/ascendc/0_introduction/1_add_frameworklaunch/AclNNInvocation directory of the AclNNInnovation repository and run the following command:
    ./run.sh
  5. After the environment variables are enabled, perform simulation by referring to msprof op simulator function and generate dump data.
    export LD_LIBRARY_PATH=${git_clone_path}/samples/operator/ascendc/0_introduction/1_add_frameworklaunch/CustomOp/build_out/op_host/:$LD_LIBRARY_PATH
  6. Generate an operator simulation pipeline file.

    Run the following command. For details about the parameters, see Table 1.

    msopgen sim -c core{id} -d xx/{path of dump data} -subc {sub core id} -out {output path} -reloc {path of .o file or executable file} 
    Table 1 Parameters

    Parameter

    Description

    Required

    sim

    Used for operations related to performance simulation.

    Yes

    -c, --core-id

    Core ID.

    Processor ID, for example, core0.

    Yes

    -d, --dump-dir

    Path to the dump file. The path can be either absolute or relative.

    Yes

    -reloc, --relocatable-file

    Sets the value to the path of the .o file or executable file generated after operator compilation on the kernel.

    Maps the pipeline to the code line and generates a .csv file indicating time consumption of code lines and instructions.

    NOTE:

    Build the operator project to generate a .o file (in ${git_clone_path}/samples/operator/ascendc/0_introduction/1_add_frameworklaunch/CustomOp/build_out/op_kernel/binary/ascendxxxy/add_custom/AddCustom_*.o) that contains the debugging information. That is, change CMAKE_BUILD_TYPE in CMakePresets.json to Debug. For details, see Build Operations.

    No

    -out, --output

    Output path. The path can be either absolute or relative. The user who runs the tool must have the read and write permissions on the path.

    Yes

    Run the following commands:

    Example 1:
    msopgen sim -c core0 -d xx/{model}/ca/add_custom/add_custom_pre_static_add_custom -out ./output_data -subc cubecore0 -reloc xx/.o
    • -c specifies the core ID of the dump data file to be parsed, for example, core0.
    • -d specifies the path of the dump data file generated in the performance simulation environment, for example, {model}/ca/add_custom/add_custom_pre_static_add_custom.
    • -subc specifies the subcore ID of the dump file to be parsed. For example, if the file name is core0.cubecore0.instr_log.dump, cubecore0 is the subcore ID. (This parameter needs to be set only for .)
    • -reloc: specifies the path of the .o file or executable file generated after operator building on the kernel side.
    Example 2:
    msopgen sim -c core0 -d xx/{model}/ca/add_custom/add_custom_pre_static_add_custom -out ./output_data -mix
    • -c specifies the core ID of the dump data file to be parsed, for example, core0.
    • -d specifies the path of the dump data file generated in the performance simulation environment, for example, {model}/ca/add_custom/add_custom_pre_static_add_custom.
  7. View the operator simulation pipeline file.

    You can enter chrome://tracing in the address box of the Chrome browser, drag the dump2trace_core0.json file from the output path to the blank area, and press the shortcut keys (w: zoom in; s: zoom out; a: move left; d: move right) on the keyboard to view the file, as shown in the following figure.

    Figure 1 Display of a single subcore
    Figure 2 Display of the mix fusion operator
    Table 2 Field description

    Field

    Description

    VECTOR

    Vector unit.

    SCALAR

    Scalar unit.

    CUBE

    Cube unit.

    MTE1

    Data transfer flow. The transfer direction is L1 -> {L0A/L0B, UBUF}.

    MTE2

    Data transfer flow. The transfer direction is {DDR/GM, L2} -> {L1, L0A/B, UBUF}.

    MTE3

    Data transfer flow. The transfer direction is UBUF -> {DDR/GM, L2, L1}.

    FLOWCTRL

    Control flow instruction.

    ICmiss

    Missed iCache.

  8. View the time-consuming file of code lines or instructions.
    Open the time-consuming file of code lines {core ID}_code_exe_prof.csv in the output path.
    Figure 3 Time-consuming file of code lines
    Open the time-consuming file of instructions {core ID}_instr_exe_prof.csv in the output path.
    Figure 4 Time-consuming file of instructions

    You can view the call count and cycles fields in the file to view the number of times that a code line or instruction is called and the accumulated duration.