US 11,934,832 B2
Synchronization instruction insertion method and apparatus
Xiong Gao, Hangzhou (CN); and Kun Zhang, Shenzhen (CN)
Assigned to Huawei Technologies Co., Ltd., Shenzhen (CN)
Filed by HUAWEI TECHNOLOGIES CO., LTD., Guangdong (CN)
Filed on Dec. 21, 2021, as Appl. No. 17/558,076.
Application 17/558,076 is a continuation of application No. PCT/CN2020/098021, filed on Jun. 24, 2020.
Claims priority of application No. 201910551144.9 (CN), filed on Jun. 24, 2019.
Prior Publication US 2022/0113971 A1, Apr. 14, 2022
Int. Cl. G06F 9/30 (2018.01); G06F 8/41 (2018.01); G06F 9/38 (2018.01)
CPC G06F 9/30087 (2013.01) [G06F 8/433 (2013.01); G06F 9/3838 (2013.01)] 19 Claims
OG exemplary drawing
 
1. A synchronization instruction insertion method, comprising:
obtaining a first program block comprising one or more statements, wherein each of the one or more statements comprises one or more function instructions;
determining a first function instruction and a second function instruction between which data dependency exists in the first program block;
inserting a synchronization instruction pair between a first statement comprising the first function instruction and a second statement comprising the second function instruction;
indicating, by using a first synchronization path graph, a directed dependency relationship between synchronized function instructions;
determining a third function instruction and a fourth function instruction between which data dependency exists in the first program block;
determining that a synchronization path from a node corresponding to the third function instruction to a node corresponding to the fourth function instruction is unreachable in the first synchronization path graph; and
in response to determining that the synchronization path from the node corresponding to the third function instruction to the node corresponding to the fourth function instruction is unreachable in the first synchronization path graph, inserting a synchronization instruction pair between a third statement comprising the third function instruction and a fourth statement comprising the fourth function instruction.