目录

IterateAll

Function Description

Computes a matrix C of size singleCoreM × singleCoreN by each call to IterateAll. The iteration sequence can be adjusted using the tiling parameter iterateOrder.

Function Prototype

template <bool sync = true> __aicore__ inline void IterateAll(const GlobalTensor<DstT>& gm, uint8_t enAtomic = 0, bool enSequentialWrite = false, bool waitIterateAll = false, bool fakeMsg = false)
template <bool sync = true> __aicore__ inline void IterateAll(const LocalTensor<DstT>& ubCmatrix, uint8_t enAtomic = 0)

Parameters

Table 1 Template parameters

Parameter Description
sync

Matrix C can be obtained in synchronous or asynchronous mode.

- Synchronous: Wait until IterateAll is executed.

- Asynchronous: Do not need to wait until IterateAll is executed.

Setting it to true (default) enables the synchronous mode; while setting it to false enables the asynchronous mode.

Table 2 API parameters

Parameter Input/Output Description
gm Input

Address for storing matrix C in the global memory.

For Kirin 9020 and Kirin 9030 series processors, the supported data type is half.

ubCmatrix Input

Address for storing matrix C in the Local Memory. TPosition can be set to TPosition::TSCM.

For Kirin 9020 and Kirin 9030 series processors, the supported data type is half.

enAtomic Input

Whether to enable the atomic operation. The default value is 0.

Values:

0: disables the Atomic operation.

1: enables the AtomicAdd (accumulation) operation.

2: enables the AtomicMax (maximum value calculation) operation.

3: enables the AtomicMin (minimum value calculation) operation.

enSequentialWrite Input Whether to enable the continuous write mode (continuous write: write to [baseM, baseN]; non-continuous write: write to the corresponding position in [singleCoreM, singleCoreN]). The default value is false (non-continuous write mode).
waitIterateAll Input

Used only in asynchronous scenarios, indicating whether to use WaitIterateAll to wait for the completion of IterateAll execution.

true: WaitIterateAll is used to wait for the completion of IterateAll execution.

false: WaitIterateAll is not used to wait for the completion of IterateAll execution. Developers can handle this waiting process themselves.

fakeMsg Input

Used only in the IBShare scenario where doIBShareNorm is enabled.

IBShare is used to ensure that the same matrix A or matrix B data on L1 is reused. The number of times that AIV calls IterateAll by core must be matched. In this case, fakeMsg needs to be set to true, and no computation is performed. This ensures that IterateAll is called in pairs. The default value is false, indicating that computation is performed.

Return Value

None

Supported Models

Kirin 9020 series processors

Kirin 9030 series processors

Precautions

Ensure that the size of the input matrix C address space is greater than or equal to singleM x singleN.

Calling Example

REGIST_MATMUL_OBJ(&pipe, GetSysWorkSpacePtr(), mm, &tiling);
mm.SetTensorA(gm_a);
mm.SetTensorB(gm_b);
mm.SetBias(gm_bias);
mm.IterateAll(gm_c);    // Computation