WaitPreBlock

Supported Products

Product

Supported/Unsupported

Atlas A3 training products / Atlas A3 inference products

x

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

x

Atlas inference product 's AI Core

Atlas inference product 's Vector Core

x

Atlas training products

x

Function Usage

Reads the value in the GM address to determine whether to continue to wait. When the GM value meets the waiting condition of the current core, the core can proceed to the next operation. Before calling this API, ensure that InitDetermineComputeWorkspace has been called to initialize the shared memory.

Prototype

1
__aicore__ inline void WaitPreBlock(GlobalTensor<int32_t>& gmWorkspace, LocalTensor<int32_t>& ubWorkspace)

Parameters

Table 1 Parameters

Parameter

Input/Output

Meaning

gmWorkspace

Input

Temporary space. gmWorkspace is read to determine whether the current core can continue to execute. The type is GlobalTensor.

ubWorkspace

Input

Temporary space, which is used to operate gmWorkspace. The type is LocalTensor.

Returns

None

Constraints

  • Ensure that each core calls this API the same times.
  • The minimum space allocated to gmWorkspace is blockNum * 32 bytes. The minimum space allocated to ubWorkspace is (blockNum * 32 + 32 bytes). blockNum indicates the number of called cores, which can be obtained by calling GetBlockNum.
  • In separation mode, when this API is used for multi-core synchronization, the API takes effect only for the AIV core. Only vector calculation instructions can be inserted between WaitPreBlock and NotifyNextBlock. Matrix calculation instructions do not take effect.
  • When this API is used for multi-core control, the logical blockDim specified during operator calling must be less than or equal to the number of cores for running the operator. Otherwise, the framework inserts abnormal synchronization during multi-round scheduling, causing the kernel to stop responding.

Example

For details, see Example.