SetFlag/WaitFlag
Product Support
Product |
Supported |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
x |
|
√ |
Function
- SetFlag: The current instruction starts to be executed after all read and write operations of the current instruction are completed and the corresponding flag bit in hardware is set to 1.
- WaitFlag: When this instruction is executed, if the corresponding flag bit is 0, the subsequent instructions in the queue are blocked; if the corresponding flag bit is 1, the subsequent instructions are executed after this bit is changed to 0.
Prototype
1 2 | __aicore__ inline void SetFlag(TEventID id) __aicore__ inline void WaitFlag(TEventID id) |
Parameters
Parameter |
Input/Output |
Description |
||
|---|---|---|---|---|
id |
Input |
Event ID, which is specified by the user. You are advised to obtain the value by using AllocEventID or FetchEventID. The definition is as follows:
|
Returns
None
Restrictions
SetFlag and WaitFlag must be used in pairs.
Example
DataCopy can be executed only after SetValue is executed. In this case, you need to insert the synchronization operation between PIPE_S and PIPE_MTE3.
1 2 3 4 5 6 7 | AscendC::GlobalTensor<half> dstGlobal; AscendC::LocalTensor<half> dstLocal; dstLocal.SetValue(0, 0); AscendC::TQueSync<PIPE_S, PIPE_MTE3> sync; sync.SetFlag(0); sync.WaitFlag(0); AscendC::DataCopy(dstGlobal, dstLocal, dataSize); |