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 : #include "base_config.h"
11 : #include <fstream>
12 : #include "log.h"
13 :
14 : namespace Hccl {
15 :
16 : // EnvHostNicConfig
17 :
18 16 : void EnvHostNicConfig::Parse()
19 : {
20 16 : hcclIfIp.Parse();
21 28 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_IF_IP set by %s to [%s]", hcclIfIp.GetSource(),
22 : GetControlIfIp().Describe().c_str());
23 :
24 16 : hcclIfBasePort.Parse();
25 28 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_IF_BASE_PORT set by %s to [%u]", hcclIfBasePort.GetSource(),
26 : GetIfBasePort());
27 :
28 16 : hcclSocketIfName.Parse();
29 28 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_SOCKET_IFNAME set by %s to [%s]", hcclSocketIfName.GetSource(),
30 : GetSocketIfName().configIfNameStr.c_str());
31 :
32 16 : whitelistDisable.Parse();
33 28 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_WHITELIST_DISABLE set by %s to [%d]", whitelistDisable.GetSource(),
34 : whitelistDisable.Get());
35 :
36 16 : if (!whitelistDisable.Get()) {
37 1 : hcclWhiteListFile.Parse();
38 3 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_WHITELIST_FILE set by %s to [%s]", hcclWhiteListFile.GetSource(),
39 : GetWhiteListFile().c_str());
40 : }
41 :
42 16 : hcclHostSocketPortRange.Parse();
43 16 : std::ostringstream hosrPortRangeOss;
44 17 : for (auto range : GetHostSocketPortRange()) {
45 1 : hosrPortRangeOss << "[" << range.min << ", " << range.max << "]";
46 : }
47 28 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_HOST_SOCKET_PORT_RANGE set by %s to %s", hcclHostSocketPortRange.GetSource(),
48 : hosrPortRangeOss.str().c_str());
49 :
50 16 : hcclDeviceSocketPortRange.Parse();
51 16 : std::ostringstream devicePortRangeOss;
52 16 : for (auto range : GetDeviceSocketPortRange()) {
53 0 : devicePortRangeOss << "[" << range.min << ", " << range.max << "]";
54 : }
55 28 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_NPU_SOCKET_PORT_RANGE set by %s to %s", hcclDeviceSocketPortRange.GetSource(),
56 : devicePortRangeOss.str().c_str());
57 16 : }
58 :
59 24 : const IpAddress &EnvHostNicConfig::GetControlIfIp() const
60 : {
61 24 : return hcclIfIp.Get();
62 : }
63 :
64 51 : u32 EnvHostNicConfig::GetIfBasePort() const
65 : {
66 51 : return hcclIfBasePort.Get();
67 : }
68 :
69 25 : const SocketIfName &EnvHostNicConfig::GetSocketIfName() const
70 : {
71 25 : return hcclSocketIfName.Get();
72 : }
73 :
74 42 : bool EnvHostNicConfig::GetWhitelistDisable() const
75 : {
76 42 : return whitelistDisable.Get();
77 : }
78 :
79 2 : const std::string &EnvHostNicConfig::GetWhiteListFile() const
80 : {
81 2 : return hcclWhiteListFile.Get();
82 : }
83 :
84 54 : const std::vector<SocketPortRange> &EnvHostNicConfig::GetHostSocketPortRange() const
85 : {
86 54 : return hcclHostSocketPortRange.Get();
87 : }
88 :
89 18 : const std::vector<SocketPortRange> &EnvHostNicConfig::GetDeviceSocketPortRange() const
90 : {
91 18 : return hcclDeviceSocketPortRange.Get();
92 : }
93 :
94 : // EnvSocketConfig
95 :
96 16 : void EnvSocketConfig::Parse()
97 : {
98 16 : hcclSocketFamily.Parse();
99 28 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_SOCKET_FAMILY set by %s to [%d]", hcclSocketFamily.GetSource(),
100 : GetSocketFamily());
101 :
102 16 : linkTimeOut.Parse();
103 28 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_CONNECT_TIMEOUT set by %s to [%d]s", linkTimeOut.GetSource(),
104 : GetLinkTimeOut());
105 16 : }
106 :
107 23 : s32 EnvSocketConfig::GetSocketFamily() const
108 : {
109 23 : return hcclSocketFamily.Get();
110 : }
111 :
112 68 : s32 EnvSocketConfig::GetLinkTimeOut() const
113 : {
114 68 : return linkTimeOut.Get();
115 : }
116 :
117 : // EnvRtsConfig
118 :
119 16 : void EnvRtsConfig::Parse()
120 : {
121 16 : execTimeOut.Parse();
122 16 : aivExecTimeOut.Parse();
123 28 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_EXEC_TIMEOUT set by %s to [%u]s", execTimeOut.GetSource(),
124 : GetExecTimeOut());
125 16 : }
126 :
127 199 : u32 EnvRtsConfig::GetExecTimeOut() const
128 : {
129 199 : return execTimeOut.Get();
130 : }
131 :
132 1 : double EnvRtsConfig::GetAivExecTimeOut() const
133 : {
134 1 : return aivExecTimeOut.Get();
135 : }
136 :
137 : // EnvRdmaConfig
138 :
139 27 : void EnvRdmaConfig::Parse()
140 : {
141 27 : rdmaTrafficClass.Parse();
142 61 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_RDMA_TC set by %s to [%u]", rdmaTrafficClass.GetSource(),
143 : GetRdmaTrafficClass());
144 :
145 27 : rdmaServerLevel.Parse();
146 61 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_RDMA_SL set by %s to [%u]", rdmaServerLevel.GetSource(),
147 : GetRdmaServerLevel());
148 :
149 27 : rdmaTimeOut.Parse();
150 61 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_RDMA_TIMEOUT set by %s to [%u]", rdmaTimeOut.GetSource(),
151 : GetRdmaTimeOut());
152 :
153 27 : rdmaRetryCnt.Parse();
154 61 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_RDMA_RETRY_CNT set by %s to [%u]", rdmaRetryCnt.GetSource(),
155 : GetRdmaRetryCnt());
156 :
157 27 : uboeTimeOut.Parse();
158 58 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_UBOE_TIMEOUT set by %s to [%u]", uboeTimeOut.GetSource(),
159 : GetUboeTimeOut());
160 :
161 26 : ubTimeOut.Parse();
162 55 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_UB_TIMEOUT set by %s to [%u]", ubTimeOut.GetSource(),
163 : GetUbTimeOut());
164 :
165 25 : queueNum.Parse();
166 52 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_RDMA_QPS_PER_CONNECTION set by %s to [%u]", queueNum.GetSource(),
167 : GetRdmaQueueNum());
168 :
169 24 : multiQpThreshold.Parse();
170 49 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_MULTI_QP_THRESHOLD set by %s to [%u]B", multiQpThreshold.GetSource(),
171 : GetRdmaMultiQpThreshold());
172 23 : }
173 :
174 33 : u32 EnvRdmaConfig::GetRdmaTrafficClass() const
175 : {
176 33 : return rdmaTrafficClass.Get();
177 : }
178 :
179 33 : u32 EnvRdmaConfig::GetRdmaServerLevel() const
180 : {
181 33 : return rdmaServerLevel.Get();
182 : }
183 :
184 28 : u32 EnvRdmaConfig::GetRdmaTimeOut() const
185 : {
186 28 : return rdmaTimeOut.Get();
187 : }
188 :
189 28 : u32 EnvRdmaConfig::GetRdmaRetryCnt() const
190 : {
191 28 : return rdmaRetryCnt.Get();
192 : }
193 :
194 29 : u32 EnvRdmaConfig::GetUboeTimeOut() const
195 : {
196 29 : return uboeTimeOut.Get();
197 : }
198 :
199 130 : u32 EnvRdmaConfig::GetUbTimeOut() const
200 : {
201 130 : return ubTimeOut.Get();
202 : }
203 25 : u32 EnvRdmaConfig::GetRdmaQueueNum() const
204 : {
205 25 : return queueNum.Get();
206 : }
207 :
208 26 : u32 EnvRdmaConfig::GetRdmaMultiQpThreshold() const
209 : {
210 26 : return multiQpThreshold.Get();
211 : }
212 :
213 : // EnvAlgoConfig
214 :
215 19 : void EnvAlgoConfig::Parse()
216 : {
217 19 : primQueueGenName.Parse();
218 35 : HCCL_RUN_INFO("[HCCL_ENV] PRIM_QUEUE_GEN_NAME set by %s to [%s]", primQueueGenName.GetSource(),
219 : GetPrimQueueGenName().c_str());
220 :
221 19 : hcclAlgoConfig.Parse();
222 17 : std::ostringstream hcclAlgoConfigOss;
223 18 : for (auto algoConfig : GetAlgoConfig()) {
224 1 : OpType opType = algoConfig.first;
225 1 : hcclAlgoConfigOss << "[" << opType.Describe().c_str() << ", ";
226 1 : std::vector<HcclAlgoType> algoTypes = algoConfig.second;
227 5 : for (auto algoType : algoTypes) {
228 4 : hcclAlgoConfigOss << algoType.Describe().c_str() << " ";
229 : }
230 1 : hcclAlgoConfigOss << "]";
231 1 : }
232 29 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_ALGO set by %s to [%s]", hcclAlgoConfig.GetSource(),
233 : hcclAlgoConfigOss.str().c_str());
234 :
235 17 : bufferSize.Parse();
236 29 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_BUFFSIZE set by %s to [%llu]B", bufferSize.GetSource(),
237 : GetBuffSize());
238 :
239 17 : hcclAccelerator_.Parse();
240 29 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_OP_EXPANSION_MODE set by %s to [%s]", hcclAccelerator_.GetSource(),
241 : GetHcclAccelerator().Describe().c_str());
242 17 : }
243 :
244 20 : const std::string &EnvAlgoConfig::GetPrimQueueGenName() const
245 : {
246 20 : return primQueueGenName.Get();
247 : }
248 :
249 19 : const std::map<OpType, std::vector<HcclAlgoType>> &EnvAlgoConfig::GetAlgoConfig() const
250 : {
251 19 : return hcclAlgoConfig.Get();
252 : }
253 :
254 35 : u64 EnvAlgoConfig::GetBuffSize() const
255 : {
256 35 : return bufferSize.Get();
257 : }
258 :
259 33 : HcclAccelerator EnvAlgoConfig::GetHcclAccelerator() const
260 : {
261 33 : return hcclAccelerator_.Get();
262 : }
263 :
264 : // EnvLogConfig
265 16 : void EnvLogConfig::Parse()
266 : {
267 16 : entryLogEnable.Parse();
268 28 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_ENTRY_LOG_ENABLE set by %s to [%d]", entryLogEnable.GetSource(),
269 : GetEntryLogEnable());
270 :
271 16 : cannVersion.Parse();
272 28 : HCCL_RUN_INFO("[HCCL_ENV] LD_LIBRARY_PATH set by %s to [%s]", cannVersion.GetSource(),
273 : GetCannVersion().c_str());
274 :
275 16 : dfsConfig.Parse();
276 28 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_DFS_CONFIG task_exception set by %s to [%d], cluster_heartbeat set by %s to [%d], "
277 : "rankConsistentState set by %s to [%d]",
278 : dfsConfig.GetSource(), GetDfsConfig().taskExceptionEnable, dfsConfig.GetSource(),
279 : GetDfsConfig().clusterHeartBeatEnable, dfsConfig.GetSource(), GetDfsConfig().rankConsistentState);
280 16 : }
281 :
282 156 : bool EnvLogConfig::GetEntryLogEnable() const
283 : {
284 156 : return entryLogEnable.Get();
285 : }
286 :
287 17 : const std::string &EnvLogConfig::GetCannVersion() const
288 : {
289 17 : return cannVersion.Get();
290 : }
291 :
292 208 : const DfsConfig &EnvLogConfig::GetDfsConfig() const
293 : {
294 208 : return dfsConfig.Get();
295 : }
296 :
297 : // EnvDetourConfig
298 :
299 16 : void EnvDetourConfig::Parse()
300 : {
301 16 : detourType.Parse();
302 28 : HCCL_RUN_INFO("[HCCL_ENV] HCCL_DETOUR set by %s to [%s]", detourType.GetSource(),
303 : GetDetourType().Describe().c_str());
304 16 : }
305 :
306 261 : HcclDetourType EnvDetourConfig::GetDetourType() const
307 : {
308 261 : return detourType.Get();
309 : }
310 :
311 : } // namespace Hccl
|