LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/registry - coll_alg_exec_registry.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 76.5 % 17 13
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 3 3

            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 "coll_alg_exec_registry.h"
      12              : 
      13              : namespace hccl {
      14              : 
      15         7314 : CollAlgExecRegistry& CollAlgExecRegistry::Instance()
      16              : {
      17         7314 :     static CollAlgExecRegistry globalExecRegistry;
      18         7314 :     return globalExecRegistry;
      19              : }
      20              : 
      21         7238 : HcclResult CollAlgExecRegistry::Register(const std::string& tag, const CollExecCreator& collExecCreator)
      22              : {
      23         7238 :     const std::lock_guard<std::mutex> lock(mu_);
      24         7238 :     if (execCreators_.find(tag) != execCreators_.end()) {
      25            0 :         HCCL_WARNING("[CollAlgExecRegistry]Exec tag[%s] already registered.", tag.c_str());
      26            0 :         return HcclResult::HCCL_E_INTERNAL;
      27              :     }
      28         7238 :     execCreators_.emplace(tag, collExecCreator);
      29         7238 :     return HcclResult::HCCL_SUCCESS;
      30         7238 : }
      31              : 
      32           76 : std::unique_ptr<CollExecutorBase> CollAlgExecRegistry::GetAlgExec(
      33              :     const std::string& tag, const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher)
      34              : {
      35           76 :     if (execCreators_.find(tag) == execCreators_.end()) {
      36            0 :         HCCL_DEBUG("[CollAlgExecRegistry]Creator for executor tag[%s] has not registered.", tag.c_str());
      37            0 :         return nullptr;
      38              :     }
      39           66 :     HCCL_DEBUG("[CollAlgExecRegistry][GetAlgExec]get executor by algName[%s].", tag.c_str());
      40           79 :     return std::unique_ptr<CollExecutorBase>(execCreators_[tag](dispatcher, topoMatcher));
      41              : }
      42              : 
      43              : } // namespace hccl
        

Generated by: LCOV version 2.0-1