LCOV - code coverage report
Current view: top level - legacy/ascend910/framework/inc - hccl_comm_pub.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-07-28 12:11:00 Functions: - 0 0

            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_COMM_PUB_H
      12              : #define HCCL_COMM_PUB_H
      13              : 
      14              : #include <vector>
      15              : #include <memory>
      16              : #include <map>
      17              : #include <mutex>
      18              : #include "hccl/base.h"
      19              : #include "hccl_common.h"
      20              : #include "common.h"
      21              : #include "mem_device_pub.h"
      22              : #include "topoinfo_struct.h"
      23              : #include "comm.h"
      24              : #include "topoinfo_struct.h"
      25              : #include "transport_heterog_def.h"
      26              : #include "hccl/hccl_res.h"
      27              : #include "comm_config_pub.h"
      28              : #include "transport_manager.h"
      29              : #include "independent_op.h"
      30              : #include "share_ccl_buffer_manager.h"
      31              : #ifndef HCCD
      32              :     #include "coll_comm.h"
      33              : #endif
      34              : 
      35              : namespace hccl {
      36              : /* * 默认的rank_table, ranklist为空数组;  后续HCCL可以用于判断是否走新分支 */
      37              : extern RankTable_t g_hcclDefaultRankTable;
      38              : 
      39              : class HcclCommunicator;
      40              : class IHcclOneSidedService;
      41              : 
      42              : class hcclComm {
      43              : public:
      44         1199 :     explicit hcclComm(u64 inCCLbufferSize = 0, u64 outCCLbufferSize = 0, std::string identifier = "", std::string cclBuffName = "");
      45              :     ~hcclComm();
      46              : 
      47              :     /**********************************************************************
      48              :      函 数 名  : hcclComm::init
      49              :      功能描述  : 集合通信域初始化
      50              :      输入参数  : HcclCommParams& params
      51              :              const RankTable_t &rankTable
      52              :      输出参数  : 无
      53              :      返 回 值  : HcclResult
      54              :     **********************************************************************/
      55              :     HcclResult init(HcclCommParams &params, const CommConfig &commConfig,
      56              :         const RankTable_t &rankTable = g_hcclDefaultRankTable);
      57              :     HcclResult init(HcclCommParams &params, const CommConfig &commConfig,
      58              :         const std::vector<RankInfo> &rankList, WorldGroupInfo &groupCommonData);
      59              : 
      60              :     /**********************************************************************
      61              :      功能描述  : 创建以group为名字的集合通信
      62              :      输入参数  : const std::string& group
      63              :              const u32& groupRank
      64              :              const std::vector<u32>& groupRanks
      65              :      输出参数  : std::shared_ptr<hcclComm>& groupComm
      66              :      返 回 值  : HcclResult
      67              :     **********************************************************************/
      68              :     HcclResult CreateGroup(const std::string &group, const u32 &groupRank, const u32 &userRank,
      69              :         const std::vector<u32> &groupRanks, std::shared_ptr<hcclComm> &groupComm);
      70              : 
      71              :     /**********************************************************************
      72              :      功能描述  : 销毁以group为名字的集合通信
      73              :      输入参数  : const std::string& group
      74              :      返 回 值  : HcclResult
      75              :     **********************************************************************/
      76              :     HcclResult DestroyGroup(const std::string &group) const;
      77              : 
      78              :     /**********************************************************************
      79              :      功能描述  : 查询当前的算法类型
      80              :      输出参数  : AlgType &algType
      81              :      返 回 值  : HcclResult
      82              :     **********************************************************************/
      83              :     HcclResult GetAlgType(AlgType &algType, HcclCMDType opType);
      84              : 
      85              :     /**********************************************************************
      86              :      功能描述  : AllGather功能实现
      87              :      输入参数  : const char *tag
      88              :                  const void* input_ptr
      89              :                  void *outputPtr
      90              :                  s32 inputCount
      91              :                  HcclDataType datatype
      92              :                  rtStream_t stream
      93              :      输出参数  : void* output_ptr
      94              :      返 回 值  : HcclResult
      95              :     **********************************************************************/
      96              :     HcclResult AllGather(const std::string &tag, void *inputPtr, void *outputPtr, u64 inputCount, HcclDataType dataType,
      97              :         rtStream_t stream, HcomCollOpInfo *opInfo = nullptr);
      98              :     HcclResult AllGatherOutPlace(const std::string &tag, void *inputPtr, void *outputPtr, u64 inputCount,
      99              :         HcclDataType dataType, rtStream_t stream);
     100              :     HcclResult AllGatherVOutPlace(const std::string &tag, void *inputPtr, void *outputPtr, 
     101              :         u64 inputCount, const void *outputCounts, const void *outputDispls, HcclDataType dataType, HcclRtStream stream);
     102              :     HcclResult AllGatherV(const std::string &tag, const void *sendBuf, u64 sendCount, const void *recvBuf,
     103              :         const void *recvCounts, const void *rdispls, HcclDataType dataType, HcclRtStream stream);
     104              : 
     105              :     /* *********************************************************************
     106              :      功能描述  : all reduce功能实现
     107              :      输入参数  : const char *tag
     108              :                  const void* input_ptr
     109              :                  void *outputPtr
     110              :                  s32 count
     111              :                  HcclDataType data_type
     112              :                  HcclReduceOp op
     113              :                  rtStream_t stream
     114              :      输出参数  : void* output_ptr
     115              :      返 回 值  : HcclResult
     116              :     ********************************************************************* */
     117              :     HcclResult AllReduce(const std::string &tag, void *inputPtr, void *outputPtr, u64 count, HcclDataType dataType,
     118              :         HcclReduceOp op, rtStream_t stream, SyncMode syncMode = SyncMode::DEFAULT_TIMEWAITSYNCMODE);
     119              :     HcclResult AllReduceOutPlace(const std::string &tag, void *inputPtr, void *outputPtr, u64 count,
     120              :         HcclDataType dataType, HcclReduceOp op, rtStream_t stream,
     121              :         SyncMode syncMode = SyncMode::DEFAULT_TIMEWAITSYNCMODE);
     122              :     /* *********************************************************************
     123              :      功能描述  : broadcast功能实现
     124              :      输入参数  :const char *tag
     125              :                  void* ptr
     126              :                  s32 count
     127              :                  HcclDataType dataType
     128              :                  s32 root
     129              :                  rtStream_t stream
     130              :      输出参数  : void* ptr
     131              :      返 回 值  : HcclResult
     132              :     ********************************************************************* */
     133              :     HcclResult Broadcast(const std::string &tag, void *ptr, u64 count, HcclDataType dataType,
     134              :         u32 root, rtStream_t stream);
     135              :     HcclResult BroadcastOutPlace(const std::string &tag, void *ptr, u64 count, HcclDataType dataType, u32 root,
     136              :         rtStream_t stream);
     137              :     /* *********************************************************************
     138              :      功能描述  : scatter功能实现
     139              :      输入参数  : const char *tag
     140              :                 const void* input_ptr
     141              :                 void *outputPtr
     142              :                 u64 recvCount
     143              :                 HcclDataType dataType
     144              :                 u32 root
     145              :                 rtStream_t stream
     146              :      输出参数  : void* ptr
     147              :      返 回 值  : HcclResult
     148              :     ********************************************************************* */
     149              :     HcclResult Scatter(const std::string &tag, void *inputPtr, void *outputPtr, u64 recvCount, HcclDataType dataType,
     150              :         u32 root, rtStream_t stream);
     151              :     HcclResult ScatterOutPlace(const std::string &tag, void *inputPtr, void *outputPtr, u64 recvCount,
     152              :         HcclDataType dataType, u32 root, rtStream_t stream);
     153              :     /**********************************************************************
     154              :      功能描述  : reduce功能实现
     155              :      输入参数  : const char *tag
     156              :                  const void* input_ptr
     157              :                  void *outputPtr
     158              :                  s32 count
     159              :                  HcclDataType data_type
     160              :                  HcclReduceOp op
     161              :                  s32 root,
     162              :                  rtStream_t stream
     163              :      输出参数  : void* output_ptr
     164              :      返 回 值  : HcclResult
     165              :     **********************************************************************/
     166              :     HcclResult Reduce(const std::string &tag, void *inputPtr, void *outputPtr, u64 count,
     167              :         HcclDataType dataType, HcclReduceOp op, u32 root, rtStream_t stream);
     168              :     HcclResult ReduceOutPlace(const std::string &tag, void *inputPtr, void *outputPtr, u64 count,
     169              :         HcclDataType dataType, HcclReduceOp op, u32 root, rtStream_t stream);
     170              : 
     171              :     /**********************************************************************
     172              :      功能描述  : reduce-scatter功能实现
     173              :      输入参数  : const char *tag
     174              :                  const void* input_ptr
     175              :                  void *outputPtr
     176              :                  s32 count
     177              :                  HcclDataType data_type
     178              :                  HcclReduceOp op
     179              :                  rtStream_t stream
     180              :      输出参数  : void* output_ptr
     181              :      返 回 值  : HcclResult
     182              :     **********************************************************************/
     183              :     HcclResult ReduceScatter(const std::string &tag, void *inputPtr, void *outputPtr, u64 recvCount,
     184              :         HcclDataType dataType, HcclReduceOp op, rtStream_t stream);
     185              :     HcclResult ReduceScatterOutPlace(const std::string &tag, void *inputPtr, void *outputPtr, u64 recvCount,
     186              :         HcclDataType dataType, HcclReduceOp op, rtStream_t stream);
     187              :     HcclResult ReduceScatterV(const std::string &tag, void *inputPtr,
     188              :         const void *inputCounts, const void *inputDispls, void *outputPtr, u64 outputCount,
     189              :         HcclDataType dataType, HcclReduceOp op, HcclRtStream stream);
     190              :     HcclResult ReduceScatterVOutPlace(const std::string &tag, void *inputPtr, void *outputPtr, 
     191              :         const void *inputCounts, const void *inputDispls, u64 outputCount, 
     192              :         HcclDataType dataType, HcclReduceOp op, HcclRtStream stream);
     193              : 
     194              :     HcclResult BatchSendRecv(const std::string &tag, struct HcclSendRecvItemDef* sendRecvItemsPtr,
     195              :         u32 itemNum, rtStream_t stream);
     196              : 
     197              :     HcclResult send(const std::string &tag, void *inputPtr, u64 count, HcclDataType dataType, u32 destRank,
     198              :         rtStream_t stream, u32 srTag, u32 localGroupRank);
     199              :     HcclResult SendOutPlace(const std::string &tag, void *inputPtr, u64 count, HcclDataType dataType, u32 destRank,
     200              :         rtStream_t stream);
     201              : 
     202              :     HcclResult receive(const std::string &tag, void *outputPtr, u64 count, HcclDataType dataType, u32 srcRank,
     203              :         rtStream_t stream, u32 srTag, u32 localGroupRank);
     204              :     HcclResult ReceiveOutPlace(const std::string &tag, void *outputPtr, u64 count, HcclDataType dataType, u32 srcRank,
     205              :         rtStream_t stream);
     206              : 
     207              :     HcclResult AlltoAllV(const void *sendBuf, const void *sendCounts, const void *sdispls, HcclDataType sendType,
     208              :         const void *recvBuf, const void *recvCounts, const void *rdispls, HcclDataType recvType, rtStream_t stream,
     209              :         const std::string &tag);
     210              :     HcclResult AlltoAllVOutPlace(const void *sendBuf, const void *sendCounts, const void *sdispls,
     211              :         HcclDataType sendType, const void *recvBuf, const void *recvCounts, const void *rdispls, HcclDataType recvType,
     212              :         rtStream_t stream, const std::string &tag);
     213              : 
     214              :     HcclResult AlltoAllVC(const void *sendBuf, const void *sendCountMatrix, HcclDataType sendType, const void *recvBuf,
     215              :         HcclDataType recvType, rtStream_t stream, const std::string &tag);
     216              :     HcclResult AlltoAllVCOutPlace(const void *sendBuf, const void *sendCountMatrix, HcclDataType sendType,
     217              :         const void *recvBuf, HcclDataType recvType, rtStream_t stream, const std::string &tag);
     218              : 
     219              :     HcclResult AlltoAll(const void *sendBuf, u64 sendCount, HcclDataType sendType, const void *recvBuf,
     220              :         u64 recvCount, HcclDataType recvType, rtStream_t stream, const std::string &tag);
     221              : 
     222              :     /**********************************************************************
     223              :      功能描述  : 生成唯一的集合通信域标识
     224              :      输入参数  : 无
     225              :      输出参数  : HcclRootInfo* rootInfo
     226              :      返 回 值  : HcclResult
     227              :     **********************************************************************/
     228              :     static HcclResult GetUniqueId(HcclRootInfo *uniqueId);
     229              : 
     230              :     HcclResult GetInCCLbuffer(void* &buffer, u64 &size);
     231              :     HcclResult GetOutCCLbuffer(void* &buffer, u64 &size);
     232              :     HcclResult GetUserRank(u32 &userRank);
     233              :     HcclResult GetGroupRank(u32 &userRank);
     234              :     HcclResult GetRankSize(u32 &rankSize);
     235              :     void ReleaseCommCCLbuffer() const;
     236              :     void RealeaseBarrierMemory();
     237              :     HcclResult RealeaseShareCCLbuffer();
     238              :     HcclResult CreateCommCCLbuffer() const;
     239              :     HcclResult CreateIndirectCCLbuf();
     240              :     void ReleaseIndirectCCLbuf();
     241              :     HcclResult SetAicpuCommEngine(bool isAicpuCommEngine);
     242              : 
     243              :     HcclResult GetOneSidedService(IHcclOneSidedService** service);//host侧专用
     244              :     HcclResult InitOneSidedServiceNetDevCtx(u32 remoteRankId);//host侧专用
     245              :     HcclResult OneSidedServiceStartListen(NicType nicType,HcclNetDevCtx netDevCtx);//host侧专用
     246              :     HcclResult GetOneSidedServiceDevIpAndPort(NicType nicType, HcclIpAddress& ipAddress, u32& port);//host侧专用
     247              :     HcclResult DeinitOneSidedService();//host侧专用
     248              : 
     249              :     HcclResult GetIndirectInCCLbuf(void* &ptr, u64 &size);
     250              :     HcclResult GetIndirectOutCCLbuf(void* &ptr, u64 &size);
     251              :     HcclResult HcclSelectAlg(HcclCMDType opType, u64 count, void* counts, HcclDataType dataType,
     252              :         HcclReduceOp op, int32_t aivCoreLimit, bool &ifAiv, std::string &algName);
     253              :     HcclResult HcclCalcNumBlocks(HcclCMDType opType, u64 count, void* counts, HcclDataType dataType, int32_t aivCoreLimit,
     254              :         std::string &algName, u32 &numBlocks);
     255              :     
     256              :     HcclResult HcclGetAlgExecParam(const std::string &tag, u64 count, void *inputPtr, void *outputPtr,
     257              :         HcclCMDType opType, bool clearEnable, HcclDataType dataType, HcclReduceOp op, 
     258              :         void *&commContext, u64 &len, u32 aivCoreLimit);
     259              : 
     260              :     HcclResult GetWorkspaceSubStreamNum(u64 count, HcclDataType dataType, HcclReduceOp op, const std::string &algName,
     261              :         u64 &streamNum, u64 dataSize = 0, bool ifAiv = false,
     262              :         HcclCMDType optype = HcclCMDType::HCCL_CMD_INVALID) const;
     263              :     HcclResult GetWorkspaceMemSize(const std::string &opType, u64 count, HcclDataType dataType,
     264              :                                    u32 &rankSize, u64 &size);
     265              :     HcclResult GetAllReduceScratchSize(const u64 count, const HcclDataType dataType, u64 &scratchSize) const;
     266              :     HcclResult SetWorkspaceResource(const std::string &tag, void *memPtr, u64 maxSize,
     267              :                                     std::vector<rtStream_t> &stream);
     268              :     HcclResult CreateOpBasedResources(const HcclCMDType &opType, const std::string &tag,
     269              :         const HcomCollOpInfo &opInfo);
     270              : 
     271              :     std::string GetIdentifier();
     272              :     std::string GetCCLbufferName();
     273              :     HcclResult CreateBarrierMemory();
     274              :     HcclResult ReleaseSubComms() const;
     275              :     HcclResult GetAlltoAllStagedWorkSpaceMemSize(u64 *sendCounts, u64 *sdispls,
     276              :         HcclDataType sendType, u64 *recvCounts, u64 *rdispls, HcclDataType recvType, u64 &memSize) const;
     277              :     HcclResult GetAlltoAllStagedWorkSpaceMemSize(std::vector<SendRecvInfo> &allMeshAggregationSendRecvInfo,
     278              :         u64 &memSize) const;
     279              :     // 目前支持按tag对资源释放、解绑定
     280              :     HcclResult ClearOpResource(const std::string &tag);
     281              :     HcclResult SetClearAivSyncBuf(bool aivClearEnable);
     282              :     HcclResult Isend(void *buffer, s32 count, HcclDataType dataType, u32 peerRank, s32 tag, HcclRequest &request,
     283              :         HcclUserRequire &userRequire) const;
     284              :     HcclResult Improbe(u32 peerRank, s32 tag, s32 &flag, HcclMessage &msgHandle, HcclStatus &status) const;
     285              :     HcclResult Imrecv(void *buffer, s32 count, HcclDataType dataType, HcclMessage msg, HcclRequest &request) const;
     286              :     HcclResult HcclTest(HcclRequest hcclRequest, s32 &flag, HcclStatus &compState) const;
     287              :     // 获取溢出Flag内存传给RTS
     288              :     HcclResult SetGlobalWorkSpace(std::vector<void *> &globalWorkSpaceAddr);
     289              :     HcclResult SetAttachedStream(u32 graphId, const std::vector<rtStream_t> &streams);
     290              :     // 获取rdma with reduce算子溢出的task信息,然后清除
     291              :     HcclResult GetandClearOverFlowTasks(std::vector<HcclDumpInfo> &hcclDumpInfo);
     292              :     HcclResult SupportDeterministicOptim(bool &isDeterministicOptim);
     293              :     HcclResult GetHccsLinkNum(u32 &numHccsLink);
     294              :     HcclResult GetDeviceId(s32 &deviceId);
     295              :     HcclResult GetDevType(DevType &devType);
     296              :     HcclResult IsStandardCard(bool &isStandardCard);
     297              :     HcclResult Is310PDuoCard(bool &is310PDuoCard);
     298              :     HcclResult AbortSelf(s32 tag);
     299              : 
     300              :     HcclResult RegistTaskAbortHandler() const;
     301              :     HcclResult UnRegistTaskAbortHandler() const;
     302              :     HcclResult RegTransportLinks(s32 linkNum, void *transportPara);
     303              :     HcclResult GetDeviceNumPerAggregation(u32 &deviceNumPerAggregation);
     304              :     HcclResult GetBandWidthPerNPU(u32 level, float &bandWidth);
     305              :     bool IsNeedResetDevice();
     306              :     HcclResult ResetDeviceEnable();
     307              :     HcclResult CommCheckErrorCqe(HcclResult &result);
     308              :     HcclResult CommCheckOpInconsistentError(HcclResult &result);
     309              :     HcclResult SaveTraceInfo(std::string &logInfo);
     310              :     HcclResult AllocComResourceByTiling(const std::string &algConfig, void *param);
     311              :     HcclResult CreateCommResource(const std::string &tag, rtStream_t aiCpuStream, bool isOpbaseMode,
     312              :         void **commContext, const std::string &algConfig = "");
     313              :     bool GetCommResource(const std::string &tag, void **commContext);
     314              :     bool GetCommResource(void *&commContext);
     315              :     HcclResult SetStopFlag(bool value);
     316              :     HcclResult SetState(HcclCommState state);
     317              :     HcclCommState GetState();
     318              :     HcclResult GetAicpuOpStreamNotify(HcclRtStream *opStream, u8 aicpuNotifyNum, void** aicpuNotify);
     319              :     HcclResult Mc2AiCpuStreamAllocAndGet(u32 streamMode, rtStream_t &aiCpuStream);
     320              :     HcclResult GetAiCpuNotifyData(HcclRtNotify notifyHandle, HcclSignalInfo &notifyInfo);
     321              :     HcclResult AddAiCpuNotify(HcclRtNotify *notifyHandle);
     322              :     HcclResult GetTopoDesc(HcclTopoDescs *topoDescs, uint32_t topoSize);
     323              :     HcclResult GetCommUserMemSize(uint64_t &size);
     324              :     HcclResult SetDeterministicConfig(const u8 deterministic);  // 设置确定性计算配置
     325              :     HcclResult SetAivModeConfig(const bool aivMode);  // 设置aiv模式配置
     326              :     HcclResult SetOnlyAivModeConfig(const bool isOnlyAiv);
     327              :     HcclResult GetOnlyAivModeConfig(bool &isOnlyAiv);
     328              :     HcclResult SetAicpuUnfoldConfig(const bool aicpuUnfold);  // 设置aicpu配置
     329              :     HcclResult SetExecTimeOutConfig(const s32 execTimeOut);  // 设置HCCL执行超时时间
     330              :     HcclResult SetAlgoConfig(const std::map<HcclCMDType, std::vector<HcclAlgoType>>& algoMap);  //设置HCCL_ALGO
     331              :     u64 GetConfigInCCLbufferSize();     // 获取通信域配置的输入buffer大小
     332              :     u64 GetConfigOutCCLbufferSize();    // 获取通信域配置的输出buffer大小
     333              :     u32 GetRankTableCrc();
     334              :     u32 GetServerNum();
     335              :     u32 GetModuleNum();
     336              :     u32 GetRealUserRank() const;
     337              :     HcclResult GetCommParams(HcclCommParams &params);       // 逆向解析获取HcclCommParams参数
     338              :     HcclResult GetCommRankTable(RankTable_t &rankTable);    // 逆向解析获取RankTable_t参数
     339              :     HcclResult SetQpQosAttr(u32 trafficClass, u32 serviceLevel); // 设置TC/SL配置
     340              :     HcclResult SetHcclQos(u32 hcclQos);
     341              :     u32 GetHcclQos();
     342              : 
     343              :     std::shared_ptr<struct hcclKernelPlanner> planner {nullptr}; //for group
     344              :     void* barrierSendBuf;
     345              :     void* barrierRecvBuf;
     346              :     std::mutex operatorlock_;
     347              :     HcclResult Suspend();
     348              :     HcclResult Resume();
     349              :     HcclResult GetCommStatus(HcclCommStatus &status);
     350              : 
     351              :     HcclResult InitZeroCopyMemoryAgent();
     352              :     HcclResult DeinitZeroCopyMemoryAgent();
     353              :     HcclResult SetMemoryRange(void *baseVirPtr, size_t size, size_t alignment, uint64_t flags);
     354              :     HcclResult UnsetMemoryRange(void *baseVirPtr);
     355              :     HcclResult ActivateCommMemory(void *virPtr, size_t size, size_t offset, void* handle, uint64_t flags);
     356              :     HcclResult DeactivateCommMemory(void *virPtr);
     357              :     HcclResult GetNumBlocks(u32& numBlocks);
     358              :     HcclResult SetAivCoreLimit(u32 aivCoreLimit);
     359              :     HcclResult SwitchNic(uint32_t nRanks, uint32_t *ranks, bool *useBackup);
     360              :     HcclResult InitHccpChannel();
     361              :     std::vector<RankInfo> GetRankLists();
     362              :     HcclResult RegisterCommUserMem(void* addr, u64 size, void **handle);
     363              :     HcclResult DeregisterCommUserMem(void* handle);
     364              :     HcclResult ExchangeCommUserMem(void* handle, std::vector<u32>& peerRanks);
     365              :     HcclResult SetCommDispatcherCtx();
     366              :     HcclResult ReleaseCommDispatcherCtx();
     367              :     // 独立算子专用
     368              :     HcclResult SetIndependentOpConfig(const CommConfig &commConfig, const RankTable_t &rankTable);
     369              :     HcclResult InitIndependentOp();
     370              :     void SetAicpuCommState(bool aicpuCommState);
     371              :     bool GetAicpuCommState();
     372              :     HcclResult KernelLaunchAicpuCommInit();
     373              :     HcclResult ReportProfilingKernel(uint64_t beginTime, std::string kernelName);
     374              :     bool IsCommunicatorV2();
     375              : #ifndef HCCD
     376              :     HcclResult InitCollComm(void* commV2, void* rankGraph, uint32_t userRank,
     377              :         HcclMem cclBuffer, const std::string &commName, HcclCommConfig *config,
     378              :         CollCommInitMode initMode = CollCommInitMode::fullMode);
     379              :     HcclResult InitCollCommInner(uint32_t userRank);
     380              : #endif
     381              :     void* GetCommunicatorV2();
     382              :     HcclCommunicator* GetHcclCommunicator();
     383              : #ifndef CCL_KERNEL_AICPU
     384              :     #ifndef HCCD
     385              :         CollComm* GetCollComm();
     386              :     #endif
     387              :     IndependentOp& GetIndependentOp();
     388              : #endif
     389              :     // A5communicator相关
     390              : 
     391              :     HcclResult IndOpTransportAlloc(const std::string &tag, OpCommTransport &opCommTransport, bool isAicpuModeEn);
     392              : 
     393              :     HcclResult PrepareChannelMem(const std::string &tag, TransportIOMem &transMem);
     394              : 
     395              :     //Decouple for MC2
     396              :     HcclResult GetLocalCCLBuf(void **addr, uint64_t *size);
     397              :     HcclResult GetRemoteCCLBuf(uint32_t remoteRank, void **addr, uint64_t *size);
     398              :     HcclResult GetKFCWorkSpace(void **addr, uint64_t *size);
     399              :     HcclResult GetDevMemWorkSpace(const std::string &memTag, uint64_t *size, void **addr, bool *newCreated);
     400              :     HcclResult CommGetNetLayers(uint32_t **netLayers, uint32_t *netLayerNum);
     401              :     HcclResult CommGetInstSizeByNetLayer(uint32_t netLayer, uint32_t *rankNum);
     402              :     HcclResult CommGetInstTopoTypeByNetLayer(uint32_t netLayer, uint32_t *topoType);
     403              :     //rankgraph interface 
     404              :     HcclResult GetNetLayers(uint32_t **netLayers, uint32_t *netLayerNum);
     405              :     HcclResult GetInstSizeByNetLayer(uint32_t netLayer, uint32_t *rankNum);
     406              :     HcclResult GetInstTopoTypeByNetLayer(uint32_t netLayer, CommTopo *topoType);
     407              :     HcclResult GetInstRanksByNetLayer(uint32_t netLayer, uint32_t **rankList, uint32_t *rankNum);
     408              :     HcclResult GetInstSizeListByNetLayer(uint32_t netLayer, uint32_t **instSizeList, uint32_t *listSize);
     409              :     HcclResult GetRankGraph(GraphType type, void **graph, uint32_t *len);
     410              :     HcclResult GetLinks(uint32_t netLayer, uint32_t srcRank, uint32_t dstRank,
     411              :         CommLink **linkList, uint32_t *listSize);
     412              :     uint32_t GetConnectMode();
     413              :     HcclResult GetTopoInstsByLayer(uint32_t netLayer, uint32_t **topoInsts, uint32_t *topoInstNum);
     414              :     HcclResult GetTopoType(uint32_t netLayer, uint32_t topoInstId, CommTopo *topoType);
     415              :     HcclResult GetRanksByTopoInst(uint32_t netLayer, uint32_t topoInstId, uint32_t **ranks, uint32_t *rankNum);
     416              :     HcclResult GetEndpointNum(uint32_t netLayer, uint32_t topoInstId, uint32_t *num);
     417              :     HcclResult GetEndpointDesc(uint32_t netLayer, uint32_t topoInstId, uint32_t *descNum, EndpointDesc *endpointDesc);
     418              :     HcclResult GetEndpointInfo(uint32_t rankId, const EndpointDesc *endPointDesc, EndpointAttr endpointAttr,
     419              :                                uint32_t infoLen, void *info);
     420              :     HcclResult GetHeterogMode(HcclHeterogMode *mode);
     421              :     // for group
     422              :     HcclResult SetGroupMode(bool isGroup);
     423              :     bool GetGroupMode();
     424              :     HcclResult RegisterWindow(void* ptr, size_t size, HcclCommSymWindow *winHandle);
     425              :     HcclResult DeregisterWindow(HcclCommSymWindow winHandle);
     426              :     HcclResult GetCommSymWin(void* ptr, size_t size, HcclCommSymWindow *winHandle, size_t *offset);
     427              :     aclrtBinHandle GetBinHandle();
     428              : protected:
     429              :     /* * 禁止用户对API类的实体做拷贝构造或拷贝赋值的操作,内部有指针成员变量 */
     430              :     hcclComm(const hcclComm &) = delete;
     431              :     hcclComm &operator=(const hcclComm &) = delete;
     432              : private:
     433              :     HcclResult InitImpl(DevType deviceType, const CommConfig &commConfig);
     434              :     void UpdateIsHaveCpuRank(const RankTable_t &rankTable);
     435              :     void UpdateIsHaveCpuRank(const std::vector<RankInfo> &rankList);
     436              :     void PrintSubmittedOpCnt(const std::string &tag, HcclResult ret);
     437              :     HcclResult ReleaseChannel();
     438              :     void BinaryUnLoad();
     439              :     HcclResult InitBinHandle();
     440              :     DeviceMem indirectInCCLbuffer_; /* 保存inCCLbuffer指针的地址 */
     441              :     DeviceMem indirectOutCCLbuffer_; /* 保存outCCLbuffer_指针的地址 */
     442              :     u64 inCCLbufferSize_;
     443              :     u64 outCCLbufferSize_;
     444              :     DevType deviceType_;
     445              :     DeviceMem barrierInMemory_;
     446              :     DeviceMem barrierOutMemory_;
     447              :     bool isFirstBarrier_;
     448              :     const std::string identifier_;
     449              :     const std::string cclBuffName_; 
     450              :     bool isHeterogComm_;
     451              :     bool isGroupMode_{false};
     452              :     bool isResetDevice_;
     453              :     bool isSpecialType_;
     454              :     bool isHaveCpuRank_{false};
     455              :     std::unique_ptr<HcclCommunicator> communicator_;
     456              : 
     457              :     bool isAicpuCommInit_ = false;
     458              :     CommAicpuParam commAicpuParam_;
     459              :     aclrtBinHandle binHandle_ = nullptr;
     460              :     DevType devType_ = DevType::DEV_TYPE_COUNT;
     461              :     u32 hcclQos_;
     462              : #ifndef CCL_KERNEL_AICPU
     463              :     // 独立算子专用成员变量
     464              :     IndependentOp independentOp_;
     465              :     #ifndef HCCD
     466              :         // A5CollComm
     467              :         std::unique_ptr<CollComm> collComm_{nullptr};
     468              :     #endif
     469              : #endif
     470              : };
     471              : }  // namespace hccl
     472              : 
     473              : using HcclCommPtr = std::shared_ptr<hccl::hcclComm>;
     474              : #endif /* HCCL_COMM_PUB_H */
        

Generated by: LCOV version 2.0-1