Compilation and Build
SiP Compilation
Download the Acceleration Library Source Code
git clone https://gitcode.com/cann/sip.git
You can select any branch as needed.
Compile
Users need to enter the root directory of the acceleration library and compile
cd ${SiP_root_path}
bash build.sh
Note: SiP library compilation depends on ascend-boost-comm. Therefore, the compilation process involves two steps: ① pulling and compiling the ascend-boost-comm (Ascend Distributed Communication Acceleration Library) repository; ② compiling the SiP acceleration library. For more command introductions, refer to the README.md and build.sh files in the main directory of the SiP repository.
For the complete dependency list, refer to the
requirements.txtand the "Environment Setup" section inREADME.mdin the root directory.
SiP Compilation Related Notes
The basic compilation command for SiP is bash build.sh. In the default build mode, this command generates version information and creates an installation package.
bash build.sh
Use the --help parameter to obtain the build.sh script functions and corresponding instructions.
--help Displays help message.
--dev Compile only the operator library. If type is empty, the default is dev.
--clean Clear caches and dependent third-party libraries.
--ut Compile and execute unit test cases.
Compilation Target Chip Architecture Configuration
The SiP library supports multiple Ascend chip architectures. During compilation, configure the target chips to compile through configs/build_config.json. The file content is as follows:
{
"targets": {
"ascend310b": false,
"ascend310p": false,
"ascend910b": true,
"ascend950": true
}
}
The meaning of each field is as follows:
| Chip Architecture | Corresponding Product Series |
|---|---|
ascend310b |
Atlas 200I/500 A2 Inference Card |
ascend310p |
Atlas 300I Inference Card |
ascend910b |
Atlas A2 Training/Inference Server |
ascend950 |
Ascend 950PR/950DT |
Set the targets that need compilation to true, and set the targets that do not need compilation to false.
Note: The default configuration enables both
ascend910bandascend950targets simultaneously. If your runtime environment only supports one of these chips (for example, only supports Ascend910), set the unsupported chip architecture tofalse. Otherwise, compiling an unsupported chip target will fail due to hardware feature mismatch (typical error such assimd_vf function 'RegCompute' must be a free function or static member function).
Custom Compilation Configuration File
In addition to modifying the project's built-in configs/build_config.json, you can also specify a custom configuration file path through the environment variable BUILD_CONFIG_FILE, so that the project reads that file instead of the default configuration during compilation. For example:
export BUILD_CONFIG_FILE=/path/to/your/build_config.json
bash build.sh
Note: The configuration file actually read by the compilation system is determined by the
get_build_target_list()function inscripts/build_util.py. When theBUILD_CONFIG_FILEenvironment variable is not set, the system readsconfigs/build_config.jsonin the project root directory by default. When the environment variable is set, the system reads the configuration file at the specified path. Although themkicomponent (located in3rdparty/mki/) that the project depends on also has aconfigs/build_config.json, the SiP compilation process uses the project's own configuration file as the standard. No modification to the configuration under3rdparty/mki/is required.
SiP Key File Introduction
-
scriptsdirectory:install.sh: Installation scriptuninstall.sh: Uninstallation scriptrelease.sh: Fully automatic build and packaging scriptset_env.sh: SiP environment variable setup filebuild_util.py: Compilation helper script. Responsible for reading the compilation target configuration (build_config.json) and operator binary packaging.
-
configsdirectory:build_config.json: Compilation target chip architecture configuration fileop_list.yaml: Operator list configuration
-
outputdirectory:version.info
-
output/libdirectory:libasdsip.so: Dynamic link library file of the SiP acceleration librarylibmki.so: Dynamic link library file of the MKI library
Configuration Files
Compilation File build.sh
File name: build.sh
This is the acceleration library compilation file. You can set the log storage directory, log file, compiler version, etc. in this file. Generally, no modification is required.
Environment Variable Setup File set_env.sh
File name: scripts/set_env.sh
After the acceleration library is installed, the system provides set_env.sh (a process-level environment variable setup script) to automatically complete environment variable setup. The settings expire automatically after the user process ends.
If you want to view the descriptions of related variables, visit Environment Variable Reference - CANN Community Edition - Ascend Community.