Blocks a pipeline. This synchronization needs to be inserted between the same pipelines with data dependencies.
Table 1 Template parameters
| Parameter | Description |
|---|---|
| pipe | Template parameter, indicating the type of a blocked pipeline. For details about the supported pipelines, see Table 2. If you do not care about the pipeline type and want to block all pipelines, you can pass PIPE_ALL. |
Table 2 Description of instruction pipelines
| Pipeline Type | Description |
|---|---|
| PIPE_S | Scalar computation pipeline. Used when calling the Tensor GetValue function. |
| PIPE_V | Vector computation pipeline and data movement pipeline for L0C -> UB. |
| PIPE_M | Matrix computation pipeline. |
| PIPE_MTE1 | L1 -> L0A and L1 -> L0B data movement pipelines. |
| PIPE_MTE2 | Data movement pipelines for GM -> L1, GM -> L0A, GM -> L0B, and GM -> UB. |
| PIPE_MTE3 | Data movement pipelines for UB -> GM and UB -> L1. |
| PIPE_FIX | Data movement pipelines for L0C -> GM and L0C -> L1. |
The synchronization between Scalar pipelines is automatically ensured by the hardware. Calling PipeBarrier[/topic/body/section/p/b/pipe_s {""}) () (pipe_s] throws a hardware error.
In the following example, the input dst0Local of the Mul instruction is the output of the Add instruction. The two vector operation instructions depend on each other. Therefore, PipeBarrier needs to be inserted to ensure the execution sequence of the two instructions.
Note: This is only an example for reference. If automatic synchronization is enabled, PIPE_V is automatically inserted synchronously by the compiler.
The Mul instruction and the Add instruction are in a serial relationship. The Mul instruction can be executed only after the Add instruction is executed. For details, see Figure 1.

AscendC::LocalTensor<half> src0Local; AscendC::LocalTensor<half> src1Local; AscendC::LocalTensor<half> src2Local; AscendC::LocalTensor<half> dst0Local; AscendC::LocalTensor<half> dst1Local; AscendC::Add(dst0Local, src0Local, src1Local, 512); AscendC::PipeBarrier<PIPE_V>(); AscendC::Mul(dst1Local, dst0Local, src2Local, 512);