LCOV - code coverage report
Current view: top level - coll_communicator_mgr/communicator/device - coll_comm_aicpu.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 9 9
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 9 9

            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 COLL_COMM_AICPU_H
      12              : #define COLL_COMM_AICPU_H
      13              : 
      14              : #include "common.h"
      15              : #include "aicpu_init_param.h"
      16              : #include "topo_matcher.h"
      17              : #include "hcomm_primitives.h"
      18              : #include "transport_pub.h"
      19              : #include "thread.h"
      20              : #include "local_notify.h"
      21              : #include "ub_transport_lite_impl.h"
      22              : #include "p2p_transport_lite_impl.h"
      23              : #include "task_exception.h"
      24              : #include "aicpu_launch_manager.h"
      25              : #include "channel_param.h"
      26              : #include "hdc_pub.h"
      27              : #include "ns_recovery/aicpu/ns_recovery_lite.h"
      28              : #include <atomic>
      29              : #include "hcclCommDfxLite.h"
      30              : #include "error_message_v2.h"
      31              : #include "kfc.h"
      32              : #include "aicpu_hdc.h"
      33              : #include "roce_transport_lite_impl.h"
      34              : #include "hccl/hccl_types.h"
      35              : #include "comm_engine_res_aicpu_mgr.h"
      36              : #include "channel_aicpu_mgr.h"
      37              : 
      38              : using namespace hccl;
      39              : 
      40              : namespace hccl {
      41              : class HcclCommAicpu;
      42              : }
      43              : 
      44              : class CollCommAicpu {
      45              : public:
      46              :     ~CollCommAicpu();
      47              :     HcclResult InitAicpuIndOp(CommAicpuParam* commAicpuParam);
      48              : 
      49              :     // 资源管理 — 通过mgr指针暴露,调用者通过mgr操作资源
      50           21 :     CommEngineResAicpuMgr* GetCommEngineResMgr() { return commEngineResMgr_.get(); }
      51            1 :     ChannelAicpuMgr* GetChannelMgr() { return channelMgr_.get(); }
      52              : 
      53              :     // 910B legacy 通信域管理
      54              :     hccl::HcclCommAicpu* GetLegacy910CollComm();
      55              :     void SetLegacy910CollComm(std::shared_ptr<hccl::HcclCommAicpu> comm);
      56              :     bool IsLegacy910CollCommBusy();
      57              :     void SetLegacy910CollCommBusy(bool busy);
      58              : 
      59            5 :     const HcclTopoInfo& GetTopoInfo() { return topoInfo_; }
      60           19 :     const std::string& GetIdentifier() { return identifier_; }
      61              : 
      62              :     // taskException
      63            3 :     bool IsErrorReported() { return isErrorReported_; }
      64            2 :     void SetErrorReported(bool isErrorReported) { isErrorReported_ = isErrorReported; }
      65              :     HcclResult SendErrorMessageReportToHost(Hccl::ErrorMessageReport& errMsgInfo);
      66              :     HcclResult RegisterProfCallBack();
      67            4 :     HcclCommDfxLite* GetHcclCommDfxLite() { return &dfx_; };
      68            8 :     u32 GetDevId() { return devId_; }
      69              : 
      70              :     // h2d - d2h通道信息交互
      71              :     HcclResult BackGroundGetCmd(Hccl::KfcCommand& cmd);
      72              :     HcclResult BackGroundSetStatus(Hccl::KfcStatus state);
      73              :     u32 UpdateIndex();
      74              : 
      75           11 :     HcclCommStatus GetCommmStatus() { return commStatus_; }
      76              :     void SetCommmStatus(HcclCommStatus status);
      77              : 
      78              :     // N秒快恢
      79              :     hccl::NsRecoveryLitePtr GetNsRecoveryLitePtr();
      80              :     HcclResult Clean();
      81              :     HcclResult Resume(HcclChannelUrmaRes* commParam);
      82              : 
      83              :     HcclResult CheckIndOpExecStatus(bool timeout);
      84              : 
      85              :     // DFX — 单通信域粒度操作
      86              :     HcclResult InitDfxOpInfo(HcclDfxOpInfo* aicpuDfxInfo);
      87              :     HcclResult ProfilingReportDeviceOp();
      88              :     HcclResult UpdateTask();
      89              : 
      90              : private:
      91              :     HcclResult InitHDCommunicate(CommAicpuParam* commAicpuParam);
      92              : 
      93              :     u32 devId_{0};
      94              :     // 通用的通道
      95              :     std::shared_ptr<hccl::HDCommunicate> kfcControlTransferH2D_{nullptr};
      96              :     std::shared_ptr<hccl::HDCommunicate> kfcStatusTransferD2H_{nullptr};
      97              : 
      98              :     std::string identifier_;
      99              :     HcclCommStatus commStatus_{HcclCommStatus::HCCL_COMM_STATUS_INVALID};
     100              :     HcclTopoInfo topoInfo_;
     101              : 
     102              :     // dfx — 必须在 commEngineResMgr_/channelMgr_ 之前声明,确保后析构
     103              :     bool isErrorReported_{false};
     104              :     HcclCommDfxLite dfx_;
     105              : 
     106              :     // 资源管理 — 通过mgr持有(持有 dfx_ 引用)
     107              :     std::unique_ptr<CommEngineResAicpuMgr> commEngineResMgr_;
     108              :     std::unique_ptr<ChannelAicpuMgr> channelMgr_;
     109              : 
     110              :     // 910B legacy 通信域 — CollCommAicpu 作为 wrapper,通过 shared_ptr 共享所有权
     111              :     // std::atomic_bool 用于标记使用中
     112              :     std::pair<std::shared_ptr<hccl::HcclCommAicpu>, std::atomic_bool> legacy910CollComm_;
     113              : 
     114              :     // N秒快恢相关
     115              :     hccl::NsRecoveryLitePtr nsRecoveryLitePtr_{nullptr};
     116              : 
     117              :     u32 index_{0};
     118              : };
     119              : 
     120              : #endif // COLL_COMM_AICPU_H
        

Generated by: LCOV version 2.0-1