Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #ifndef TOPOINFO_STRUCT_H
12 : #define TOPOINFO_STRUCT_H
13 :
14 : #include <string>
15 : #include <vector>
16 : #include <memory>
17 : #include <mutex>
18 : #include "hccl/base.h"
19 : #include "hccl_common.h"
20 : #include "adapter_pub.h"
21 : #include "externalinput_pub.h"
22 : #include "hccl_network_pub.h"
23 :
24 : namespace hccl {
25 : using NetworkInfo_t = struct tagNetworkInfo {
26 : std::string ethName; // [DEPRECATED]网卡名, 用于获取PCIe总线信息, 网卡在device侧时无效
27 : HcclIpAddress ipAddr; // [DEPRECATED]空字符串则表示没有配ip, 不得参与节点间通信
28 : u32 networkPort { 0 }; // [DEPRECATED]port接口
29 : HcclIpAddress refIp; // [DEPRECATED]reference ip
30 : u32 planeID { INVALID_UINT }; // [DEPRECATED]该网卡对应的网络平面ID, 用于控制网卡之间的建链
31 : };
32 :
33 : // [DEPRECATED] type ServerInfo_t
34 : using ServerInfo_t = struct tagServerInfo {
35 : std::string serverId; // 集群内服务器唯一标识
36 : std::vector<NetworkInfo_t> networkInfo; // [DEPRECATED]网卡信息
37 0 : bool operator == (const tagServerInfo &that)
38 : {
39 0 : return this->serverId == that.serverId;
40 : }
41 : };
42 :
43 : using DeviceInfo_t = struct tagDeviceInfo {
44 : s32 devicePhyId; // 服务器内device唯一标识
45 : DevType deviceType { DevType::DEV_TYPE_NOSOC }; // 服务器内device类型
46 : std::vector<HcclIpAddress> deviceIp; // device 对应的网卡ip
47 : std::vector<HcclIpAddress> backupDeviceIp; // 同一卡另一个device的网卡ip,应用于重执行借轨场景
48 : HcclIpAddress refIp; // [DEPRECATED]device 对应的ref ip
49 : u32 port { HCCL_INVALID_PORT };
50 : u32 vnicPort { HCCL_INVALID_PORT };
51 : u32 backupPort { HCCL_INVALID_PORT };
52 : NICDeployment nicDeploy{NICDeployment::NIC_DEPLOYMENT_DEVICE};
53 : u32 proto;
54 : };
55 :
56 : using TransportInfo_t = struct tagTransportInfo {
57 : u32 dstRankId;
58 : TransportType transportType;
59 : };
60 :
61 : using RankInfo_t = struct tagRankInfo {
62 : u32 rankId = 0xFFFFFFFF; // rank 标识,userRank,cloud时hcom计算填入
63 : u32 localRank = 0xFFFFFFFF; // 本server内rank号
64 : std::string serverId; // 集群内服务器唯一标识
65 : u32 serverIdx = INVALID_UINT; // Server在ranktable中的自然顺序(用户指定)
66 : u32 superDeviceId = INVALID_UINT; // 超节点device id,超节点内唯一
67 : std::string superPodId; // 超节点标识
68 : u32 superPodIdx = INVALID_UINT; // SuperPod在ranktable中的自然顺序(用户指定)
69 : HcclIpAddress hostIp; // 本server的host ip,用于host rdma通信
70 : u32 hostPort = HCCL_INVALID_PORT; // 本rank进行host socket通信使用的端口
71 : u32 nodeId = INVALID_UINT; // 离线编译逻辑ranktable 和NumaConfig中的node id相同
72 : s32 itemId = INVALID_UINT; // 离线编译逻辑ranktable 和NumaConfig中的item id相同
73 : std::string groupName; // [DEPRECATED]group名称
74 : std::string podName; // [DEPRECATED]容器名称
75 : DeviceInfo_t deviceInfo; // 设备信息
76 : std::vector<TransportInfo_t> transportInfo; // [DEPRECATED]本rank与其余rank的数据传输信息(抽象信息)
77 : s32 bindDeviceId = INVALID_INT; // 绑定的device id
78 : TlsStatus tlsStatus = TlsStatus::UNKNOWN; // TLS开关状态
79 : std::string originalSuperPodId; // 划分逻辑超节点前的原超节点ID,来源为用户配置
80 : };
81 :
82 : // 对外的ranktable格式
83 : using RankTable_t = struct tagRankTable {
84 : u32 deviceNum { 0 }; // 当前通信域内device数量
85 : u32 serverNum { 0 }; // 集群内服务器总数
86 : u32 superPodNum { 0 }; // 集群超节点总数
87 : u32 groupNum { 0 }; // [DEPRECATED]集群内group总数
88 : NICDeployment nicDeploy { NICDeployment::NIC_DEPLOYMENT_DEVICE }; // 网卡挂载位置 0:host 1:device
89 : u32 nicNum { 0 }; // [DEPRECATED]参数平面网卡数量
90 : std::vector<std::string> nicNames; // [DEPRECATED]参数平面网卡名称
91 : u32 rankNum { 0 }; // 通信域内的rank总数
92 : std::vector<RankInfo_t> rankList; // 通信域内所有的rank信息
93 : std::vector<ServerInfo_t> serverList; // [DEPRECATED]通信域内服务器信息 目前cloud和lab网卡在device场景置空
94 : std::string collectiveId; // 通信域ID
95 : std::string version; // rankTable版本信息
96 : std::string mode; // [DEPRECATED]通讯方式tcp/rdma
97 : };
98 :
99 : using RoleTableNodeInfo = struct RoleTableNodeInfoTag {
100 : u32 id;
101 : std::string serverId;
102 : HcclIpAddress ipAddr;
103 : u32 port;
104 : u32 rankId;
105 : HcclIpAddress hostIp;
106 : u32 hostPort{HCCL_INVALID_PORT};
107 : s32 devicePhyId;
108 0 : RoleTableNodeInfoTag()
109 0 : : id(INVALID_UINT), port(INVALID_UINT), rankId(INVALID_UINT), hostPort(INVALID_UINT), devicePhyId(INVALID_INT)
110 0 : {}
111 : };
112 :
113 : using RoleTableInfo = struct RoleTableInfoTag {
114 : std::vector<RoleTableNodeInfo> servers;
115 : std::vector<RoleTableNodeInfo> clients;
116 : };
117 :
118 : constexpr uint32_t ROOTINFO_INDENTIFIER_MAX_LENGTH = 128;
119 : constexpr uint32_t ROOTINFO_PORT_MAX_LENGTH = 16;
120 : using HcclRootHandle = struct HcclRootHandleDef {
121 : char ip[IP_ADDRESS_BUFFER_LEN];
122 : uint32_t port;
123 : NICDeployment nicDeploy;
124 : char identifier[ROOTINFO_INDENTIFIER_MAX_LENGTH];
125 : u32 rankId;
126 : };
127 :
128 : using HcclRankHandle = HcclRootHandle;
129 :
130 : using GroupLeader_t = struct tagGroupLeaderInfo {
131 : u32 grpLeaderNum { 0 };
132 : std::vector<HcclRankHandle> GroupLeaderList;
133 : };
134 :
135 : const std::string PROP_STEP = "step";
136 : const std::string PROP_RANK_NUM = "rank_num";
137 : const std::string PROP_DEV_NUM = "device_num";
138 : const std::string PROP_SRV_NUM = "server_num";
139 : const std::string PROP_DEV_INFO = "dev_info";
140 : const std::string PROP_RANK_LIST = "rank_list";
141 : const std::string PROP_RANK_ID = "rank_id";
142 : const std::string PROP_DEST_RANK = "dest_rank";
143 : const std::string PROP_SERVER_ID = "server_id";
144 : const std::string PROP_SERVER_LIST = "server_list";
145 : const std::string PROP_DEV_ID = "device_id";
146 : const std::string PROP_DEV_TYPE = "device_type";
147 : const std::string PROP_DEV_IP = "device_ip";
148 : const std::string PROP_DEV_NIC_PORT = "device_port";
149 : const std::string PROP_DEV_VNIC_PORT = "device_vnic_port";
150 : const std::string PROP_BACKUP_DEV_PORT = "backup_device_port";
151 : const std::string PROP_BACKUP_DEV_IP = "backup_device_ip";
152 : const std::string PROP_HOST_IP = "host_ip";
153 : const std::string PROP_DEPLOY_MODE = "deploy_mode";
154 : const std::string PROP_TRANS_INFO = "trans_info";
155 : const std::string PROP_TRANS_TYPE = "trans_type";
156 : const std::string PROP_TLS_STATUS = "tls_status";
157 :
158 : const std::string PROP_SERVER_COUNT = "server_count";
159 : const std::string PROP_DEVICE = "device";
160 : const std::string PROP_STATUS = "status";
161 : const std::string PROP_VERSION = "version";
162 :
163 : const std::string PROP_SUPER_POD_LIST = "super_pod_list";
164 : const std::string PROP_SUPER_POD_ID = "super_pod_id";
165 : const std::string PROP_SUPER_DEVICE_ID = "super_device_id";
166 : const std::string PROP_SUPER_POD_NUM = "super_pod_num";
167 :
168 : const std::string PROP_NETWORK_INFO_LIST = "network_info_list";
169 : const std::string PROP_NETWORK_ETHNAME = "eth_name";
170 : const std::string PROP_NETWORK_IPADDR = "ip_addr";
171 : const std::string PROP_NETWORK_NETWORKPORT = "network_port";
172 : const std::string PROP_NETWORK_REFIP = "ref_ip";
173 : const std::string PROP_NETWORK_PLANEID = "plane_id";
174 :
175 : const std::string PROP_NETWORK_IDENTIFIER = "identifier";
176 : const std::string PROP_GROUP_LEADER_LIST = "group_leader_list";
177 : const std::string PROP_GROUP_CLUSTER_LIST = "group_cluster_list";
178 :
179 : const std::string TOPO_DETECT_TAG = "topo_detect_default_tag";
180 : }
181 : #endif /* __TOPINFO_STRUCT_H__ */
|