LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/pub_inc - hccl_impl_pub.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 56 56
Test Date: 2026-08-04 10:52:23 Functions: 100.0 % 5 5

            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 HCCL_IMPL_PUB_H
      12              : #define HCCL_IMPL_PUB_H
      13              : 
      14              : #include "comm_base_pub.h"
      15              : #include "threadManage.h"
      16              : 
      17              : namespace hccl {
      18              : constexpr s32 PROF_RANKSIZE_OFFSET_OF_PLANEID = 16;
      19              : constexpr s32 PROF_RINGINDEX_OFFSET_OF_PLANEID = 28;
      20              : 
      21              : constexpr u32 PROF_STAGE_0 = 0;
      22              : constexpr u32 PROF_STAGE_1 = 1;
      23              : constexpr u32 PROF_STAGE_2 = 2;
      24              : 
      25              : using level1StreamInfo_t = struct Level1StreamInfo {
      26              :     u32 ringNum; /* 至少有1个ring */
      27              :     std::vector<std::shared_ptr<LocalNotify>> ringSignal;
      28              :     std::vector<std::shared_ptr<LocalNotify>> ringSignalAux;
      29              :     std::vector<Stream> ringStreams;
      30              :     std::vector<std::shared_ptr<ThreadManage>> ringThreadsManage;
      31              :     std::vector<uint32_t> tidInfo;
      32              :     std::vector<Stream> ringDeviceStreams;
      33              :     std::vector<std::shared_ptr<LocalNotify>> ringDeviceSignal;
      34              :     std::vector<std::shared_ptr<LocalNotify>> ringDeviceSignalAux;
      35              : 
      36            2 :     Level1StreamInfo() : ringNum(1)
      37              :     {
      38            2 :     }
      39              : };
      40              : 
      41              : using tagStreamInfo_t = std::map<std::string, Level1StreamInfo>;
      42              : 
      43              : using CommInfo = struct TagCommInfo {
      44              :     std::vector<std::unique_ptr<CommBase> > commLevel1;
      45              :     std::vector<std::unique_ptr<CommBase> > commLevel1Rdma;
      46              :     std::vector<std::unique_ptr<CommBase> > commLevel0;
      47              :     std::vector<std::unique_ptr<CommBase> > commLevel0Rdma;
      48              :     std::vector<std::unique_ptr<CommBase> > commLevel2;
      49              :     std::vector<std::unique_ptr<CommBase> > commP2P;
      50              :     std::unique_ptr<CommBase> commIntraServer;
      51              : 
      52          121 :     TagCommInfo() : commLevel1(0), commLevel1Rdma(0), commLevel0(0), commLevel0Rdma(0), commP2P(0), commIntraServer(nullptr)
      53              :     {
      54           11 :     }
      55              : };
      56              : using tagCommInfo_t = std::map<std::string, CommInfo>;
      57              : 
      58              : using HcclAlgoAttr = struct HcclAlgoAttrDef {
      59              :     bool isHaveCpuRank;              // 是否有cpu参与通信
      60              :     bool inlineReduceSwitchOn;       // 收到数量时同时完成Reduce计算
      61              :     bool isUsedRdmaLevel0;            // Level0 通信域是否使用RDMA
      62              :     bool isUsedInterHccsMode;       // 超节点内节点间是否使用HCCS模式
      63              :     std::string identifier;
      64              :     std::string collectiveId;
      65              :     NICDeployment nicDeployment;
      66              :     WorkMode commWorkMode;
      67              :     std::map<HcclCMDType, std::vector<HcclAlgoType>> commAlgoConfig;
      68              : 
      69         1054 :     HcclAlgoAttrDef()
      70         1054 :         : isHaveCpuRank(false),
      71         1054 :         inlineReduceSwitchOn(true),
      72         1054 :         isUsedRdmaLevel0(false),
      73         1054 :         isUsedInterHccsMode(false),
      74         2108 :         identifier(""),
      75         2108 :         collectiveId(""),
      76         1054 :         nicDeployment(NICDeployment::NIC_DEPLOYMENT_DEVICE),
      77         1054 :         commWorkMode(WorkMode::HCCL_MODE_NORMAL)
      78              :     {
      79         1054 :         SetDefaultAlgo();
      80         1054 :     }
      81         1054 :     void SetDefaultAlgo()
      82              :     {
      83       110670 :         for (u32 opType = 0; opType < static_cast<u32>(HcclCMDType::HCCL_CMD_MAX); opType++) {
      84       109616 :             commAlgoConfig[static_cast<HcclCMDType>(opType)] =
      85       219232 :                 std::vector<HcclAlgoType>(HCCL_ALGO_LEVEL_NUM, HcclAlgoType::HCCL_ALGO_TYPE_DEFAULT);
      86              :         }
      87         1054 :     }
      88              : };
      89              : 
      90              : struct HcclTopoAttr {
      91              :     u32 serverNum;                   // 集群中总的服务器数
      92              :     u32 superPodNum;                 // 集群中总的超节点数
      93              :     u32 moduleNum;                   // 集群中的总的module数
      94              :     u32 deviceNumPerServer;          // 服务器上的Device数量
      95              :     u32 deviceNumPerAggregation;     // 每个module中的Device数量
      96              :     bool multiModuleDiffDeviceNumMode; // 每个module内的设备数是否相等,如果不相同即为多module不同卡模式 (走大RING环)
      97              :     bool multiSuperPodDiffServerNumMode; // 每个超节点内的server数是否相等
      98              :     bool multiSuperPodDiffDeviceNumMode; // 每个超节点内的总rank数是否相等
      99              :     
     100              :     bool isDiffDeviceType;
     101              :     u32 gcdDeviceNumPerAggregation;
     102              : 
     103              :     u32 meshAggregationRankSize;
     104              :     bool isDiffDeviceModule;
     105              :     bool isSingleMeshAggregation;
     106              :     bool isAllRankSamePlane;         // 通信域所有Rank是否在同一平面
     107              : 
     108              :     u32 userRank;                    // 通信域 RankID
     109              :     u32 realUserRank;
     110              :     u32 userRankSize;                // 通信域的 Rank数量
     111              :     std::vector<RankInfo> rankInfoList; // world group内rank的信息, 按照rank id递增依次排列
     112              : 
     113              :     u32 devicePhyId;
     114              :     s32 deviceLogicId;
     115              :     bool useSuperPodMode;    // 使用SDID作为DeviceId做相关查询操作
     116              : 
     117              :     DevType deviceType;
     118              :     bool isStandardCard;
     119              :     bool is310PDuoCard;
     120              :     bool isCommon310P3DUO; // 310p duo 2卡4芯场景
     121              :     s32 hccsPortNum;
     122              : 
     123              :     std::vector<u32> nicList;
     124              :     std::unordered_map<u32, u32> pairLinkCounter; // server内所有device间的链路类型计数
     125              :     std::unordered_map<u32, std::unordered_map<int, std::vector<int>>> pairLinkInfo; // server内所有device间的链路类型
     126              :     bool isSupportRdmaLite;           // 是否支持rdma lite
     127              :     bool isSupportHccsAndSio;         //是否支持hccs sio并发
     128              :     u32 localNicPort;
     129              :     bool isNeedInitNic;      // 是否需要初始化Nic,心跳使用
     130              :     bool isARSDoubleRing;
     131              :     
     132         2665 :     HcclTopoAttr()
     133         2665 :         : serverNum(0),
     134         2665 :         superPodNum(0),
     135         2665 :         moduleNum(0),
     136         2665 :         deviceNumPerServer(0),
     137         2665 :         deviceNumPerAggregation(0),
     138         2665 :         multiModuleDiffDeviceNumMode(false),
     139         2665 :         multiSuperPodDiffServerNumMode(false),
     140         2665 :         multiSuperPodDiffDeviceNumMode(false),
     141         2665 :         isDiffDeviceType(false),
     142         2665 :         gcdDeviceNumPerAggregation(0),
     143         2665 :         meshAggregationRankSize(0),
     144         2665 :         isDiffDeviceModule(false),
     145         2665 :         isSingleMeshAggregation(false),
     146         2665 :         isAllRankSamePlane(false),
     147         2665 :         userRank(0),
     148         2665 :         realUserRank(0),
     149         2665 :         userRankSize(0),
     150         5330 :         rankInfoList(0),
     151         2665 :         devicePhyId(0),
     152         2665 :         deviceLogicId(0),
     153         2665 :         useSuperPodMode(false),
     154         2665 :         deviceType(DevType::DEV_TYPE_COUNT),
     155         2665 :         isStandardCard(false),
     156         2665 :         is310PDuoCard(false),
     157         2665 :         isCommon310P3DUO(false),
     158         2665 :         hccsPortNum(-1),
     159         5330 :         nicList(0),
     160         5330 :         pairLinkCounter(0),
     161         5330 :         pairLinkInfo(0),
     162         2665 :         isSupportRdmaLite(false),
     163         2665 :         isSupportHccsAndSio(false),
     164         2665 :         localNicPort(0),
     165         2665 :         isNeedInitNic(false),
     166         2665 :         isARSDoubleRing(true)
     167         2665 :     {}
     168              : };
     169              : 
     170              : using RegisterToHeartBeatCallBack =
     171              :     HcclResult (*)(s32 deviceLogicID, u32 userRank, DevType devType, std::vector<RankInfo> &rankInfoList,
     172              :         const u32 port, const bool isNeedNic, u32 peerRankId, const std::string &commIdentifier, const std::string &tag,
     173              :         bool useSuperPodMode, bool isUsedRdmaLevel0);
     174              : using UnRegisterToHeartBeatCallBack =
     175              :     void (*)(s32 deviceLogicID, DevType devType, const std::string &commIdentifier, const std::string &tag);
     176              : using SetRankPortInfoCallBack =
     177              :     HcclResult (*)(s32 deviceLogicID, bool isUseRankPort, std::vector<u32> &ranksPort);
     178              : #ifdef __cplusplus
     179              : extern "C" {
     180              : #endif // __cplusplus
     181              : void RegisterHeartBeatCallBack(RegisterToHeartBeatCallBack p1, UnRegisterToHeartBeatCallBack p2, SetRankPortInfoCallBack p3);
     182              : #ifdef __cplusplus
     183              : }
     184              : #endif // __cplusplus
     185              : }  // namespace hccl
     186              : #endif /** HCCL_IMPL_PUB_H */
        

Generated by: LCOV version 2.0-1