AllocMessage

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

Allocates message space in a message queue requested by the AIV, which is used to store message structures. The address of the current message space is returned. The depth of the message queue is fixed to 4. The allocation of message space follows a specific order (e.g., top-down, then looping back). When the message space to which the message queue pointer points is in the FREE state, AllocMessage returns the address of the space. Otherwise, AllocMessage loops until the current space is in the FREE state.

Figure 1 AllocMessage

Prototype

1
2
template <PipeMode pipeMode = PipeMode::SCALAR_MODE>             
__aicore__ inline __gm__ CubeMsgType *AllocMessage()

Parameters

Table 1 Parameters in the template

Parameter

Description

pipeMode

Execution unit for sending messages. The PipeMode type is defined as follows:

1
2
3
4
5
enum class PipeMode : uint8_t { 
  SCALAR_MODE = 0, // Uses the Scalar execution unit to write messages to the global memory.
  MTE3_MODE = 1, // Uses the MTE3 unit to write messages to the global memory.
  MAX 
}

Note that if pipeMode is set to MTE3_MODE, only the PostMessage API can be used to send messages. In addition, the template parameter pipeMode of the AllocMessage and PostMessage APIs must be the same.

Returns

Address of the message space that is currently allocated for

Constraints

None

Example

1
2
3
auto queIdx = AscendC::GetBlockIdx();
handle.AssignQueue(queIdx);
auto msgPtr = handle.AllocMessage();        // After a queue is bound, allocate message space in the queue. The message space address is msgPtr.