LCOV - code coverage report
Current view: top level - coll_communicator_mgr/resource_mgr/local/my_rank/comm_engine_reses - comm_engine_res_manager.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 85.4 % 41 35
Test Date: 2026-07-28 12:11:00 Functions: 81.8 % 11 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              : #include "comm_engine_res_manager.h"
      12              : 
      13              : namespace hccl {
      14          686 : CommEngineResMgr::CommEngineResMgr(){};
      15              : 
      16          331 : HcclResult CommEngineResMgr::Init(uint32_t threadNum, uint32_t notifyNumPerThread,
      17              :     const std::string& commId, const aclrtBinHandle binHandle, const ManagerCallbacks& callbacks)
      18              : {
      19          331 :     std::lock_guard<std::mutex> lock(mtx_);
      20          331 :     HCCL_INFO("[CommEngineResMgr][%s] Hcom[%s] threadNum[%u], notifyPerThread[%u]", 
      21              :         __func__, commId.c_str(), threadNum, notifyNumPerThread);
      22          331 :     if (!threadMgr_) {
      23          331 :         EXCEPTION_CATCH(threadMgr_ = std::make_unique<ThreadMgr>(threadNum, notifyNumPerThread, commId, binHandle, callbacks),
      24              :             return HCCL_E_PTR);
      25              :     }
      26          331 :     if (!notifyMgr_) {
      27          331 :         EXCEPTION_CATCH(notifyMgr_ = std::make_unique<NotifyManager>(commId, binHandle, callbacks),
      28              :             return HCCL_E_PTR);
      29              :     }
      30          331 :     return HCCL_SUCCESS;
      31          331 : }
      32              : 
      33           16 : HcclResult CommEngineResMgr::HcclThreadAcquireV2(CommEngine engine, uint32_t threadNum, ThreadType type,
      34              :     const ThreadConfig *config, ThreadHandle *threads, std::vector<uint32_t> &threadId)
      35              : {
      36           16 :     CHK_SMART_PTR_NULL(threadMgr_);
      37           16 :     uint32_t setThreadNum = threadMgr_->GetThreadNum();
      38           16 :     CHK_PRT_RET(threadNum > setThreadNum, HCCL_ERROR("[%s]Alloced thread num[%u] more than num[%u] in config type[%d]",
      39              :         __func__, threadNum, setThreadNum, static_cast<int32_t>(type)), HCCL_E_PARA);
      40           16 :     return threadMgr_->HcclThreadAcquireV2(engine, threadNum, type, config, threads, threadId);
      41              : }
      42              : 
      43            5 : HcclResult CommEngineResMgr::HcclThreadAcquire(CommEngine engine, uint32_t threadNum, ThreadType type,
      44              :     const ThreadConfig *config, ThreadHandle *threads, std::vector<uint32_t> &threadId)
      45              : {
      46            5 :     CHK_SMART_PTR_NULL(threadMgr_);
      47            5 :     uint32_t setThreadNum = threadMgr_->GetThreadNum();
      48            5 :     CHK_PRT_RET(threadNum > setThreadNum,  HCCL_ERROR("[%s] Alloced thread num[%u] more than num[%u] in config type[%d]", 
      49              :         __func__, threadNum, setThreadNum, static_cast<int32_t>(type)), HCCL_E_PARA);
      50            5 :     return threadMgr_->HcclThreadAcquire(engine, threadNum, type, config, threads, threadId);
      51              : }
      52              : 
      53            2 : HcclResult CommEngineResMgr::HcclThreadAcquireWithStream(CommEngine engine,
      54              :         rtStream_t stream, uint32_t notifyNum, ThreadHandle *thread)
      55              : {
      56            2 :     CHK_SMART_PTR_NULL(threadMgr_);
      57            1 :     return threadMgr_->HcclThreadAcquireWithStream(engine, stream, notifyNum, thread);
      58              : }
      59              : 
      60            5 : HcclResult CommEngineResMgr::HcclGetNotifyNumInThread(ThreadHandle thread, CommEngine engine, uint32_t *notifyNum)
      61              : {
      62            5 :     CHK_SMART_PTR_NULL(threadMgr_);
      63            4 :     return threadMgr_->HcclGetNotifyNumInThread(thread, notifyNum);
      64              : }
      65              : 
      66            0 : HcclResult CommEngineResMgr::HcclAllocNotify(CommEngine commEngine, ::NotifyType notifyType, uint32_t notifyNum,
      67              :     NotifyHandle **notifyHandleList)
      68              : {
      69            0 :     CHK_SMART_PTR_NULL(threadMgr_);
      70            0 :     return notifyMgr_->HcclAllocNotify(commEngine, notifyType, notifyNum, notifyHandleList);
      71              : }
      72              : 
      73            0 : HcclResult CommEngineResMgr::HcommFreeNotify(uint32_t notifyNum, NotifyHandle *notifyHandleList)
      74              : {
      75            0 :     CHK_SMART_PTR_NULL(threadMgr_);
      76            0 :     return notifyMgr_->HcommFreeNotify(notifyNum, notifyHandleList);
      77              : }
      78              : 
      79            4 : HcclResult CommEngineResMgr::HcclThreadExportToCommEngine(uint32_t threadNum, const ThreadHandle *threads, CommEngine dstCommEngine, ThreadHandle *exportedThreads)
      80              : {
      81            4 :     CHK_SMART_PTR_NULL(threadMgr_);
      82            4 :     return threadMgr_->HcclThreadExportToCommEngine(threadNum, threads, dstCommEngine, exportedThreads);
      83              : }
      84              : 
      85            4 : HcclResult CommEngineResMgr::HcclThreadResGetInfo(ThreadHandle thread, ThreadResType resType, uint32_t infoLen, void **info)
      86              : {
      87            4 :     CHK_SMART_PTR_NULL(threadMgr_);
      88            4 :     return threadMgr_->HcclThreadResGetInfo(thread, resType, infoLen, info);
      89              : }
      90              : 
      91           10 : HcclResult CommEngineResMgr::HcclDedicatedThreadAcquire(HcclDedicatedThreadType useType, uint32_t notifyNumPerThread, ThreadHandle *thread) 
      92              : { 
      93           10 :     CHK_SMART_PTR_NULL(threadMgr_);     
      94           10 :     return threadMgr_->HcclDedicatedThreadAcquire(useType, notifyNumPerThread, thread); 
      95              : } 
      96              : 
      97              : }
        

Generated by: LCOV version 2.0-1