LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/selector - auto_selector_base.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 66 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 11 0

            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 "auto_selector_base.h"
      12              : #include "coll_operator.h"
      13              : #include "coll_alg_params.h"
      14              : 
      15              : namespace Hccl {
      16              : 
      17            0 : SelectorStatus AutoSelectorBase::Select(const CollAlgOperator& op, CollAlgParams& params, std::string& primQueueGenName)
      18              : {
      19            0 :     HCCL_DEBUG("[AutoSelectorBase][%s] start", __func__);
      20            0 :     TopoInfo topoInfo;
      21            0 :     HCCL_DEBUG("[AutoSelectorBase][%s] CalcTopoShape start", __func__);
      22            0 :     CalcTopoShape(topoInfo);
      23            0 :     HCCL_DEBUG("[AutoSelectorBase][%s] end, levelNum[%u]", __func__, topoInfo.levelNum);
      24            0 :     std::map<OpType, std::vector<HcclAlgoType>> configAlgMap = EnvConfig::GetInstance().GetAlgoConfig().GetAlgoConfig();
      25            0 :     SelectorStatus ret = SelectorStatus::NOT_MATCH;
      26            0 :     HCCL_DEBUG(
      27              :         "[AutoSelectorBase][%s] params.opExecuteConfig.accelerator[%s]", __func__,
      28              :         params.opExecuteConfig.accState.Describe().c_str());
      29            0 :     dataSize_ = op.dataCount * DataTypeSizeGet(op.dataType);
      30              :     ;
      31            0 :     if (params.opExecuteConfig.accState == AcceleratorState::CCU_MS) {
      32            0 :         ret = SelectCcuMsAlgo(topoInfo, op, configAlgMap, primQueueGenName);
      33            0 :         if (ret == SelectorStatus::NOT_MATCH) {
      34            0 :             params.opExecuteConfig.accState = AcceleratorState::CCU_SCHED;
      35              :         } else {
      36            0 :             return ret;
      37              :         }
      38              :     }
      39            0 :     if (params.opExecuteConfig.accState == AcceleratorState::CCU_SCHED) {
      40            0 :         ret = SelectCcuScheduleAlgo(topoInfo, op, configAlgMap, primQueueGenName);
      41            0 :         if (ret == SelectorStatus::NOT_MATCH) {
      42            0 :             params.opExecuteConfig.accState = AcceleratorState::CCU_FALLBACK;
      43              :         } else {
      44            0 :             return ret;
      45              :         }
      46              :     }
      47            0 :     if (params.opExecuteConfig.accState == AcceleratorState::AIV) {
      48            0 :         if (op.opType != OpType::BARRIER) {
      49            0 :             ret = SelectAivAlgo(topoInfo, op, configAlgMap, primQueueGenName);
      50              :         }
      51            0 :         if (ret == SelectorStatus::MATCH) {
      52            0 :             return ret;
      53              :         }
      54            0 :         params.opExecuteConfig.accState = AcceleratorState::CCU_FALLBACK;
      55              :     }
      56              : 
      57            0 :     if (params.opExecuteConfig.accState == AcceleratorState::AIV_ONLY) {
      58            0 :         return (op.opType == OpType::BARRIER) ? SelectorStatus::NOT_MATCH :
      59            0 :                                                 SelectAivAlgo(topoInfo, op, configAlgMap, primQueueGenName);
      60              :     }
      61            0 :     if (IsStarsState(params.opExecuteConfig)) {
      62              :         // level0是PCIE混合的场景,且CLOS规模大于8,选择AIV_ONLY算法
      63            0 :         if (topoInfo.level0PcieMix && topoInfo.level0BigClosRange) {
      64            0 :             params.opExecuteConfig.accState = AcceleratorState::AIV_ONLY;
      65            0 :             return (op.opType == OpType::BARRIER) ? SelectorStatus::NOT_MATCH :
      66            0 :                                                     SelectAivAlgo(topoInfo, op, configAlgMap, primQueueGenName);
      67              :         }
      68            0 :         ret = SelectAicpuAlgo(topoInfo, op, configAlgMap, primQueueGenName);
      69            0 :         if ((ret == SelectorStatus::MATCH) && (params.opExecuteConfig.accState == AcceleratorState::CCU_FALLBACK)) {
      70            0 :             params.opExecuteConfig.accState = AcceleratorState::AICPU_TS;
      71              :         }
      72            0 :         return ret;
      73              :     }
      74            0 :     return SelectorStatus::NOT_MATCH;
      75            0 : }
      76              : 
      77            0 : bool AutoSelectorBase::IsStarsState(const OpExecuteConfig& opExecuteConfig) const
      78              : {
      79              :     return (
      80            0 :         opExecuteConfig.accState == AcceleratorState::AICPU_TS
      81            0 :         || opExecuteConfig.accState == AcceleratorState::HOSTCPU_TS
      82            0 :         || opExecuteConfig.accState == AcceleratorState::CCU_FALLBACK);
      83              : }
      84              : 
      85            0 : bool AutoSelectorBase::IsDefaultAlg(const HcclAlgoType algoType) const
      86              : {
      87            0 :     return (algoType == HcclAlgoType::HCCL_ALGO_TYPE_DEFAULT) || (algoType == HcclAlgoType::HCCL_ALGO_TYPE_NA);
      88              : }
      89              : 
      90            0 : HcclAlgoType AutoSelectorBase::GetLevel0AlgoType(
      91              :     const CollAlgOperator& op, const std::map<OpType, std::vector<HcclAlgoType>>& configAlgMap) const
      92              : {
      93            0 :     HcclAlgoType levle0Algo = HcclAlgoType::HCCL_ALGO_TYPE_DEFAULT;
      94            0 :     auto it = configAlgMap.find(op.opType);
      95            0 :     if ((it != configAlgMap.end()) && (it->second.size() > 0)) {
      96            0 :         levle0Algo = it->second[0];
      97              :     }
      98            0 :     return levle0Algo;
      99              : }
     100              : 
     101            0 : bool AutoSelectorBase::IsSmallData(const u64 dataSize) const { return dataSize < SMALL_COUNT_512KB; }
     102              : 
     103            0 : bool AutoSelectorBase::IsLargeData(const u64 dataSize) const { return dataSize >= LARGE_COUNT_1024KB; }
     104              : 
     105            0 : bool AutoSelectorBase::IsSmallDataCCU(const u64 dataSize, const u64 rankSize) const
     106              : {
     107            0 :     if (rankSize == 0) {
     108            0 :         HCCL_WARNING("the selector is not set RankSize");
     109              :     }
     110            0 :     return (dataSize <= CCU_PARALLEL_MAX_DATA_SIZE) ? true : false;
     111              : }
     112              : 
     113            0 : SelectorStatus AutoSelectorBase::SelectCcuMsAlgo(
     114              :     const TopoInfo& topoInfo, const CollAlgOperator& op,
     115              :     const std::map<OpType, std::vector<HcclAlgoType>>& configAlgMap, std::string& primQueueGenName) const
     116              : {
     117              :     (void)topoInfo;
     118              :     (void)op;
     119              :     (void)configAlgMap;
     120              :     (void)primQueueGenName;
     121            0 :     return SelectorStatus::NOT_MATCH;
     122              : }
     123              : 
     124            0 : SelectorStatus AutoSelectorBase::SelectCcuScheduleAlgo(
     125              :     const TopoInfo& topoInfo, const CollAlgOperator& op,
     126              :     const std::map<OpType, std::vector<HcclAlgoType>>& configAlgMap, std::string& primQueueGenName) const
     127              : {
     128              :     (void)topoInfo;
     129              :     (void)op;
     130              :     (void)configAlgMap;
     131              :     (void)primQueueGenName;
     132            0 :     return SelectorStatus::NOT_MATCH;
     133              : }
     134              : 
     135            0 : SelectorStatus AutoSelectorBase::SelectAicpuAlgo(
     136              :     const TopoInfo& topoInfo, const CollAlgOperator& op,
     137              :     const std::map<OpType, std::vector<HcclAlgoType>>& configAlgMap, std::string& primQueueGenName) const
     138              : {
     139              :     (void)topoInfo;
     140              :     (void)op;
     141              :     (void)configAlgMap;
     142              :     (void)primQueueGenName;
     143            0 :     return SelectorStatus::NOT_MATCH;
     144              : }
     145              : 
     146            0 : SelectorStatus AutoSelectorBase::SelectAivAlgo(
     147              :     const TopoInfo& topoInfo, const CollAlgOperator& op,
     148              :     const std::map<OpType, std::vector<HcclAlgoType>>& configAlgMap, std::string& primQueueGenName) const
     149              : {
     150              :     (void)topoInfo;
     151              :     (void)op;
     152              :     (void)configAlgMap;
     153              :     (void)primQueueGenName;
     154            0 :     return SelectorStatus::NOT_MATCH;
     155              : }
     156              : 
     157              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1