PostMessage

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

Sends the message after the message structure CubeMsgType is constructed at the message space address msg obtained using the AllocMessage API.

Prototype

1
2
template <PipeMode pipeMode = PipeMode::SCALAR_MODE>
__aicore__ inline uint16_t PostMessage(__gm__ CubeMsgType* msg, CubeMsgType& msgInput)

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 
}
Table 2 API parameters

Parameter

Input/Output

Description

msg

Input

Message space address of a task in the CubeResGroupHandle object.

msgInput

Input

Message content to be sent.

Returns

Address offset between the current message space and the head space of the message queue

Constraints

None

Example

1
2
3
4
5
handle.AssignQueue(queIdx);  
auto msgPtr = handle.AllocMessage();        // Obtain the message space pointer msgPtr.
AscendC::CubeGroupMsgHead headA = {AscendC::CubeMsgState::VALID, 0};
AscendC::CubeMsgBody msgA = {headA, 1, 0, 0, false, false, false, false, 0, 0, 0, 0, 0, 0, 0, 0};
auto offset = handle.PostMessage(msgPtr, msgA);           // Fill the custom message structure at the location pointed to by msgPtr and send the message.