LCOV - code coverage report
Current view: top level - base_comm/resources/endpoint_pairs/channels/aicpu - aicpu_ts_hccs_channel.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 50.0 % 2 1
Test Date: 2026-08-18 17:47:01 Functions: 50.0 % 2 1

            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 AICPU_TS_HCCS_CHANNEL_H
      12              : #define AICPU_TS_HCCS_CHANNEL_H
      13              : #include <memory>
      14              : #include <vector>
      15              : #include "hccl_mem_defs.h"
      16              : #include "transport_mem.h"
      17              : #include "hccl_res.h"
      18              : #include "hccl_socket.h"
      19              : #include "channel.h"
      20              : #include "aicpu_ts_channel_helper.h"
      21              : #include "channel_param.h"
      22              : #include "buffer.h"
      23              : #include "hccl_dispatcher_ctx.h"
      24              : #include "rma_buffer.h"
      25              : #include "hcomm_c_adpt.h"
      26              : #include "../../../endpoints/aicputs_hccs_endpoint.h"
      27              : 
      28              : namespace hcomm {
      29              : /**
      30              :  * @note 职责:Channel的AicpuTs通信引擎、HCCS协议的类派生
      31              :  */
      32              : class AicpuTsHccsChannel : public Channel {
      33              : public:
      34              :     struct HccsExchangeInfo {
      35              :         s32 memNum = 0;
      36              :     };
      37              :     AicpuTsHccsChannel(EndpointHandle endpointHandle, const HcommChannelDesc& channelDesc);
      38              :     virtual ~AicpuTsHccsChannel();
      39              : 
      40              :     HcclResult Init() override;
      41              :     HcclResult GetNotifyNum(uint32_t* notifyNum) const override;
      42              :     HcclResult GetRemoteMems(uint32_t* memNum, CommMem** remoteMem, char*** memInfos) override;
      43              :     ChannelStatus GetStatus() override;
      44              : 
      45              :     std::shared_ptr<hccl::Transport> GetTransport() { return transport_; }
      46              :     HcclResult Clean() override;
      47              :     HcclResult Resume() override;
      48            0 :     const HcommChannelDesc& GetChannelDesc() const override { return channelDesc_; }
      49              : 
      50              :     // for launch channel kernel data
      51              :     HcclResult Serialize(std::shared_ptr<hccl::DeviceMem>& out) override;
      52              :     HcommChannelKind GetChannelKind() const override;
      53              : 
      54              :     // 数据面接口
      55              :     HcclResult NotifyRecord(const uint32_t remoteNotifyIdx) override;
      56              :     HcclResult NotifyWait(const uint32_t localNotifyIdx, const uint32_t timeout) override;
      57              :     HcclResult WriteWithNotify(void* dst, const void* src, const uint64_t len, uint32_t remoteNotifyIdx) override;
      58              :     HcclResult Write(void* dst, const void* src, uint64_t len) override;
      59              :     HcclResult Read(void* dst, const void* src, uint64_t len) override;
      60              :     HcclResult ChannelFence() override;
      61              : 
      62            2 :     AicpuTsChannelHelper* GetAicpuTsHelper() override { return &aicpuTsHelper_; }
      63              : 
      64              : private:
      65              :     AicpuTsChannelHelper aicpuTsHelper_;
      66              :     HcclResult ParseInputParam();
      67              :     HcclResult EnableP2P();
      68              :     void DisableP2P();
      69              :     HcclResult BuildConnection();
      70              :     void DestroyConnection();
      71              :     HcclResult EnableMemAccess();
      72              :     void DisableMemAccess();
      73              :     HcclResult GetFirstIpByPhyId(u32 devicePhyId, u32 superDevId, hccl::HcclIpAddress& ip);
      74              :     HcclResult SetMachinePara(hccl::MachinePara& machinePara);
      75              :     void SetTransportParam(hccl::TransportPara& para);
      76              :     HcclResult TransportInit();
      77              :     void TransportDeInit();
      78              :     HcclResult BuildHcclChannelHccsRes(HcclChannelHccsRes& channelHccsRes);
      79              : 
      80              : private:
      81              :     // --------------------- 入参 ---------------------
      82              :     EndpointHandle endpointHandle_{nullptr};
      83              :     HcommChannelDesc channelDesc_;
      84              : 
      85              :     // --------------------- 转换参数 ---------------------
      86              :     EndpointDesc localEp_{};
      87              :     EndpointDesc remoteEp_{};
      88              :     hccl::HcclIpAddress localIp_;
      89              :     hccl::HcclIpAddress remoteIp_;
      90              :     uint32_t notifyNum_{0};
      91              :     AicpuTsHccsEndpoint* localEpPtr_{nullptr};
      92              :     uint32_t serverPort_{AICPU_CHANNEL_DEFAULT_PORT};
      93              :     bool serverInited_{false};
      94              :     // --------------------- 具体成员 ---------------------
      95              :     std::shared_ptr<hccl::HcclSocket> socket_{nullptr};
      96              :     std::string socketTag_{};
      97              :     bool isSocketServer_{false};
      98              :     // for create TransportMem
      99              :     HcclDispatcher dispatcher_{nullptr}; // dispatcher放到最后析构
     100              :     DispatcherCtxPtr dispatcherCtx_{nullptr};
     101              :     std::unique_ptr<hccl::NotifyPool> notifyPool_;
     102              :     std::shared_ptr<hccl::Transport> transport_{nullptr};
     103              : 
     104              :     // for get mem temp
     105              :     std::vector<CommMem> remoteIpcRmaBufferVec_;
     106              :     std::vector<HcclMemEx> localIpcRmaBufferVecEx_;
     107              :     std::vector<HcclMemEx> remoteIpcRmaBufferVecEx_;
     108              : };
     109              : } // namespace hcomm
     110              : 
     111              : #endif // AICPU_TS_HCCS_CHANNEL_H
        

Generated by: LCOV version 2.0-1