RecvOperation

功能

从当前通信卡接收来自指定通信卡的数据。Send和Recv需要配套使用。

图1 Send&Recv收发数据功能示意图

定义

struct RecvParam {
    int rank = 0;
    int rankSize = 0;
    int rankRoot = 0;
    uint32_t srcRank = 1;
    std::string backend = "hccl";
    HcclComm hcclComm = nullptr;
    CommMode commMode = COMM_MULTI_PROCESS;
    std::string rankTableFile;
    std::string commDomain;
};

参数列表

成员名称

类型

默认值

描述

rank

int

0

当前卡所属通信编号。

rankSize

int

0

通信的卡的数量。

rankRoot

int

0

主通信编号。

srcRank

uint32_t

1

通信域内数据接收端的rank编号。

backend

std::string

"hccl"

通信后端指示,仅支持"hccl"。

hcclComm

HcclComm

nullptr

HCCL通信域指针。

默认为空,加速库为用户创建;若用户想要自己管理通信域,则需要传入该通信域指针,加速库使用传入的通信域指针来执行通信算子。

commMode

CommMode

COMM_MULTI_PROCESS

通信模式,CommMode类型枚举值。hccl多线程只支持外部传入通信域方式。

rankTableFile

std::string

-

集群信息的配置文件路径,适用单机以及多机通信场景,当前仅支持hccl后端场景,若单机配置了ranktable,则以ranktable来初始化通信域。

ranktable配置请参见《CANN TensorFlow 1.15模型迁移指南》的“模型训练>执行分布式训练>准备ranktable资源配置文件

commDomain

std::string

-

通信device组用通信域名标识,多通信域时使用,当前仅支持hccl。

输入

参数

维度

数据类型

格式

描述

x

[d0,…,dn]

"hccl": float16/float/int8/int16/int32/int64/bf16

ND

输入tensor。

输出

参数

维度

数据类型

格式

描述

output

[d0,…,dn]

"hccl": float16/float/int8/int16/int32/int64/bf16

ND

输出tensor,与输入维度相同。

规格约束

  • 多用户使用时需要使用ATB_SHARE_MEMORY_NAME_SUFFIX环境变量(请参见Transformer加速库环境变量说明)进行共享内存的区分,以进行初始化信息同步。
  • 当使用加速库的通信算子异常退出时,需要清空残留数据,避免影响之后的使用,命令参考如下:
    rm -rf /dev/shm/sem.lccl*
    rm -rf /dev/shm/sem.hccl*
    ipcrm -a