PostMessage
产品支持情况
| 产品 | 是否支持 | 
|---|---|
| x | |
| √ | |
| x | |
| x | |
| x | |
| x | |
| x | 
功能说明
通过AllocMessage接口获取到消息空间地址msg后,构造消息结构体CubeMsgType,发送该消息。
函数原型
| 1 2 | template <PipeMode pipeMode = PipeMode::SCALAR_MODE> __aicore__ inline uint16_t PostMessage(__gm__ CubeMsgType* msg, CubeMsgType& msgInput) | 
参数说明
| 参数名 | 描述 | ||
|---|---|---|---|
| pipeMode | 用于配置发送消息的执行单元。PipeMode类型,其定义如下: 
 | 
| 参数 | 输入/输出 | 说明 | 
|---|---|---|
| msg | 输入 | 该CubeResGroupHandle中某个任务的消息空间地址。 | 
| msgInput | 输入 | 需要发送的消息内容。 | 
返回值说明
当前消息空间与该消息队列队首空间的地址偏移。
约束说明
无
调用示例
| 1 2 3 4 5 | handle.AssignQueue(queIdx); auto msgPtr = handle.AllocMessage(); // 获取消息空间指针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); // 在msgPtr指针位置,填充用户自定义的消息结构体,并发送 | 
父主题: CubeResGroupHandle