LCOV - code coverage report
Current view: top level - base_comm/resources/comm_engine_res/threads - aicpu_ts_thread.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 4 4
Test Date: 2026-07-28 12:11:00 Functions: 100.0 % 2 2

            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              : #ifndef AICPU_TS_THREAD_H
      11              : #define AICPU_TS_THREAD_H
      12              : 
      13              : #include <vector>
      14              : #include "thread.h"
      15              : #include "aicpu_ts_thread_interface.h"
      16              : 
      17              : namespace hccl {
      18              : class AicpuTsThread : public Thread {
      19              : public:
      20              :     AicpuTsThread(StreamType streamType, uint32_t notifyNum, const NotifyLoadType notifyLoadType);
      21              :     AicpuTsThread(const std::string &uniqueIdStr);
      22              : 
      23              :     ~AicpuTsThread();
      24              : 
      25              :     HcclResult Init() override;
      26              :     HcclResult DeInit() override;
      27              :     std::string &GetUniqueId() override;
      28              :     uint32_t GetNotifyNum() const override;
      29              :     LocalNotify *GetNotify(uint32_t index) const override;
      30              :     HcclResult GetNotifyByUniqueId(u32 &notifyNum, std::string &notifyDesc);
      31              :     HcclResult SupplementNotify(uint32_t notifyNum) override;
      32              :     HcclResult SupplementNotify(u32 notifyNum, const std::string &notifyDesc);
      33              : 
      34              :     // A3 Stream & A5 Stream
      35           48 :     inline bool IsDeviceA5() const override
      36              :     {
      37           48 :         return devType_ == DevType::DEV_TYPE_950 || devType_ == DevType::DEV_TYPE_960;
      38              :     }
      39              : 
      40              :     Stream *GetStream() const override;
      41              : 
      42           51 :     inline void *GetStreamLitePtr() const override
      43              :     {
      44           51 :         return pImpl_->GetStreamLitePtr();
      45              :     }
      46              : 
      47              :     void LaunchTask() const override;
      48              :     void TryLaunchTask() const override;
      49              : 
      50              :     // Local Data Plane Functions
      51              :     HcclResult LocalNotifyWait(uint32_t notifyId) const override;
      52              :     HcclResult LocalNotifyRecord(uint32_t notifyId) const override;
      53              : 
      54              :     HcclResult LocalNotifyRecord(ThreadHandle dstThread, uint32_t dstNotifyIdx) const override;
      55              :     HcclResult LocalNotifyWait(uint32_t notifyId, uint32_t timeout) const override;
      56              : 
      57              :     HcclResult LocalCopy(void *dst, const void *src, uint64_t size) const override;
      58              :     HcclResult LocalReduce(
      59              :         void *dst, const void *src, uint64_t size, HcommDataType dataType, HcommReduceOp reduceOp) const override;
      60              : 
      61              :     // Non-override functions
      62              :     HcclResult GetSqHeadAndTail(uint32_t& sqHead, uint32_t& sqTail);
      63              :     bool GetMaster() const override;
      64              :     void SetIsMaster(bool isMaster) override;
      65              : 
      66              :     HcclResult SetCheckExecStatusCallback(std::function<HcclResult(bool)> callback) override;
      67              : private:
      68              :     bool isMaster_{false};
      69              :     struct HcclStreamInfo {
      70              :         s32 streamIds;
      71              :         uint32_t sqIds;
      72              :         uint32_t cqIds;       // 记录物理cqId
      73              :         uint32_t logicCqids;  // 记录逻辑cqId
      74              :     };
      75              : 
      76              :     struct HcclStreamParam {
      77              :         HcclStreamInfo streamInfo;
      78              :         uint64_t sqCqContextAddr = 0;  // 记录sqeContext地址
      79              :         uint64_t sqCqContextSize = 0;  // 记录sqeContext大小
      80              :     };
      81              :     HcclResult InitStreamLite(HcclStreamInfo &streamParam, uint32_t hostPhyId);
      82              :     HcclResult InitStream(HcclStreamParam &streamParam);
      83              :     HcclResult HostInit();
      84              :     HcclResult DeviceInit();
      85              :     std::string &UpdateUniqueId();
      86              : #ifdef CCL_KERNEL_AICPU
      87              :     HcclResult BuildComStreamInfo(const HcclStreamInfo &streamInfo, HcclComStreamInfo &comStreamInfo) const;
      88              : #endif
      89              :     template <typename Operation, typename ReportOp>
      90              :     HcclResult LocalProcess(void *dst, const void *src, uint64_t size, Operation &&op, ReportOp &&reportOp) const;
      91              : 
      92              :     // 成员变量(适配 AICPU-TS)
      93              :     bool isDeviceSide_ = false;
      94              :     rtStream_t rtStream_ = nullptr;
      95              :     StreamType streamType_ = StreamType::STREAM_TYPE_RESERVED;
      96              :     uint32_t notifyNum_ = 0;
      97              :     NotifyLoadType notifyLoadType_ = NotifyLoadType::HOST_NOTIFY;
      98              :     uint32_t devId_ = INVALID_UINT;
      99              :     std::unique_ptr<Stream> stream_ = nullptr;
     100              :     std::vector<std::unique_ptr<LocalNotify>> notifys_;
     101              :     std::string uniqueIdStr_;
     102              :     DeviceMem sqCqeContext_;
     103              :     DevType devType_ = DevType::DEV_TYPE_COUNT;
     104              :     std::unique_ptr<Hccl::IAicpuTsThread> pImpl_{nullptr};
     105              : };
     106              : 
     107              : }  // namespace hccl
     108              : #endif  // AICPU_TS_THREAD_H
        

Generated by: LCOV version 2.0-1