LCOV - code coverage report
Current view: top level - legacy/ascend910/framework/common/src - param_check.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 54.2 % 216 117
Test Date: 2026-07-28 12:11:00 Functions: 69.6 % 23 16

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

Generated by: LCOV version 2.0-1