CubeResGroupHandle Constructor

Product Support

Product

Supported

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

Constructs a CubeResGroupHandle object to allocate AICs and message queues in a group. When constructing a CubeResGroupHandle object, you need to pass in the template parameter CubeMsgType, which is a custom message structure. For details, see Table 1. You need to manage the addresses and synchronization events when using this API. Therefore, the CreateCubeResGroup API is recommended to quickly create the CubeResGroupHandle object.

Prototype

1
2
3
4
template <typename CubeMsgType>
class CubeResGroupHandle;
__aicore__ inline CubeResGroupHandle() = default
__aicore__ inline CubeResGroupHandle(GM_ADDR workspace, uint8_t blockStart, uint8_t blockSize, uint8_t msgQueueSize, uint8_t evtIDIn)

Parameters

Table 1 CubeResGroupHandle parameters

Parameter

Input/Output

Description

workspace

Input

Start address of the message communication area of the CubeResGroupHandle object on the GM.

blockStart

Input

Index of the AIV corresponding to the start AIC of the CubeResGroupHandle object, that is, start AIC index × 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.

evtIDIn

Input

Identifier of the message synchronization event on the AIV within the communication framework.

As shown in the following figure, for CubeResGroupHandle 1, the value of blockStart is 4, and the value of blockSize is 4, indicating that the start AIC index is 2, that is, blockStart/2, and the number of AICs is 2, that is, blockSize/2. If the value of msgQueueSize is 10, indicating that the number of message queues is 10, the number of message queues allocated to each block is Ceil(msgQueueSize, blockSize/2), and five message queues are allocated to block 2 and block 3. For CubeResGroupHandle 2, the value of msgQueueSize is 11, and only five message queues can be allocated to the last block.

Figure 1 Mapping between blocks and message queues

Restrictions

  • Assume that the number of AIV Cores of the chip is x. Then, blockStart + blockSizex – 1, and msgQueueSizex.
  • At least one message queue (msgQueue) is allocated to each AIC.
  • 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. That is, the [blockStart/2, blockStart/2 + blockSize/2] intervals of multiple CubeGroupHandles 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
2
3
4
5
6
7
uint8_t blockStart = 4;
uint8_t blockSize = 4;
uint8_t msgQueueSize = 10;
uint8_t evtIDIn = 0; // User-managed event ID.
AscendC::KfcWorkspace desc(workspace); // User-managed workspace pointer.
AscendC::CubeResGroupHandle<CubeMsgBody> handle;
handle = AscendC::CubeResGroupHandle<MatmulApiType, MyCallbackFunc, CubeMsgBody>(desc.GetMsgStart(), blockStart, blockSize, msgQueueSize, evtIDIn);