Source Code Scans in Atomic Scenarios
A source code scan in the atomic scenario is based on the source code scan in common scenarios. When you use C++ atomic, the static scan tool identifies the atomic operations that contain the memory_order semantics and displays them in the final report.
Scanning the Source Code
- Download the sample code atomic from GitHub or Gitee to obtain the software source package.
The downloaded source package is devkitdemo-main.zip. The ./devkitdemo-main/Porting_advisor/testdemo/weak_consistency/atomic file extracted from the package is the code to be scanned for static memory consistency check.
- Generate a BC file.
- Scan the updated source file and generate a BC file.
1 2
cd /home/software/Porting_advisor/testdemo/weak_consistency/atomic/ devkit advisor bc-gen -o /home/report -c make
Command output:
Executing bc gen task, please wait... Current progress: ###### [20%] Start to get the compile database Current progress: ################ [50%] Start to generate the BC files Current progress: ################################# [100%] Configuration: Generate BC files path: /home/report Compile command: make Threads: The threads is not set, using the half number of cores. Task Timeout Interval: The timeout period is not set. Log level: info Summary: Scanned all source files, there are 1 linked BC files and 1 object BC files generated. For the detail information, please check: Output path of linked BC files: /home/report/bc-gen_20250526022607_0ebd/bin Output path of object BC files: /home/report/bc-gen_20250526022607_0ebd/object There are 0 linked BC files fail to be generated. For the causes of the failure to generate all the BC files and their intermediates, please check: Log path: /opt/DevKit-CLI-x.x.x-Linux-Kunpeng/advisor/logs/affinity/affinity.log
- -o: Path for storing the generated BC file. You must have the write permission on the path. By default, the report is saved in the current path and is named in the format of Module name_Timestamp.
- -c: Builds source code.
Download the bc-gen_20250526022607_0ebd folder in the path next to Output path of linked BC files in the command output. The bin folder is used to store the BC file in 3.
- Scan the updated source file and generate a BC file.
- Log in to the Kunpeng DevKit. In the navigation tree, choose Affinity Analyzer > Static Memory Consistency Check. Set Check Mode to Static check.
Click Select Folder next to Source File Path and upload the atomic folder. Click Select Folder next to BC File Path and upload the bin folder. See Figure 1.
- Click Check to check the memory consistency. A check report is displayed. See Figure 2.
Source Code Memory Inconsistency Issues
Four memory inconsistency issues are detected in the atomic.c file. The C++ atomic operations are not in the correct memory order. The memory consistency scan tool identifies these issues and reports their locations.



