CreateCubeResGroup

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

x

Atlas inference product's Vector Core

x

Atlas training products

x

Function Usage

Quickly creates a CubeResGroupHandle object to allocate message queue space and synchronization events internally. You are advised to use this API instead of the constructor of CubeResGroupHandle to create the object. Otherwise, message queue space conflicts between different objects and synchronization event errors may occur.

Prototype

1
2
template <int groupID, class MatmulApiType, template <class, class> class CallBack, typename CubeMsgType>
__aicore__ inline CubeResGroupHandle<CubeMsgType> CreateCubeResGroup(KfcWorkspace& desc, uint8_t blockStart, uint8_t blockSize, uint8_t msgQueueSize, GM_ADDR tiling)

Parameters

Table 1 Parameters in the template

Parameter

Description

groupID

Group ID. The value is of the int32 type.

MatmulApiType

Defined AIC compute object.

CallBack

Callback function class, which needs to implement the Init and Call APIs.

CubeMsgType

Custom message structure.

Table 2 API parameters

Parameter

Input/Output

Description

desc

Input

KfcWorkspace object, which is used to maintain the message queue space.

blockStart

Input

Index of the AIV corresponding to the start AIC of the CubeResGroupHandle object, that is, start AIC index x 2. For example, if the start AIC index is 0, enter 0*2. If the start AIC index is 1, enter 1*2.

blockSize

Input

Number of blocks allocated to CubeResGroupHandle in the AIV framework, that is, actual number of AICs × 2.

msgQueueSize

Input

Total number of message queues allocated to the CubeResGroupHandle object.

tiling

Input

Address of the tiling information required for AIC core computation.

Returns

A CubeResGroupHandle object instance

Restrictions

  • Assume that the number of AIV Cores of the chip is x. Then blockStart + blockSizex – 1, and msgQueueSizex.
  • Each AIC is allocated with at least one msgQueue.
  • The values of blockStart and blockSize must be even numbers.
  • When this API is called, 1600 bytes + sizeof(CubeMsgType) at the end of UB will be occupied.
  • One AIC belongs to only one CubeGroupHandle API. That is, the [blockStart / 2, blockStart / 2 + blockSize / 2] intervals of multiple CubeGroupHandle APIs cannot overlap.
  • This API cannot be used together with REGIST_MATMUL_OBJ. The resource management API is used by users to manage the inter-core communication between the AIC and AIV. In REGIST_MATMUL_OBJ, the framework manages the inter-core communication between the AIC and AIV. If they are used at the same time, exceptions such as communication message errors may occur.

Example

1
auto handle = AscendC::CreateCubeResGroup<GROUPID, MatmulApiType, MyCallbackFunc, CubeMsgBody> (desc, BLOCKSTART, BLOCKSIZE, MSGQUEUESIZE, tilingGM);