SetFlag/WaitFlag(ISASI)
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
√ |
|
x |
|
√ |
Function Usage
Synchronizes different pipelines in the same core. This synchronization operation needs to be inserted between different pipeline instructions with data dependency.
Prototype
1 2 3 4 | template <HardEvent event> __aicore__ inline void SetFlag(int32_t eventID) template <HardEvent event> __aicore__ inline void WaitFlag(int32_t eventID) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
event |
Input |
Template parameter. Synchronization event of the HardEvent data type. For details, see the following description of synchronization types. |
eventID |
Input |
Event ID. The data type is int32_t. The definition is as follows: In TPipe- and TQue-based programming scenarios, the event ID needs to be obtained by using AllocEventID (AllocEventID) or FetchEventID (FetchEventID). Atlas 350 Accelerator Card: The value ranges from 0 to 7. |
The synchronization types are described as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | enum class HardEvent : uint8_t { // Name (source pipeline_target pipeline). For example, MTE2_V indicates that PIPE_MTE2 is the source pipeline and PIPE_V is the target pipeline. Synchronization is performed between PIPE_MTE2 and PIPE_V, and PIPE_V waits for PIPE_MTE2. MTE2_MTE1 MTE1_MTE2 MTE1_M M_MTE1 MTE2_V V_MTE2 MTE3_V V_MTE3 M_V V_M V_V MTE3_MTE1 MTE1_MTE3 MTE1_V MTE2_M M_MTE2 V_MTE1 M_FIX FIX_M MTE3_MTE2 MTE2_MTE3 S_V V_S S_MTE2 MTE2_S S_MTE3 MTE3_S MTE2_FIX FIX_MTE2 FIX_S M_S FIX_MTE3 } |
Returns
None
Constraints
- SetFlag and WaitFlag must be used in pairs.
- In TPipe- and TQue-based programming scenarios, you are not advised to specify the event ID when using SetFlag and WaitFlag. Otherwise, the event ID may conflict with the framework synchronization event, causing suspension.
- In static tensor programming scenarios, the event types and event IDs are managed by developers. However, note that event IDs 6 and 7 cannot be used (as they may conflict with internal event IDs, leading to undefined behavior).
Example
1 2 3 4 5 6 7 8 9 10 11 12 | AscendC::GlobalTensor<half> dstGlobal; AscendC::LocalTensor<half> dstLocal; dstLocal.SetValue(0, 0); uint32_t dataSize = 512; // In TPipe- and TQue-based programming scenarios, the event ID needs to be obtained by using AllocEventID or FetchEventID. int32_t eventIDSToMTE3 = static_cast<int32_t>(GetTPipePtr()->FetchEventID(AscendC::HardEvent::S_MTE3)); AscendC::SetFlag<AscendC::HardEvent::S_MTE3>(eventIDSToMTE3); AscendC::WaitFlag<AscendC::HardEvent::S_MTE3>(eventIDSToMTE3); // In static tensor programming scenarios, the event ID is managed by developers. // AscendC::SetFlag<AscendC::HardEvent::S_MTE3>(EVENT_ID0); // AscendC::WaitFlag<AscendC::HardEvent::S_MTE3>(EVENT_ID0); AscendC::DataCopy(dstGlobal, dstLocal, dataSize); |