LCOV - code coverage report
Current view: top level - coll_communicator_mgr/resource_mgr/local/my_rank/comm_engine/notify - notify_manager.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 1 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 NOTIFY_MANAGER_H
      12              : #define NOTIFY_MANAGER_H
      13              : 
      14              : #include "local_notify.h"
      15              : #include "hccl_common.h"
      16              : #include "hccl/hccl_res.h"
      17              : #include "hccl_independent_common.h"
      18              : #include "manager_common.h"
      19              : 
      20              : namespace hccl {
      21              : 
      22              : class NotifyManager {
      23              :     struct NotifyInfo {
      24              :         CommEngine commEngine;
      25              :         ::NotifyType notifyType;
      26              :         bool isAicpu;
      27              :         NotifyHandle notifyHandle;
      28              :     };
      29              : 
      30              : public:
      31              : #ifndef CCL_KERNEL_AICPU
      32              :     NotifyManager(std::string commId, aclrtBinHandle binHandle, const ManagerCallbacks& callbacks);
      33          381 :     ~NotifyManager() = default;
      34              : #endif
      35              : 
      36              :     static HcclResult
      37              :     ParseBinNotifys(const std::string& uniqueIdStr, std::vector<std::unique_ptr<LocalNotify>>& newNotifys);
      38              : #ifndef CCL_KERNEL_AICPU
      39              :     static std::string
      40              :     GetBinNotifys(std::vector<std::unique_ptr<LocalNotify>>& newNotifys, const NotifyLoadType notifyType);
      41              : 
      42              :     HcclResult HcclAllocNotify(
      43              :         CommEngine commEngine, ::NotifyType notifyType, uint32_t notifyNum, NotifyHandle** notifyHandleList);
      44              :     HcclResult HcommFreeNotify(uint32_t notifyNum, NotifyHandle* notifyHandleList);
      45              : 
      46              :     inline LocalNotify* GetNotify(u32 index) const
      47              :     {
      48              :         if (index > notifyNum_) {
      49              :             HCCL_ERROR(
      50              :                 "[NotifyManager][GetNotify]notifyNum[%u], notifyIdx[%u] out of range, maxIndex[%u]", notifyNum_, index,
      51              :                 (notifyNum_ == 0 ? 0 : notifyNum_ - 1));
      52              :             return nullptr;
      53              :         }
      54              :         return notifys_[index].get();
      55              :     }
      56              : 
      57              :     inline u32 GetNotifyNum() { return notifyNum_; }
      58              : #endif
      59              : private:
      60              :     static HcclResult
      61              :     InitNotifys(std::istringstream& iss, size_t notifyNum, std::vector<std::unique_ptr<LocalNotify>>& newNotifys);
      62              : #ifndef CCL_KERNEL_AICPU
      63              :     HcclResult NotifyTypeToNotifyLoadType(::NotifyType notifyType, NotifyLoadType& notifyLoadType);
      64              :     std::string commId_;
      65              :     aclrtBinHandle binHandle_;
      66              :     std::mutex notifyMutex_;
      67              :     bool isDeviceSide_ = false;
      68              :     u32 notifyNum_ = 0;
      69              :     std::vector<std::unique_ptr<LocalNotify>> notifys_;
      70              :     std::vector<std::unique_ptr<NotifyHandle[]>> handleBlocks_; // 托管所有 handle 数组
      71              :     std::unordered_map<LocalNotify*, NotifyInfo> notifysInfo_;
      72              :     ManagerCallbacks callbacks_;
      73              : #endif
      74              : };
      75              : } // namespace hccl
      76              : 
      77              : #endif
        

Generated by: LCOV version 2.0-1