Synchronization Check
During the development of an Ascend C operator, SetFlag and WaitFlag must be used in pairs. The synchronization check function is used to find the unpaired SetFlag instructions in the operator.
A redundant SetFlag instruction does not directly cause a contention problem of the current operator, but changes the status of the hardware counter. This may subsequently cause a synchronization instruction pairing error of subsequent operators. If the subsequent operators do not contend with each other, no error is reported during contention check. However, the counter change of preceding operators may cause actual contention. The synchronization check function can effectively identify redundant SetFlag instructions in the preceding operators, preventing the subsequent operators from being affected.
- When synchronization check is enabled independently, memory check and contention check are not performed. Therefore, you are advised to enable memory check and contention check first. If no exception is reported during contention check but operator contention occurs, you can use synchronization detection to check the preceding operators.
- A redundant WaitFlag instruction blocks the subsequent instructions of the current operator, causing the operator to stop running. In this case, developers can detect problems without tool prompts.
Supported Synchronization Exception Types
Exception |
Description |
Location |
|---|---|---|
Synchronization check |
Unpaired SetFlag synchronization instructions will cause counter status errors, even if they do not directly affect the functionality of the current operator. Synchronization instruction pairing of subsequent operators may be disturbed, furthermore, computational precision of the subsequent operators is affected. |
Kernel |
Enabling Synchronization Check
mssanitizer --tool=synccheck application // application indicates the user program.
- After the tool is started, the tool run log file mssanitizer_{TIMESTAMP}_{PID}.log is automatically generated in the current directory.
- After the user program is complete, an exception report is displayed on the GUI. For details about the exceptions, see Analyzing a Synchronization Exception Report.
Analyzing a Synchronization Exception Report
The synchronization check exception report lists the information about the unpaired SetFlag instructions in each operator in sequence, including the source flow, target flow, and specific location.
1 2 3 4 5 6 7 | The= = = = = = WARNING: Unpaired set_flag instructions detected // Unmatched set_flag instructions detected. = = = = = = from PIPE_S to PIPE_MTE3 in kernel // identifies the synchronization from PIPE_S to PIPE_MTE3. PIPE_MTE3 waits for PIPE_S. The= = = = = = in block aiv(0) on device 1 // The exception code indicates the block index and device ID of the Vector core. In this example, core 0 and card 1 are used. = = = = = = code in pc current 0x2c94 (serialNo:31) // PC pointer of the current exception and sequence number of the API calling behavior. ====== #0 /home/Ascend/compiler/tikcpp/tikcfw/impl/kernel_event.h:785:13 // The following is the call stack of the code where the exception occurs, including the file name, line number, and column number. ====== #1 /home/Ascend/compiler/tikcpp/tikcfw/interface/kernel_common.h:150:5 ====== #2 /home/test/ascendc_test_syncall/kernel.cpp:26:9 |