Parsing Profile Data

Before parsing profile data, you need to collect the raw data.

  1. Log in to the development environment as the Ascend-CANN-Toolkit running user.
  2. Switch to the directory where the msprof.py script is located.

    ${INSTALL_DIR}/tools/profiler/profiler_tool/analysis/msprof. Replace ${INSTALL_DIR} with the actual CANN component directory. If the Ascend-CANN-Toolkit package is installed as the root user, the CANN component directory is /usr/local/Ascend/ascend-toolkit/latest.

    Quick tip: Create an alias for the msprof.py script with the command alias msprof_analysis='python3 msprof.py_script_directory' as the running user. Then, you can start profiling with the shortcut msprof_analysis in any directory. This operation takes effect only in the current window.

  3. Parse the profile data.

    The command syntax is as follows:

    python3 msprof.py import -dir <dir>

    Example: python3 msprof.py import -dir /home/HwHiAiUser/profiler_data/PROF_XXX

    Table 1 Parsing command options

    Option

    Description

    Required/Optional

    import

    Parse profile data in import mode.

    When the profile data is parsed in the import mode, a .db file is generated even if there is an existing .db file in the original profile data directory.

    Required

    --cluster

    Parses and summarizes profile data in the cluster scenario. This option is supported only when the import parameter is configured.

    The -dir parameter specifies the parent directory of PROF_XXX. The parsing result is stored in the sqlite directory generated under PROF_XXX.

    This option is mandatory in the cluster scenario.

    -dir, --collection-dir

    Directory of collected profile data. The value must be the parent directory of the PROF_XXX or PROF_XXX directory, for example,

    /home/HwHiAiUser/profiler_data/PROF_XXX

    Required

    -h, --help

    Help information.

    Optional

    After the commands are executed, the sqlite directory is generated in the device_{id}and host directories of PROF_XXX. A .db file is generated in the sqlite directory. The .db file is the intermediate result and can be ignored. You can perform 4 to export the final .db file.

  4. Parse the .db file data for the second time (Optional)

    This function further parses the .db file in the sqlite directory and generates a .db file (msprof_timestamp.db) that summarizes all profile data.

    python3 msprof.py export db -dir <dir> 
    • During the execution of the export db command, a .db file (msprof_timestamp.db) that summarizes all profile data is generated in the PROF_XXX directory.
    • When --type=db is executed by the msprof command, this API is automatically called to generate a .db file (msprof_timestamp.db) that summarizes all profile data. Usually, this step is performed automatically.