---
title: RecvOperation
description: "| 硬件型号 | 是否支持 |"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendtb/ascendtb_01_0216.html
sourcePath: /source/zh/canncommercial/900/API/ascendtb/ascendtb_01_0216.html
indexId: 0ceaff10bb27d4d359b90cd3d5d6e1d3bfb49e0fbba8555ff0f39190fa41720164
---
# RecvOperation

#### 产品支持情况

| 硬件型号 | 是否支持 |
| --- | --- |
| Atlas 350 加速卡 | x |
| Atlas A3 推理系列产品 / Atlas A3 训练系列产品 | √ |
| Atlas A2 训练系列产品 / Atlas A2 推理系列产品 | √ |
| Atlas 训练系列产品 | x |
| Atlas 推理系列产品 | x |
| Atlas 200I/500 A2 推理产品 | x |


#### 功能说明

从当前通信卡接收来自指定通信卡的数据。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;
    uint8_t rsv[64] = {0};
};
```


#### 参数列表

| 成员名称 | 类型 | 默认值 | 描述 |
| --- | --- | --- | --- |
| 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来初始化通信域。 配置请参见《HCCL集合通信库》的“rank table配置资源信息(https://www.hiascend.com/document/detail/zh/canncommercial/900/API/hcclug/hcclug\_000065.html)”。 |
| commDomain | std::string | \- | 通信device组用通信域名标识，多通信域时使用，当前仅支持hccl。 |
| rsv[64] | uint8\_t | {0} | 预留参数。 |


#### 输入

| 参数 | 维度 | 数据类型 | 格式 | 描述 |
| --- | --- | --- | --- | --- |
| 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，与输入维度相同。 |


#### 约束说明

- rank、rankSize、rankRoot需满足以下条件：

  - 0 ≤ rank < rankSize
  - 0 ≤ rankRoot < rankSize
  - 0 ≤ srcRank < rankSize

- 多用户使用时需要使用ATB_SHARE_MEMORY_NAME_SUFFIX环境变量（请参见  Transformer加速库环境变量说明
）进行共享内存的区分，以进行初始化信息同步。
- 当使用加速库的通信算子异常退出时，需要清空残留数据，避免影响之后的使用，命令参考如下：

```
rm -rf /dev/shm/sem.lccl*
rm -rf /dev/shm/sem.hccl*
ipcrm -a
```
