LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/communicator/aicpu - communicator_impl_lite.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 65.6 % 32 21
Test Date: 2026-08-18 17:47:01 Functions: 72.4 % 29 21

            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_AICPU_COMMUNICATOR_IMPL_LITE_H_
      12              : #define HCCL_AICPU_COMMUNICATOR_IMPL_LITE_H_
      13              : 
      14              : #include <memory>
      15              : #include "ins_executor.h"
      16              : #include "data_type.h"
      17              : #include "prim_translator.h"
      18              : 
      19              : #include "lite_res_mgr_fetcher.h"
      20              : #include "coll_alg_component_lite.h"
      21              : #include "types.h"
      22              : #include "coll_alg_info.h"
      23              : #include "kernel_param_lite.h"
      24              : #include "rma_buffer_lite.h"
      25              : #include "queue_notify_lite_mgr.h"
      26              : #include "cnt_1ton_notify_lite_mgr.h"
      27              : #include "host_device_sync_notify_lite_mgr.h"
      28              : #include "profiling_reporter_lite.h"
      29              : #include "profiling_handler_lite.h"
      30              : #include "data_buffer.h"
      31              : #include "rmt_data_buffer_mgr.h"
      32              : #include "aicpu_hdc_handler.h"
      33              : #include "one_sided_component_lite.h"
      34              : #include "error_message_v2.h"
      35              : 
      36              : namespace Hccl {
      37              : 
      38              : class CommunicatorImplLite : public ResMgrFetcher {
      39              : public:
      40              :     explicit CommunicatorImplLite(u32 idIndex);
      41          131 :     ~CommunicatorImplLite() override = default;
      42              : 
      43              :     int LoadWithOpBasedMode(HcclKernelParamLite* kernelParam);
      44              :     int UpdateComm(HcclKernelParamLite* kernelParam);
      45              : 
      46              :     HostDeviceSyncNotifyLiteMgr* GetHostDeviceSyncNotifyLiteMgr() override;
      47              :     StreamLiteMgr* GetStreamLiteMgr() override;
      48              :     QueueNotifyLiteMgr* GetQueueNotifyLiteMgr() override;
      49              :     Cnt1tonNotifyLiteMgr* GetCnt1tonNotifyLiteMgr() override;
      50              :     CntNto1NotifyLiteMgr* GetCntNto1NotifyLiteMgr() override;
      51              :     ConnectedLinkMgr* GetConnectedLinkMgr() override;
      52              :     DevId GetDevPhyId() override;
      53              :     u32 GetExecTimeOut() override;
      54              : 
      55            2 :     MemTransportLiteMgr* GetTransportLiteMgr() override { return transportLiteMgr.get(); }
      56              : 
      57            0 :     u64 GetLocAddr(BufferType type) override { return locBuffer[type]; }
      58              : 
      59            0 :     CollOperator GetCurrentOp() override { return currentOp; }
      60              : 
      61            2 :     void SetCurrentOpMode(OpMode opMode) { currentOp.opMode = opMode; }
      62              : 
      63           23 :     uint32_t GetCommIdIndex() const { return idIndex_; }
      64              : 
      65            0 :     RmaBufferLite* GetRmaBufferLite(BufferType type) override
      66              :     {
      67            0 :         if (rmaBufferLiteVec[type] != nullptr) {
      68            0 :             return rmaBufferLiteVec[type].get();
      69              :         } else {
      70            0 :             return nullptr;
      71              :         }
      72              :     }
      73              : 
      74            8 :     u64 GetCounterAddr() override { return opCounterAddr; }
      75              : 
      76           13 :     MirrorTaskManagerLite* GetMirrorTaskMgrLite() override { return mirrorTaskMgrLite.get(); }
      77              : 
      78            0 :     string GetId() const { return commId; }
      79              : 
      80            6 :     u32 GetRankSize() const { return rankSize; }
      81              : 
      82            6 :     RankId GetMyRank() const { return myRank; }
      83              : 
      84              :     KfcCommand BackGroundGetCmd();
      85              : 
      86            2 :     void BackGroundSetStatus(KfcStatus status, KfcErrType errorCode = KfcErrType::NONE);
      87              : 
      88            5 :     void SetIsCommReady(bool flag) { isCommReady = flag; }
      89              : 
      90            4 :     bool IsCommReady() const { return isCommReady; }
      91              : 
      92            2 :     void SetNeedClean(bool flag) { needClean = flag; }
      93              : 
      94            1 :     bool IsNeedClean() const { return needClean; }
      95              : 
      96            1 :     void SetIsSuspended(bool status) { isSuspended = status; }
      97              : 
      98            1 :     bool IsSuspended() const { return isSuspended; }
      99              : 
     100              :     const ProfilingReporterLite* GetProfilingReporterLite() const { return profilingReporterLite.get(); }
     101              : 
     102              :     bool IsFirstUsed() const { return isFirstUsed; }
     103              : 
     104            0 :     void SetIsFirstUsedToFalse() { isFirstUsed = false; }
     105              : 
     106          169 :     bool IsUsed() const { return isUsed; }
     107              : 
     108            9 :     void SetIsUsed(bool used) { isUsed = used; }
     109              : 
     110            9 :     std::mutex& GetAicpuMc2Mutex() { return aicpuMc2Mutex; }
     111              : 
     112            5 :     InsExecutor* GetInsExecutor() { return insExecutor.get(); }
     113              : 
     114            8 :     ProfilingReporterLite* GetProfilingReporterLite() { return profilingReporterLite.get(); }
     115              : 
     116              :     HcclResult SendErrorMessageReportToHost(ErrorMessageReport& errMsgInfo);
     117            0 :     u32 GetUserStreamId() const { return userStreamId_; }
     118              : 
     119            0 :     bool IsErrorReported() const { return isErrorReported_; }
     120              : 
     121            0 :     void SetErrorReported() { isErrorReported_ = true; }
     122              : 
     123            1 :     void ResetErrorReported() { isErrorReported_ = false; }
     124              : 
     125              :     void UnfoldOp(HcclKernelParamLite* kernelParam);
     126              :     void RegisterRtsqCallback();
     127              : 
     128              :     void CheckOpExecStatus() const;
     129              :     bool CheckNeedUpdateRes(HcclKernelParamLite* kernelParam);
     130              :     void UpdateCommParam(HcclKernelParamLite* kernelParam);
     131              :     void UpdateLocBuffer(HcclKernelParamLite* kernelParam);
     132              :     void UpdateRes(HcclKernelParamLite* kernelParam);
     133              :     void UpdateTransports(HcclKernelParamLite* kernelParam);
     134              :     void UpdateHDCommnicate(HcclKernelParamLite* kernelParam);
     135              :     void CreateCollAlgComponentLite();
     136              :     void InitCurrentOp(HcclKernelParamLite* kernelParam);
     137              :     void UpdateUserStreamId(HcclKernelParamLite* kernelParam);
     138              :     std::shared_ptr<InsQueue> GetInsQueue(HcclKernelParamLite* kernelParam);
     139              :     void SetDfxOpInfo(uint64_t beginTime);
     140              : 
     141              : private:
     142              :     std::unique_ptr<StreamLiteMgr> streamLiteMgr = std::make_unique<StreamLiteMgr>();
     143              :     std::unique_ptr<QueueNotifyLiteMgr> queueNotifyLiteMgr = std::make_unique<QueueNotifyLiteMgr>();
     144              :     std::unique_ptr<Cnt1tonNotifyLiteMgr> cnt1tonNotifyLiteMgr = std::make_unique<Cnt1tonNotifyLiteMgr>();
     145              :     std::unique_ptr<CntNto1NotifyLiteMgr> cntNto1NotifyLiteMgr = std::make_unique<CntNto1NotifyLiteMgr>();
     146              :     std::unique_ptr<ConnectedLinkMgr> connectedLinkMgr = std::make_unique<ConnectedLinkMgr>();
     147              :     std::unique_ptr<PrimTranslator> primTranslator = std::make_unique<PrimTranslator>();
     148              :     std::unique_ptr<InsExecutor> insExecutor = std::make_unique<InsExecutor>(this);
     149              :     std::unique_ptr<MirrorTaskManagerLite> mirrorTaskMgrLite = std::make_unique<MirrorTaskManagerLite>();
     150              :     std::unique_ptr<ProfilingReporterLite> profilingReporterLite
     151              :         = std::make_unique<ProfilingReporterLite>(mirrorTaskMgrLite.get(), &ProfilingHandlerLite::GetInstance());
     152              : 
     153              :     HcclResult InitProfilingReporterLite();
     154              : 
     155              :     std::unique_ptr<MemTransportLiteMgr> transportLiteMgr
     156              :         = std::make_unique<MemTransportLiteMgr>(mirrorTaskMgrLite.get());
     157              : 
     158              :     std::unique_ptr<HostDeviceSyncNotifyLiteMgr> hostDeviceSyncNotifyLiteMgr
     159              :         = std::make_unique<HostDeviceSyncNotifyLiteMgr>();
     160              : 
     161              :     std::unique_ptr<CollAlgComponentLite> algComponentLite{};
     162              : 
     163              :     void RestoreOpRes(const string& opTag, const string& tagKey, u64 addr, u64 bufSize);
     164              : 
     165              :     void RestoreAllTransports(u64 addr, u64 bufSize);
     166              :     unique_ptr<HDCommunicateLite> kfcControlTransferH2D = std::make_unique<HDCommunicateLite>();
     167              :     unique_ptr<HDCommunicateLite> kfcStatusTransferD2H = std::make_unique<HDCommunicateLite>();
     168              :     unique_ptr<AicpuHdcHandler> hdcHandler{};
     169              :     std::mutex hdcShmLock_;
     170              : 
     171              :     u32 idIndex_;
     172              :     u32 myRank{0};
     173              :     u32 rankSize{0};
     174              :     u32 devPhyId{0};
     175              :     u32 hcclExecTimeout{1836};
     176              :     u64 scratchSize{0};
     177              :     u64 locBuffer[BufferType::__COUNT__]{};
     178              :     u64 opCounterAddr{0};
     179              :     u32 opIndex_;
     180              :     std::string commId;
     181              :     bool isUpdateComm{false};
     182              :     CollOperator currentOp;
     183              : 
     184              :     bool isCommReady{false}; // 是否初始化完成
     185              :     bool needClean{false};   // 是否有待清理资源
     186              :     bool isSuspended{false}; // 是否处于暂停状态
     187              : 
     188              :     void InitRmaBufferLite(HcclAicpuLocBufLite& bufLite, BufferType type);
     189              :     void UpdateDynamicOpData(HcclKernelParamLite* kernelParam) const;
     190              : 
     191              :     std::vector<std::unique_ptr<RmaBufferLite>> rmaBufferLiteVec;
     192              :     DevType devType;
     193              : 
     194              :     std::unordered_map<std::string, AlgTopoInfo> algTopoInfoMap;
     195              : 
     196              :     std::unique_ptr<CollAlgInfo> collAlgInfo;
     197              :     std::unique_ptr<RmtDataBufferMgr> rmtDataBufferMgr;
     198              : 
     199              :     std::unordered_set<std::string> offloadOpSet;
     200              : 
     201              :     void CreateOneSidedComponentLite();
     202              :     std::unique_ptr<OneSidedComponentLite> oneSidedComponentLite{};
     203              :     std::shared_ptr<InsQueue> GetOneSidedInsQueue(HcclKernelParamLite* kernelParam);
     204              : 
     205              :     bool isUsed{false};
     206              :     bool isFirstUsed{true};
     207              :     std::mutex aicpuMc2Mutex;
     208              :     u32 userStreamId_{0};
     209              :     bool isErrorReported_{false};
     210              : 
     211              :     std::unordered_set<std::string> loadedOpSet{};
     212              : };
     213              : 
     214              : } // namespace Hccl
     215              : 
     216              : #endif // HCCL_AICPU_COMMUNICATOR_IMPL_LITE_H_
        

Generated by: LCOV version 2.0-1