开发者
资源

HcommChannelGetNotifyNum

产品支持情况

产品

是否支持

Atlas 350 加速卡

Atlas A3 训练系列产品/Atlas A3 推理系列产品

Atlas A2 训练系列产品/Atlas A2 推理系列产品

Atlas 200I/500 A2 推理产品

Atlas 推理系列产品

Atlas 训练系列产品

功能说明

获取指定channel的Notify数量。

函数原型

1
HcclResult HcommChannelGetNotifyNum(ChannelHandle channelHandle, uint32_t *notifyNum)

参数说明

参数名

输入/输出

说明

channelHandle

输入

通信通道句柄。

ChannelHandle类型的定义可参见ChannelHandle

notifyNum

输出

指定channel的notify数量。

返回值

HcclResult:接口成功返回HCCL_SUCCESS,其他失败。

约束说明

调用示例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// AI CPU 引擎需要DEVICE类型的端点
 EndpointDesc deviceEp = {0};
 deviceEp.protocol = COMM_PROTOCOL_ROCE;
 deviceEp.commAddr.type = COMM_ADDR_TYPE_IP_V4;
 inet_pton(AF_INET, "192.168.1.10", &deviceEp.commAddr.addr);
 deviceEp.loc.locType = ENDPOINT_LOC_TYPE_DEVICE;
 deviceEp.loc.device.devPhyId = 0;
 deviceEp.loc.device.superPodId = 0;

 EndpointHandle endpointHandle = nullptr;
 HcclResult ret = HcommEndpointCreate(&deviceEp, &endpointHandle);
 if (ret != HCCL_SUCCESS) {
     printf("Failed to create device endpoint, ret = %d\n", ret);
     return ret;
 }

 // 准备通道描述符
 const uint32_t CHANNEL_NUM = 3;
 HcommChannelDesc channelDescs[CHANNEL_NUM] = {0};

 for (uint32_t i = 0; i < CHANNEL_NUM; i++) {
     // 填充远端端点信息
     channelDescs[i].remoteEndpoint.protocol = COMM_PROTOCOL_ROCE;
     channelDescs[i].remoteEndpoint.commAddr.type = COMM_ADDR_TYPE_IP_V4;
     char remoteIp[32] = {0};
     snprintf(remoteIp, sizeof(remoteIp), "192.168.2.%d", i + 1);
     inet_pton(AF_INET, remoteIp, &channelDescs[i].remoteEndpoint.commAddr.addr);
     channelDescs[i].remoteEndpoint.loc.locType = ENDPOINT_LOC_TYPE_DEVICE;
     channelDescs[i].remoteEndpoint.loc.device.devPhyId = i + 1;
     channelDescs[i].notifyNum = 32;
     // RoCE参数
     channelDescs[i].roceAttr.queueNum = 16;
     channelDescs[i].roceAttr.retryCnt = 5;
 }

 // 创建AI CPU引擎的通道
 ChannelHandle channels[CHANNEL_NUM] = {0};
 ret = HcommChannelCreate(endpointHandle, COMM_ENGINE_AICPU, channelDescs, CHANNEL_NUM, channels);
 if (ret != HCCL_SUCCESS) {
     printf("Failed to create AICPU channels, ret = %d\n", ret);
     HcommEndpointDestroy(endpointHandle);
     return ret;
 }
uint32_t *notifyNum;
ret = HcommChannelGetNotifyNum(channels[0], notifyNum);