LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/selector - all_gather_auto_selector.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 108 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 4 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 "all_gather_auto_selector.h"
      12              : #include "selector_registry.h"
      13              : #include "coll_operator.h"
      14              : 
      15              : namespace Hccl {
      16              : 
      17            0 : SelectorStatus AllGatherAutoSelector::SelectCcuMsAlgo(
      18              :     const TopoInfo& topoInfo, const CollAlgOperator& op,
      19              :     const std::map<OpType, std::vector<HcclAlgoType>>& configAlgMap, std::string& primQueueGenName) const
      20              : {
      21              :     (void)op;
      22              :     (void)configAlgMap;
      23            0 :     HCCL_DEBUG("[AllGatherAutoSelector][%s] start, topoInfo levelNum[%u]", __func__, topoInfo.levelNum);
      24            0 :     u32 rankSize_2P = 2;
      25            0 :     u32 rankSize_4P = 4;
      26            0 :     HcclDetourType detourType = EnvConfig::GetInstance().GetDetourConfig().GetDetourType();
      27            0 :     CHK_PRT_RET(
      28              :         (detourType == HcclDetourType::HCCL_DETOUR_ENABLE_2P && rankSize_ != rankSize_2P)
      29              :             || (detourType == HcclDetourType::HCCL_DETOUR_ENABLE_4P && rankSize_ != rankSize_4P),
      30              :         HCCL_WARNING("[Algo][AllGatherAutoSelector] detourType not match for rankSize."), SelectorStatus::NOT_MATCH);
      31              : 
      32            0 :     CHK_PRT_RET(
      33              :         detourType == HcclDetourType::HCCL_DETOUR_ENABLE_2P_AND_4P,
      34              :         HCCL_WARNING("[Algo][AllGatherAutoSelector] HCCL_DETOUR_ENABLE_2P_AND_4P is not supported yet."),
      35              :         SelectorStatus::NOT_MATCH);
      36              : 
      37            0 :     if (topoInfo.levelNum > 1) {
      38            0 :         HCCL_WARNING("[Algo][AllGatherAutoSelector] levelNum > 1 is not supported yet for ccu_ms mode.");
      39            0 :         return SelectorStatus::NOT_MATCH;
      40              :     } else {
      41            0 :         if (topoInfo.level0Shape == Level0Shape::MESH_1D) {
      42            0 :             if (Is2DieFullMesh()) {
      43            0 :                 primQueueGenName = "CcuAllGatherMesh1D2Die";
      44            0 :             } else if (
      45            0 :                 (detourType == HcclDetourType::HCCL_DETOUR_ENABLE_2P && rankSize_ == rankSize_2P)
      46            0 :                 || (detourType == HcclDetourType::HCCL_DETOUR_ENABLE_4P && rankSize_ == rankSize_4P)) {
      47            0 :                 primQueueGenName = "CcuAllGatherMeshDetour1D";
      48              :             } else {
      49            0 :                 primQueueGenName = "CcuAllGatherMesh1D";
      50              :             }
      51            0 :         } else if (topoInfo.level0Shape == Level0Shape::MESH_2D) {
      52            0 :             primQueueGenName = "CcuAllGatherMesh2D";
      53            0 :         } else if (topoInfo.level0Shape == Level0Shape::MESH_1D_CLOS) {
      54            0 :             if (IsLayerAllConnetedWithTopo(topoInfo, 0, TopoType::MESH_1D)) {
      55              :                 // MESH_1D 即可链接所有卡, 使用 MESH_1D 算法
      56            0 :                 if ((detourType == HcclDetourType::HCCL_DETOUR_ENABLE_2P && rankSize_ == rankSize_2P)
      57            0 :                     || (detourType == HcclDetourType::HCCL_DETOUR_ENABLE_4P && rankSize_ == rankSize_4P)) {
      58            0 :                     primQueueGenName = "CcuAllGatherMeshDetour1D";
      59            0 :                 } else if (topoInfo.level0PcieMix) {
      60            0 :                     HCCL_WARNING("[Algo][AllGatherAutoSelector] level0 PCIE mix is not supported yet for ccu_ms mode.");
      61            0 :                     return SelectorStatus::NOT_MATCH;
      62              :                 } else {
      63            0 :                     primQueueGenName = "CcuAllGatherMesh1D";
      64              :                 }
      65              :             } else { // MS 不支持
      66            0 :                 HCCL_WARNING(
      67              :                     "[Algo][AllGatherAutoSelector] level0Shape[%d] is not supported yet for ccu_ms mode.",
      68              :                     topoInfo.level0Shape);
      69            0 :                 return SelectorStatus::NOT_MATCH;
      70              :             }
      71            0 :         } else if (topoInfo.level0Shape == Level0Shape::CLOS) {
      72            0 :             HCCL_WARNING(
      73              :                 "[Algo][AllGatherAutoSelector] level0Shape[%d] is not supported yet for ccu_ms mode.",
      74              :                 topoInfo.level0Shape);
      75            0 :             return SelectorStatus::NOT_MATCH;
      76              :         } else {
      77            0 :             HCCL_WARNING(
      78              :                 "[Algo][AllGatherAutoSelector] level0Shape[%d] is not supported yet for ccu_ms mode.",
      79              :                 topoInfo.level0Shape);
      80            0 :             return SelectorStatus::NOT_MATCH;
      81              :         }
      82              :     }
      83            0 :     HCCL_INFO("[Algo][AllGatherAutoSelector][%s] Algo match [%s]", __func__, primQueueGenName.c_str());
      84            0 :     return SelectorStatus::MATCH;
      85              : }
      86              : 
      87            0 : SelectorStatus AllGatherAutoSelector::SelectCcuScheduleAlgo(
      88              :     const TopoInfo& topoInfo, const CollAlgOperator& op,
      89              :     const std::map<OpType, std::vector<HcclAlgoType>>& configAlgMap, std::string& primQueueGenName) const
      90              : {
      91              :     (void)op;
      92              :     (void)configAlgMap;
      93            0 :     HCCL_DEBUG("[AllGatherAutoSelector][%s] start, topoInfo levelNum[%u]", __func__, topoInfo.levelNum);
      94              : 
      95            0 :     if (topoInfo.levelNum > 1) {
      96            0 :         if (topoInfo.level0Shape == Level0Shape::MESH_1D) {
      97            0 :             if (topoInfo.netLayerDetails.localNetInsSizeOfLayer[0] == 1) {
      98              :                 // 每框出 1 卡
      99            0 :                 primQueueGenName = "CcuAllGatherNHR1D";
     100            0 :             } else if (Is2DieFullMesh()) {
     101            0 :                 HCCL_WARNING("[Algo][AllGatherAutoSelector] 2DieFullMesh is not supported yet for schedule mode.");
     102            0 :                 return SelectorStatus::NOT_MATCH;
     103              :             } else {
     104            0 :                 primQueueGenName = "CcuAllGatherParallelMesh1DNHR";
     105              :             }
     106              :         } else {
     107            0 :             HCCL_WARNING(
     108              :                 "[Algo][AllGatherAutoSelector] level0Shape[%d] is not supported yet for ccu schedule mode.",
     109              :                 topoInfo.level0Shape);
     110            0 :             return SelectorStatus::NOT_MATCH;
     111              :         }
     112              :     } else {
     113            0 :         if (topoInfo.level0Shape == Level0Shape::MESH_1D) {
     114            0 :             if (Is2DieFullMesh()) {
     115            0 :                 HCCL_WARNING("[Algo][AllGatherAutoSelector] 2DieFullMesh is not supported yet for ccu schedule mode.");
     116            0 :                 return SelectorStatus::NOT_MATCH;
     117              :             } else {
     118            0 :                 primQueueGenName = "CcuAllGatherMeshMem2Mem1D";
     119              :             }
     120            0 :         } else if (topoInfo.level0Shape == Level0Shape::MESH_2D) {
     121            0 :             primQueueGenName = "CcuAllGatherMeshMem2Mem2D";
     122            0 :         } else if (topoInfo.level0Shape == Level0Shape::MESH_1D_CLOS) {
     123            0 :             if (IsLayerAllConnetedWithTopo(topoInfo, 0, TopoType::MESH_1D)) {
     124              :                 // MESH_1D 即可链接所有卡, 使用 MESH_1D 算法
     125            0 :                 primQueueGenName = "CcuAllGatherMeshMem2Mem1D";
     126            0 :             } else if (topoInfo.level0PcieMix) {
     127            0 :                 HCCL_WARNING(
     128              :                     "[Algo][AllGatherAutoSelector] level0 PCIE mix is not supported yet for ccu schedule mode.");
     129            0 :                 return SelectorStatus::NOT_MATCH;
     130              :             } else {
     131            0 :                 primQueueGenName = "CcuAllGatherParallelMesh1DNHR";
     132              :             }
     133            0 :         } else if (topoInfo.level0Shape == Level0Shape::CLOS) {
     134            0 :             HCCL_WARNING(
     135              :                 "[Algo][AllGatherAutoSelector] level0Shape[%d] is not supported yet for ccu schedule mode.",
     136              :                 topoInfo.level0Shape);
     137            0 :             return SelectorStatus::NOT_MATCH;
     138              :         } else {
     139            0 :             HCCL_WARNING(
     140              :                 "[Algo][AllGatherAutoSelector] level0Shape[%d] is not supported yet for ccu schedule mode.",
     141              :                 topoInfo.level0Shape);
     142            0 :             return SelectorStatus::NOT_MATCH;
     143              :         }
     144              :     }
     145            0 :     HCCL_INFO("[Algo][AllGatherAutoSelector][%s] Algo match [%s]", __func__, primQueueGenName.c_str());
     146            0 :     return SelectorStatus::MATCH;
     147              : }
     148              : 
     149            0 : SelectorStatus AllGatherAutoSelector::SelectAicpuAlgo(
     150              :     const TopoInfo& topoInfo, const CollAlgOperator& op,
     151              :     const std::map<OpType, std::vector<HcclAlgoType>>& configAlgMap, std::string& primQueueGenName) const
     152              : {
     153              :     (void)op;
     154              :     (void)configAlgMap;
     155            0 :     HCCL_DEBUG("[AllGatherAutoSelector][%s] start, topoInfo levelNum[%u]", __func__, topoInfo.levelNum);
     156              : 
     157            0 :     if (topoInfo.levelNum > 1) {
     158            0 :         if (topoInfo.Level1Nhr) {
     159            0 :             primQueueGenName = "InsAllGatherNHR";
     160            0 :         } else if (topoInfo.Level0Nhr) {
     161            0 :             primQueueGenName = "InsAllGatherParallelNHRNHR";
     162            0 :         } else if (topoInfo.level0Shape == Level0Shape::MESH_1D) {
     163            0 :             if (topoInfo.netLayerDetails.localNetInsSizeOfLayer[0] == 1) {
     164            0 :                 primQueueGenName = "InsAllGatherNHR";
     165              :             } else {
     166            0 :                 primQueueGenName = "InsAllGatherParallelMesh1DNHR";
     167              :             }
     168            0 :         } else if (topoInfo.level0Shape == Level0Shape::MESH_2D) {
     169            0 :             primQueueGenName = "InsAllGatherParallelMesh2DNHR";
     170            0 :         } else if (topoInfo.level0Shape == Level0Shape::CLOS) {
     171            0 :             primQueueGenName = "InsAllGatherParallelNHRNHR";
     172              :         } else {
     173            0 :             return SelectorStatus::NOT_MATCH;
     174              :         }
     175              :     } else {
     176            0 :         if (topoInfo.level0Shape == Level0Shape::MESH_1D) {
     177            0 :             primQueueGenName = "InsAllGatherMesh";
     178            0 :         } else if (topoInfo.level0Shape == Level0Shape::MESH_2D) {
     179            0 :             primQueueGenName = "InsAllGatherMesh2D";
     180            0 :         } else if (topoInfo.level0Shape == Level0Shape::MESH_1D_CLOS) {
     181            0 :             if (IsLayerAllConnetedWithTopo(topoInfo, 0, TopoType::MESH_1D)) {
     182              :                 // MESH_1D 即可链接所有卡, 使用 MESH_1D 算法
     183            0 :                 primQueueGenName = "InsAllGatherMesh";
     184            0 :             } else if (topoInfo.level0PcieMix) {
     185            0 :                 primQueueGenName = "InsAllGatherParallelMesh1DNHRPcie";
     186              :             } else {
     187            0 :                 primQueueGenName = "InsAllGatherParallelMesh1DNHR";
     188              :             }
     189            0 :         } else if (topoInfo.level0Shape == Level0Shape::CLOS) {
     190            0 :             primQueueGenName = "InsAllGatherNHR";
     191              :         } else {
     192            0 :             HCCL_WARNING("[AllGatherAutoSelector] topo not match");
     193            0 :             return SelectorStatus::NOT_MATCH;
     194              :         }
     195              :     }
     196            0 :     HCCL_INFO("[Algo][AllGatherAutoSelector][%s] Algo match [%s]", __func__, primQueueGenName.c_str());
     197            0 :     return SelectorStatus::MATCH;
     198              : }
     199              : 
     200            0 : SelectorStatus AllGatherAutoSelector::SelectAivAlgo(
     201              :     const TopoInfo& topoInfo, const CollAlgOperator& op,
     202              :     const std::map<OpType, std::vector<HcclAlgoType>>& configAlgMap, std::string& primQueueGenName) const
     203              : {
     204              :     (void)op;
     205              :     (void)configAlgMap;
     206            0 :     HCCL_DEBUG("[AllGatherAutoSelector][%s] start, topoInfo levelNum[%u]", __func__, topoInfo.levelNum);
     207              : 
     208              :     // aiv 直接走打平 mesh
     209            0 :     primQueueGenName = "AivAllGatherMesh1D";
     210              : 
     211            0 :     HCCL_INFO("[Algo][AllGatherAutoSelector][%s] Algo match [%s]", __func__, primQueueGenName.c_str());
     212            0 :     return SelectorStatus::MATCH;
     213              : }
     214              : 
     215              : REGISTER_SELECTOR_BY_OPTYPE(OpType::ALLGATHER, 18, AllGatherAutoSelector);
     216              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1