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

Generated by: LCOV version 2.0-1