MindStudio Ops Profiler Development Environment Setup, Compilation, and UT Methods¶
1. Background Knowledge Required¶
For details about the code framework and core process, see the msOpProf Architecture Design Specifications.
2. Development Environment Setup¶
-
For hardware environment requirements, see Ascend Product Models.
-
Set up the environment by referring to the Operator Tool Development Environment Setup Guide.
-
The CMake version must be between 3.20.2 and 3.31.10 (inclusive).
-
Run the
pip install numpycommand to install the NumPy Python dependency library. -
The generated .run package depends on pigz, which is typically provided by the system. Run the
pigz --versioncommand to check whether pigz has been installed.
3. Building and Packaging¶
There are two methods, each with its own advantages and disadvantages:
| Method | Application Scenario | Advantages | Disadvantages |
|---|---|---|---|
| One-click script | Initial build and CI/CD pipeline | Zero configuration, one-step setup | Steps cannot be executed independently. |
| Step-by-step script | Routine development and incremental build | Flexibility and efficiency | Multiple steps are required. |
3.1 Method 1: One-click Script¶
3.2 Method 2: Step-by-Step Script¶
3.2.1 Downloading Dependencies¶
3.2.2 Building and Packaging¶
3.2.2.1 Starting Build¶
Run the following commands to start the build:
mkdir build
cd build
cmake ../cmake # If you only need to build the project and do not need to generate a .runfile, run cmake .. instead.
make -j$(nproc) # -j indicates the number of parallel build jobs, which can be specified as required. If nproc is unavailable, manually enter a number (for example, -j8).
[!NOTE]NOTE
Debug version build
To perform GDB or VS Code graphical breakpoint debugging, build the debug version. The procedure is as follows:
Add-DCMAKE_BUILD_TYPE=Debugwhen running the preceding CMake command, for example,cmake ../cmake -DCMAKE_BUILD_TYPE=Debug.
If the generation time of the mindstudio-opprof_xxx_xxx.run file in the output directory is updated to the current build time, the building and packaging are successful.
3.2.2.2 Build Result Description¶
The build result is generated in the output directory:
output/
|-- bin # Executable binary file, which can directly call the tuning function
|-- filelist.csv # Configuration file for packaging the .run package
|-- lib64 # Various dynamic and static libraries
|-- mindstudio-opprof/ # Directory for packing the .run package
|-- mindstudio-opprof_xxx_xxx.run # Installation package
|-- parser_install.sh # Public script for parsing .run package installation
|-- version.info # Version information
3.2.3 Cleanup/Rebuild¶
Delete the build directory and perform 3.2.2.1.
4. Running UT¶
4.1 Method 1: One-Click Script¶
4.2 Method 2: Step-by-Step Script¶
4.2.1 Downloading Dependencies¶
4.2.2 Running UT¶
[!NOTE]NOTE
CMake entry description for UT
The UT build usesCMakeLists.txtin the root directory (that is,cmake ..instead ofcmake ../cmake) of the project. Only the test and dependency are built, and the .run packaging process is not included.
mkdir build_ut
cd build_ut
cmake .. -DBUILD_TESTS=ON
make -j$(nproc) # -j indicates the number of parallel build jobs, which can be specified as required. If nproc is unavailable, manually enter a number (for example, -j8).
./test/ut/msopt_test --gtest_output=xml:test_detail.xml
If the number of executed test cases is the same as the number of passed test cases, the test is successful. The output is similar to the following:
4.2.3 Cleanup/Rebuild¶
Delete the build directory and perform 4.2.2.
5. FAQ¶
5.1 Why Is No .run Package Generated When I Run the make Command During Building?¶
It is possible that cmake .. is used when running the cmake command. The cmake command is described as follows:
cmake ..: Only the current project is built. Themake installcommand installs the project to theoutput/directory, but does not callmakeself. Therefore, noAscend-mindstudio-sanitizer-xxx.runfile is generated.cmake ../cmake: The "super build" ofcmake/CMakeLists.txtis used. The project is built and installed first, and thenparser.pyandmakeselfare executed to generate the .run file in theoutput/directory.