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 : #include <unordered_set>
12 : #include <cstring>
13 : #include "log.h"
14 : #include "hccl/base.h"
15 : #include "rank_consistentcy_checker.h"
16 : #include "topoinfo_ranktableParser_pub.h"
17 : #include "config.h"
18 : #include "param_check.h"
19 :
20 : using namespace std;
21 : using namespace hccl;
22 :
23 : struct EnumHash {
24 : template <typename T>
25 1262 : std::size_t operator()(T t) const
26 : {
27 1262 : return static_cast<std::size_t>(t);
28 : }
29 : };
30 :
31 : const std::unordered_set<HcclDataType, EnumHash> HCCL_SUPPORT_DATA_TYPE
32 : = {HCCL_DATA_TYPE_INT8, HCCL_DATA_TYPE_INT16, HCCL_DATA_TYPE_INT32, HCCL_DATA_TYPE_FP16, HCCL_DATA_TYPE_FP32,
33 : HCCL_DATA_TYPE_INT64, HCCL_DATA_TYPE_UINT64, HCCL_DATA_TYPE_UINT8, HCCL_DATA_TYPE_UINT16, HCCL_DATA_TYPE_UINT32,
34 : HCCL_DATA_TYPE_FP64, HCCL_DATA_TYPE_BFP16, HCCL_DATA_TYPE_INT128};
35 :
36 : const std::unordered_set<HcclReduceOp, EnumHash> HCCL_SUPPORT_REDUCE_OP
37 : = {HCCL_REDUCE_SUM, HCCL_REDUCE_PROD, HCCL_REDUCE_MAX, HCCL_REDUCE_MIN};
38 :
39 393 : HcclResult HcomGetRanktableRealPath(const char* rankTable, std::string& realFilePath)
40 : {
41 393 : CHK_PTR_NULL(rankTable);
42 :
43 393 : u32 rankTablePathLen = strnlen(rankTable, RANK_TABLE_MAX_LEN + 1);
44 393 : if (rankTablePathLen == (RANK_TABLE_MAX_LEN + 1) || rankTablePathLen == 0) {
45 0 : RPT_INPUT_ERR(
46 : true, "EI0004", std::vector<std::string>({"ranktable_path", "error_reason"}),
47 : std::vector<std::string>(
48 : {std::string(rankTable), "rankTable path length is " + std::to_string(rankTablePathLen)
49 : + ", expect value is 0~" + std::to_string(RANK_TABLE_MAX_LEN)}));
50 0 : HCCL_ERROR(
51 : "[%s][%s]errNo[0x%016llx] rankTable file name is invalid, len is %u", LOG_KEYWORDS_INIT_GROUP.c_str(),
52 : LOG_KEYWORDS_RANKTABLE_CONFIG.c_str(), HCOM_ERROR_CODE(HCCL_E_PARA), rankTablePathLen);
53 0 : return HCCL_E_PARA;
54 : }
55 : // 校验文件是否存在
56 393 : char realFile[PATH_MAX] = {0};
57 393 : if (realpath(rankTable, realFile) == nullptr) {
58 22 : RPT_INPUT_ERR(
59 : true, "EI0004", std::vector<std::string>({"ranktable_path", "error_reason"}),
60 : std::vector<std::string>(
61 : {std::string(rankTable), "rankTable path \"" + std::string(realFile) + "\" not a valid real path"}));
62 2 : HCCL_ERROR(
63 : "[%s][%s]errNo[0x%016llx] path %s is not a valid real path", LOG_KEYWORDS_INIT_GROUP.c_str(),
64 : LOG_KEYWORDS_RANKTABLE_CONFIG.c_str(), HCOM_ERROR_CODE(HCCL_E_PARA), rankTable);
65 2 : return HCCL_E_PARA;
66 : }
67 391 : realFilePath = std::string(realFile);
68 391 : return HCCL_SUCCESS;
69 6 : }
70 :
71 235 : HcclResult HcomCheckRankTable(const char* rankTableM, u32& rankTableSize)
72 : {
73 235 : CHK_PTR_NULL(rankTableM);
74 :
75 235 : size_t rankTableLen = strnlen(rankTableM, STRING_MAX_LENGTH + 1);
76 235 : if (rankTableLen == (STRING_MAX_LENGTH + 1) || rankTableLen == 0) {
77 0 : RPT_INPUT_ERR(
78 : true, "EI0004", std::vector<std::string>({"ranktable_path", "error_reason"}),
79 : std::vector<std::string>(
80 : {std::string(rankTableM), "rankTable path length is " + std::to_string(rankTableLen)
81 : + ", expect value is 0~" + std::to_string(STRING_MAX_LENGTH)}));
82 0 : HCCL_ERROR(
83 : "[%s][%s]errNo[0x%016llx] rankTable string is invalid, len is %u", LOG_KEYWORDS_INIT_GROUP.c_str(),
84 : LOG_KEYWORDS_RANKTABLE_CONFIG.c_str(), HCOM_ERROR_CODE(HCCL_E_PARA), rankTableLen);
85 0 : return HCCL_E_PARA;
86 : }
87 :
88 235 : rankTableSize = rankTableLen;
89 235 : return HCCL_SUCCESS;
90 0 : }
91 :
92 393 : HcclResult HcomLoadRanktableFile(const char* rankTablePath, std::string& rankTableM, std::string& realFilePath)
93 : {
94 393 : CHK_PTR_NULL(rankTablePath);
95 :
96 393 : HcclResult ret = HcomGetRanktableRealPath(rankTablePath, realFilePath);
97 393 : CHK_PRT_RET(
98 : ret != HCCL_SUCCESS, HCCL_ERROR("[HcomLoadRanktableFile]get file[%s] real path error", rankTablePath),
99 : HCCL_E_PARA);
100 391 : TopoInfoRanktableParser myTopoRanktable(realFilePath, "0");
101 391 : CHK_RET(myTopoRanktable.LoadFileInit(rankTableM));
102 :
103 390 : return HCCL_SUCCESS;
104 391 : }
105 :
106 236 : HcclResult HcomCalcCRC(hccl::HcclCommParams& params, const char* rankTable)
107 : {
108 236 : CHK_RET(RankConsistentcyChecker::GetInstance().CalcStringCrc(rankTable, params.ranktableCrc));
109 236 : return HCCL_SUCCESS;
110 : }
111 :
112 0 : HcclResult HcomCheckIdentify(const char* identify)
113 : {
114 0 : CHK_PTR_NULL(identify);
115 :
116 0 : u32 identifyLen = strnlen(identify, IDENTIFY_MAX_LEN + 1);
117 0 : if (identifyLen == (IDENTIFY_MAX_LEN + 1) || identifyLen == 0) {
118 0 : HCCL_ERROR(
119 : "[Check][Identify]errNo[0x%016llx] identify name is invalid, len is %u", HCOM_ERROR_CODE(HCCL_E_PARA),
120 : identifyLen);
121 0 : return HCCL_E_PARA;
122 : }
123 0 : return HCCL_SUCCESS;
124 : }
125 :
126 0 : HcclResult HcomCheckDeviceId(const u32 device_id)
127 : {
128 0 : if (device_id >= HCCL_AISERVER_DEVICE_NUM) {
129 0 : HCCL_ERROR(
130 : "[Check][DeviceId]errNo[0x%016llx] device_id[%u] is invalid,should in (0~7)", HCOM_ERROR_CODE(HCCL_E_PARA),
131 : device_id);
132 0 : return HCCL_E_PARA;
133 : }
134 0 : return HCCL_SUCCESS;
135 : }
136 :
137 252 : HcclResult HcomCheckTag(const char* tag)
138 : {
139 252 : CHK_PTR_NULL(tag);
140 :
141 252 : u32 tagLen = strnlen(tag, TAG_MAX_LEN + 1);
142 252 : if (tagLen == (TAG_MAX_LEN + 1) || tagLen == 0) {
143 0 : HCCL_ERROR(
144 : "[Check][Tag]errNo[0x%016llx] tag is too long, range[1,%u]", HCOM_ERROR_CODE(HCCL_E_PARA), TAG_MAX_LEN);
145 0 : return HCCL_E_PARA;
146 : }
147 252 : return HCCL_SUCCESS;
148 : }
149 :
150 325 : HcclResult HcomCheckCount(const u64 count)
151 : {
152 325 : if (count > SYS_MAX_COUNT) {
153 7 : HCCL_ERROR(
154 : "[Check][Count]errNo[0x%016llx] count[%llu] is invalid(bigger than MAX count[%llu])",
155 : HCOM_ERROR_CODE(HCCL_E_PARA), count, SYS_MAX_COUNT);
156 7 : return HCCL_E_PARA;
157 : }
158 318 : return HCCL_SUCCESS;
159 : }
160 :
161 28 : HcclResult HcomCheckAlltoAllVExternalMem(
162 : const void* sendBuf, const void* sendCounts, const void* recvBuf, const void* recvCounts, u32 rankSize)
163 : {
164 28 : CHK_PRT_RET(
165 : sendBuf != nullptr && recvBuf != nullptr && sendBuf == recvBuf,
166 : HCCL_ERROR("[HcomCheckAlltoAllVExternalMem] sendBuf and recvBuf cannot be same."), HCCL_E_PARA);
167 :
168 27 : u64* sendCountsPtr = const_cast<u64*>(static_cast<const u64*>(sendCounts));
169 27 : u64* recvCountsPtr = const_cast<u64*>(static_cast<const u64*>(recvCounts));
170 27 : bool hasSend = false;
171 27 : bool hasRecv = false;
172 27 : bool invalidSendCount = false;
173 27 : bool invalidRecvCount = false;
174 61 : for (u32 i = 0; i < rankSize; i++) {
175 34 : if (*(sendCountsPtr + i) != 0) {
176 33 : invalidSendCount = invalidSendCount || (*(sendCountsPtr + i) > SYS_MAX_COUNT);
177 33 : hasSend = true;
178 : }
179 34 : if (*(recvCountsPtr + i) != 0) {
180 33 : invalidRecvCount = invalidRecvCount || (*(recvCountsPtr + i) > SYS_MAX_COUNT);
181 33 : hasRecv = true;
182 : }
183 : }
184 :
185 27 : if (invalidSendCount || invalidRecvCount || HcclCheckLogLevel(DLOG_DEBUG)) {
186 54 : std::string sendCountStr = "sendCounts:";
187 27 : std::string recvCountStr = "recvCounts:";
188 61 : for (u32 i = 0; i < rankSize; i++) {
189 34 : sendCountStr += ' ' + std::to_string(*(sendCountsPtr + i));
190 34 : recvCountStr += ' ' + std::to_string(*(recvCountsPtr + i));
191 : }
192 :
193 27 : CHK_PRT_RET(
194 : invalidSendCount,
195 : HCCL_ERROR(
196 : "HcomCheckAlltoAllVExternalMem sendCounts[%s] is invalid.(bigger than MAX count[%llu])",
197 : sendCountStr.c_str(), SYS_MAX_COUNT),
198 : HCCL_E_PARA);
199 27 : CHK_PRT_RET(
200 : invalidRecvCount,
201 : HCCL_ERROR(
202 : "HcomCheckAlltoAllVExternalMem recvCounts[%s] is invalid.(bigger than MAX count[%llu])",
203 : recvCountStr.c_str(), SYS_MAX_COUNT),
204 : HCCL_E_PARA);
205 :
206 27 : HCCL_DEBUG("[HcomCheckAlltoAllVExternalMem] sendCounts: %s", sendCountStr.c_str());
207 27 : HCCL_DEBUG("[HcomCheckAlltoAllVExternalMem] recvCounts: %s", recvCountStr.c_str());
208 27 : }
209 :
210 27 : if (hasSend) {
211 46 : RPT_INPUT_ERR(
212 : sendBuf == nullptr, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}),
213 : std::vector<std::string>({"HcomCheckAlltoAllVExternalMem", "nullptr", "sendBuf", "not nullptr"}));
214 26 : CHK_PTR_NULL(sendBuf);
215 : }
216 26 : if (hasRecv) {
217 45 : RPT_INPUT_ERR(
218 : recvBuf == nullptr, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}),
219 : std::vector<std::string>({"HcomCheckAlltoAllVExternalMem", "nullptr", "recvBuf", "not nullptr"}));
220 25 : CHK_PTR_NULL(recvBuf);
221 : }
222 25 : return HCCL_SUCCESS;
223 : }
224 :
225 0 : HcclResult HcomCheckAlltoAllVCExternalMem(
226 : const void* sendBuf, const void* sendCountMatrix, const void* recvBuf, u32 rankSize, u32 rank)
227 : {
228 0 : CHK_PRT_RET(
229 : sendBuf != nullptr && recvBuf != nullptr && sendBuf == recvBuf,
230 : HCCL_ERROR("[HcomCheckAlltoAllVCExternalMem] sendBuf and recvBuf cannot be same."), HCCL_E_PARA);
231 :
232 0 : u64* sendCountMatrixPtr = const_cast<u64*>(static_cast<const u64*>(sendCountMatrix));
233 0 : bool hasSend = false;
234 0 : bool hasRecv = false;
235 :
236 0 : for (u32 i = 0; i < rankSize; i++) {
237 0 : for (u32 j = 0; j < rankSize; j++) {
238 0 : HCCL_DEBUG(
239 : "[HcomCheckAlltoAllVCExternalMem] sendCounts[%u][%u]: %llu", i, j,
240 : *(sendCountMatrixPtr + i * rankSize + j));
241 : }
242 0 : CHK_RET(HcomCheckCount(*(sendCountMatrixPtr + rank * rankSize + i)));
243 0 : if (hasSend == false && *(sendCountMatrixPtr + rank * rankSize + i) != 0) {
244 0 : hasSend = true;
245 : }
246 0 : if (hasRecv == false && *(sendCountMatrixPtr + i * rankSize + rank) != 0) {
247 0 : hasRecv = true;
248 : }
249 : }
250 0 : if (hasSend) {
251 0 : RPT_INPUT_ERR(
252 : sendBuf == nullptr, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}),
253 : std::vector<std::string>({"HcomCheckAlltoAllVCExternalMem", "nullptr", "sendBuf", "not nullptr"}));
254 0 : CHK_PTR_NULL(sendBuf);
255 : }
256 0 : if (hasRecv) {
257 0 : RPT_INPUT_ERR(
258 : recvBuf == nullptr, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}),
259 : std::vector<std::string>({"HcomCheckAlltoAllVCExternalMem", "nullptr", "recvBuf", "not nullptr"}));
260 0 : CHK_PTR_NULL(recvBuf);
261 : }
262 0 : return HCCL_SUCCESS;
263 : }
264 :
265 0 : void HcomGetHashFromSendCountMatrix(
266 : u64& sendCountMatrixHash, const void* sendCountMatrix, u64 rankSize, const std::string& tag)
267 : {
268 0 : std::string sendCountMatrixStr;
269 : std::hash<std::string> hashString;
270 0 : for (u32 i = 0; i < rankSize; i++) {
271 0 : for (u32 j = 0; j < rankSize; j++) {
272 : std::string curSendCountStr
273 0 : = std::to_string(*(static_cast<const u64*>(sendCountMatrix) + i * rankSize + j));
274 0 : sendCountMatrixStr += curSendCountStr + '_';
275 0 : }
276 : }
277 0 : sendCountMatrixHash = hashString(sendCountMatrixStr.c_str());
278 0 : HCCL_DEBUG("[HcomGetHashFromSendCountMatrix] tag[%s], sendCountMatrixHash[%llu]", tag.c_str(), sendCountMatrixHash);
279 0 : }
280 :
281 364 : HcclResult HcomCheckDataType(const HcclDataType dataType)
282 : {
283 364 : if (HCCL_SUPPORT_DATA_TYPE.find(dataType) == HCCL_SUPPORT_DATA_TYPE.end()) {
284 0 : HCCL_ERROR(
285 : "[Check][DataType]errNo[0x%016llx] data type[%s] not supported", HCOM_ERROR_CODE(HCCL_E_NOT_SUPPORT),
286 : GetDataTypeEnumStr(dataType).c_str());
287 0 : return HCCL_E_NOT_SUPPORT;
288 : }
289 364 : return HCCL_SUCCESS;
290 : }
291 :
292 7 : HcclResult HcomCheckGroupName(const char* group)
293 : {
294 7 : if (group != nullptr) {
295 3 : u32 groupLen = strnlen(group, GROUP_NAME_MAX_LEN + 1);
296 3 : if (groupLen == (GROUP_NAME_MAX_LEN + 1) || groupLen == 0) {
297 0 : HCCL_ERROR(
298 : "[Check][GroupName]errNo[0x%016llx] group name[%s] length[%lu] is invalid",
299 : HCOM_ERROR_CODE(HCCL_E_PARA), group, groupLen);
300 0 : return HCCL_E_PARA;
301 : }
302 : }
303 7 : return HCCL_SUCCESS;
304 : }
305 :
306 99 : HcclResult HcomCheckReductionOp(const std::string& callerOpName, const HcclReduceOp op)
307 : {
308 99 : if (HCCL_SUPPORT_REDUCE_OP.find(op) == HCCL_SUPPORT_REDUCE_OP.end()) {
309 0 : std::string supportedOpsStr;
310 0 : for (const auto& supportedOp : HCCL_SUPPORT_REDUCE_OP) {
311 0 : if (!supportedOpsStr.empty()) {
312 0 : supportedOpsStr += ", ";
313 : }
314 0 : supportedOpsStr += GetReduceOpEnumStr(supportedOp);
315 : }
316 0 : RPT_INPUT_ERR(
317 : true, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}),
318 : std::vector<std::string>({callerOpName, GetReduceOpEnumStr(op), "op", supportedOpsStr}));
319 0 : HCCL_ERROR(
320 : "[%s][%s]errNo[0x%016llx] Op:[%s] not supported", LOG_KEYWORDS_TASK_EXEC.c_str(),
321 : LOG_KEYWORDS_INVALID_ARGUMENT.c_str(), HCOM_ERROR_CODE(HCCL_E_NOT_SUPPORT), GetReduceOpEnumStr(op).c_str());
322 0 : return HCCL_E_NOT_SUPPORT;
323 0 : }
324 99 : return HCCL_SUCCESS;
325 0 : }
326 :
327 99 : HcclResult HcomCheckReduceDataType(const HcclDataType dataType, const HcclReduceOp op, DevType deviceType)
328 : {
329 99 : if ((deviceType == DevType::DEV_TYPE_910B) || (deviceType == DevType::DEV_TYPE_910_93)) {
330 7 : if ((op == HCCL_REDUCE_PROD) && ((dataType == HCCL_DATA_TYPE_INT16) || (dataType == HCCL_DATA_TYPE_BFP16))) {
331 51 : RPT_INPUT_ERR(
332 : true, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}),
333 : std::vector<std::string>(
334 : {"HcomCheckReduceDataType", GetDataTypeEnumStr(dataType), "dataType", "float16, float32, int32"}));
335 3 : HCCL_ERROR(
336 : "[%s][%s]errNo[0x%016llx] device type[%d] does not support the data type[%s] and data "
337 : "type[%s] for Op[%s]",
338 : LOG_KEYWORDS_TASK_EXEC.c_str(), LOG_KEYWORDS_INVALID_ARGUMENT.c_str(),
339 : HCCL_ERROR_CODE(HCCL_E_NOT_SUPPORT), deviceType,
340 : GetDataTypeEnumStr(HcclDataType::HCCL_DATA_TYPE_BFP16).c_str(),
341 : GetDataTypeEnumStr(HcclDataType::HCCL_DATA_TYPE_INT16).c_str(), GetReduceOpEnumStr(op).c_str());
342 3 : return HCCL_E_NOT_SUPPORT;
343 : }
344 92 : } else if (deviceType == DevType::DEV_TYPE_910) {
345 92 : if (dataType == HCCL_DATA_TYPE_INT16) {
346 0 : RPT_INPUT_ERR(
347 : true, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}),
348 : std::vector<std::string>(
349 : {"HcomCheckReduceDataType", GetDataTypeEnumStr(dataType), "dataType", "float16, float32"}));
350 0 : HCCL_ERROR(
351 : "[%s][%s]errNo[0x%016llx] device type[%d] does not support the data type[%s]",
352 : LOG_KEYWORDS_TASK_EXEC.c_str(), LOG_KEYWORDS_INVALID_ARGUMENT.c_str(),
353 : HCCL_ERROR_CODE(HCCL_E_NOT_SUPPORT), deviceType, GetDataTypeEnumStr(dataType).c_str());
354 0 : return HCCL_E_NOT_SUPPORT;
355 : }
356 0 : } else if (deviceType == DevType::DEV_TYPE_310P3) {
357 0 : if (dataType == HcclDataType::HCCL_DATA_TYPE_INT16 && op != HcclReduceOp::HCCL_REDUCE_SUM) {
358 0 : RPT_INPUT_ERR(
359 : true, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}),
360 : std::vector<std::string>({"HcomCheckReduceDataType", GetReduceOpEnumStr(op), "op", "sum"}));
361 0 : HCCL_ERROR(
362 : "[%s][%s]errNo[0x%016llx] device type[%d] does not support the data type[%s] for Op[%s]",
363 : LOG_KEYWORDS_TASK_EXEC.c_str(), LOG_KEYWORDS_INVALID_ARGUMENT.c_str(),
364 : HCCL_ERROR_CODE(HCCL_E_NOT_SUPPORT), deviceType,
365 : GetDataTypeEnumStr(HcclDataType::HCCL_DATA_TYPE_INT16).c_str(), GetReduceOpEnumStr(op).c_str());
366 0 : return HCCL_E_NOT_SUPPORT;
367 : }
368 : }
369 96 : return HCCL_SUCCESS;
370 6 : }
371 :
372 148 : HcclResult HcomCheckUserRank(const u32 totalRanks, const u32 userRank)
373 : {
374 148 : if (userRank >= totalRanks) {
375 1 : HCCL_ERROR(
376 : "[Check][UserRank]errNo[0x%016llx] userRank:[%u] is out of range[0 ~ %u]", HCOM_ERROR_CODE(HCCL_E_PARA),
377 : userRank, totalRanks - 1);
378 1 : return HCCL_E_PARA;
379 : }
380 147 : return HCCL_SUCCESS;
381 : }
382 :
383 : HcclResult
384 0 : HcomCheckOpParam(const char* tag, const u64 count, const HcclDataType dataType, const char* group, const void* stream)
385 : {
386 0 : HcclResult ret = HcomCheckGroupName(group);
387 0 : RPT_INPUT_ERR(
388 : ret != HCCL_SUCCESS, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}),
389 : std::vector<std::string>({tag, group, "group", "non-empty string with only letters, dights, and underscores"}));
390 0 : CHK_PRT_RET(
391 : ret != HCCL_SUCCESS,
392 : HCCL_ERROR(
393 : "[%s][%s]errNo[0x%016llx] group name is invalid", LOG_KEYWORDS_TASK_EXEC.c_str(),
394 : LOG_KEYWORDS_INVALID_ARGUMENT.c_str(), HCOM_ERROR_CODE(ret)),
395 : ret);
396 :
397 0 : CHK_RET(HcomCheckOpParam(tag, count, dataType, stream));
398 :
399 0 : return HCCL_SUCCESS;
400 0 : }
401 :
402 252 : HcclResult HcomCheckOpParam(const char* tag, const u64 count, const HcclDataType dataType, const void* stream)
403 : {
404 252 : CHK_RET(HcomCheckOpParam(tag, count, dataType));
405 :
406 245 : RPT_INPUT_ERR(
407 : stream == nullptr, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}),
408 : std::vector<std::string>({tag, "nullptr", "stream", "non-null device stream pointer"}));
409 245 : CHK_PTR_NULL(stream);
410 :
411 245 : return HCCL_SUCCESS;
412 0 : }
413 :
414 252 : HcclResult HcomCheckOpParam(const char* tag, const u64 count, const HcclDataType dataType)
415 : {
416 252 : HcclResult ret = HcomCheckTag(tag);
417 252 : RPT_INPUT_ERR(
418 : ret != HCCL_SUCCESS, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}),
419 : std::vector<std::string>(
420 : {"HcomCheckTag", tag == nullptr ? "nullptr" : tag, "tag",
421 : "supported operation name (e.g., \"AllReduce\", \"AllGather\")"}));
422 252 : CHK_PRT_RET(
423 : ret != HCCL_SUCCESS,
424 : HCCL_ERROR(
425 : "[%s][%s]errNo[0x%016llx] tag is invalid", LOG_KEYWORDS_TASK_EXEC.c_str(),
426 : LOG_KEYWORDS_INVALID_ARGUMENT.c_str(), HCOM_ERROR_CODE(ret)),
427 : ret);
428 :
429 252 : ret = HcomCheckCount(count);
430 364 : RPT_INPUT_ERR(
431 : ret != HCCL_SUCCESS, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}),
432 : std::vector<std::string>({tag, std::to_string(count), "count", "positive integer (>=1)"}));
433 252 : CHK_PRT_RET(
434 : ret != HCCL_SUCCESS,
435 : HCCL_ERROR(
436 : "[%s][%s]errNo[0x%016llx] count is out of range", LOG_KEYWORDS_TASK_EXEC.c_str(),
437 : LOG_KEYWORDS_INVALID_ARGUMENT.c_str(), HCOM_ERROR_CODE(ret)),
438 : ret);
439 :
440 245 : ret = HcomCheckDataType(dataType);
441 245 : RPT_INPUT_ERR(
442 : ret != HCCL_SUCCESS, "EI0003", std::vector<std::string>({"ccl_op", "value", "parameter", "expect"}),
443 : std::vector<std::string>(
444 : {tag, GetDataTypeEnumStr(dataType), "dataType",
445 : "valid data type (e.g., HCCL_DATA_TYPE_FP32, HCCL_DATA_TYPE_INT64)"}));
446 245 : CHK_PRT_RET(
447 : ret != HCCL_SUCCESS,
448 : HCCL_ERROR(
449 : "[%s][%s]errNo[0x%016llx] dataType is invalid", LOG_KEYWORDS_TASK_EXEC.c_str(),
450 : LOG_KEYWORDS_INVALID_ARGUMENT.c_str(), HCOM_ERROR_CODE(ret)),
451 : ret);
452 :
453 245 : return HCCL_SUCCESS;
454 14 : }
455 :
456 0 : HcclResult HcclParseRanktable(
457 : const std::string& rankTableM, const std::string& identify, hccl::HcclCommParams& params,
458 : hccl::RankTable_t& rankTable)
459 : {
460 : // 记录版本信息
461 0 : std::string curVersion = GetExternalInputCannVersion();
462 0 : CHK_RET(RankConsistentcyChecker::GetInstance().RecordVerInfo(curVersion));
463 :
464 : // ranktableCRC计算
465 0 : if (rankTableM.c_str() == nullptr) {
466 0 : HCCL_INFO("rank table is null, rankTableCrc is 0.");
467 : } else {
468 0 : HcclResult ret = HcomCalcCRC(params, rankTableM.c_str());
469 0 : CHK_PRT_RET(
470 : ret != HCCL_SUCCESS,
471 : HCCL_ERROR("[Init][OtherInfo]errNo[0x%016llx] calc ranktable crc error", HCCL_ERROR_CODE(HCCL_E_INTERNAL)),
472 : HCCL_E_INTERNAL);
473 : }
474 :
475 : // 解析rankTable_json对象,将解析的信息保存在rankinfo中
476 0 : HcclResult ret = CfgGetClusterInfo(rankTableM, identify, params, rankTable);
477 0 : CHK_PRT_RET(
478 : ret != HCCL_SUCCESS,
479 : HCCL_ERROR("[Init][HcclComm]errNo[0x%016llx] cfg get clusterInfo jsonString ", HCCL_ERROR_CODE(ret)),
480 : HCCL_E_INTERNAL);
481 0 : return HCCL_SUCCESS;
482 0 : }
483 :
484 0 : bool IsSupportHCCLV2(const char* socNamePtr)
485 : {
486 0 : auto ascend950Comp = strstr(socNamePtr, "Ascend950") != nullptr;
487 0 : auto ascend910_96Comp = strstr(socNamePtr, "Ascend910_96") != nullptr;
488 0 : auto ascend960Comp = strstr(socNamePtr, "Ascend960") != nullptr;
489 0 : auto ascend960Comp_1 = strstr(socNamePtr, "ascend960") != nullptr;
490 0 : return ascend950Comp || ascend910_96Comp || ascend960Comp || ascend960Comp_1;
491 : }
|