LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/selector - scatter_auto_selector.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 73 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 "scatter_auto_selector.h"
      12              : #include "selector_registry.h"
      13              : #include "coll_operator.h"
      14              : 
      15              : namespace Hccl {
      16            0 : SelectorStatus ScatterAutoSelector::SelectCcuMsAlgo(
      17              :     const TopoInfo& topoInfo, const CollAlgOperator& op,
      18              :     const std::map<OpType, std::vector<HcclAlgoType>>& configAlgMap, std::string& primQueueGenName) const
      19              : {
      20              :     (void)topoInfo;
      21              :     (void)op;
      22              :     (void)configAlgMap;
      23              :     (void)primQueueGenName;
      24            0 :     HCCL_WARNING("[Algo][ScatterAutoSelector] not supported yet for ccu_ms mode, reset to default.");
      25            0 :     return SelectorStatus::NOT_MATCH;
      26              : }
      27              : 
      28            0 : SelectorStatus ScatterAutoSelector::SelectCcuScheduleAlgo(
      29              :     const TopoInfo& topoInfo, const CollAlgOperator& op,
      30              :     const std::map<OpType, std::vector<HcclAlgoType>>& configAlgMap, std::string& primQueueGenName) const
      31              : {
      32              :     (void)op;
      33              :     (void)configAlgMap;
      34            0 :     HCCL_DEBUG("[ScatterAutoSelector][%s] start, topoInfo levelNum[%u]", __func__, topoInfo.levelNum);
      35              : 
      36            0 :     if (topoInfo.levelNum > 1) {
      37            0 :         if (topoInfo.level0Shape == Level0Shape::MESH_1D) {
      38            0 :             if (topoInfo.netLayerDetails.localNetInsSizeOfLayer[0] == 1) {
      39              :                 // 每框出 1 卡
      40            0 :                 primQueueGenName = "CcuScatterNHRMem2Mem1D";
      41            0 :             } else if (Is2DieFullMesh()) {
      42            0 :                 HCCL_WARNING("[Algo][ScatterAutoSelector] 2DieFullMesh is not supported yet for schedule mode.");
      43            0 :                 return SelectorStatus::NOT_MATCH;
      44              :             } else {
      45            0 :                 primQueueGenName = "CcuScatterParallelMesh1DNHR";
      46              :             }
      47              :         } else {
      48            0 :             HCCL_WARNING(
      49              :                 "[Algo][ScatterAutoSelector] level0Shape[%d] is not supported yet for ccu schedule mode.",
      50              :                 topoInfo.level0Shape);
      51            0 :             return SelectorStatus::NOT_MATCH;
      52              :         }
      53              :     } else {
      54            0 :         if (topoInfo.level0Shape == Level0Shape::MESH_1D) {
      55            0 :             if (Is2DieFullMesh()) {
      56            0 :                 HCCL_WARNING("[Algo][ScatterAutoSelector] 2DieFullMesh is not supported yet for ccu schedule mode.");
      57            0 :                 return SelectorStatus::NOT_MATCH;
      58              :             } else {
      59            0 :                 primQueueGenName = "CcuScatterMesh1D";
      60              :             }
      61            0 :         } else if (topoInfo.level0Shape == Level0Shape::MESH_2D) {
      62            0 :             primQueueGenName = "CcuScatterMesh2D";
      63            0 :         } else if (topoInfo.level0Shape == Level0Shape::MESH_1D_CLOS) {
      64            0 :             if (IsLayerAllConnetedWithTopo(topoInfo, 0, TopoType::MESH_1D)) {
      65              :                 // MESH_1D 即可链接所有卡, 使用 MESH_1D 算法
      66            0 :                 primQueueGenName = "CcuScatterMesh1D";
      67            0 :             } else if (topoInfo.level0PcieMix) {
      68            0 :                 HCCL_WARNING("[Algo][ScatterAutoSelector] level0 PCIE mix is not supported yet for ccu schedule mode.");
      69            0 :                 return SelectorStatus::NOT_MATCH;
      70              :             } else {
      71            0 :                 primQueueGenName = "CcuAllGatherParallelMesh1DNHR";
      72              :             }
      73            0 :         } else if (topoInfo.level0Shape == Level0Shape::CLOS) {
      74            0 :             HCCL_WARNING(
      75              :                 "[Algo][ScatterAutoSelector] level0Shape[%d] is not supported yet for ccu schedule mode.",
      76              :                 topoInfo.level0Shape);
      77            0 :             return SelectorStatus::NOT_MATCH;
      78              :         } else {
      79            0 :             HCCL_WARNING(
      80              :                 "[Algo][ScatterAutoSelector] level0Shape[%d] is not supported yet for ccu schedule mode.",
      81              :                 topoInfo.level0Shape);
      82            0 :             return SelectorStatus::NOT_MATCH;
      83              :         }
      84              :     }
      85            0 :     HCCL_INFO("[Algo][ScatterAutoSelector][%s] Algo match [%s]", __func__, primQueueGenName.c_str());
      86            0 :     return SelectorStatus::MATCH;
      87              : }
      88              : 
      89            0 : SelectorStatus ScatterAutoSelector::SelectAicpuAlgo(
      90              :     const TopoInfo& topoInfo, const CollAlgOperator& op,
      91              :     const std::map<OpType, std::vector<HcclAlgoType>>& configAlgMap, std::string& primQueueGenName) const
      92              : {
      93              :     (void)op;
      94              :     (void)configAlgMap;
      95            0 :     HCCL_DEBUG("[ScatterAutoSelector][%s] start, topoInfo levelNum[%u]", __func__, topoInfo.levelNum);
      96              : 
      97            0 :     if (topoInfo.levelNum > 1) {
      98            0 :         if (topoInfo.level0Shape == Level0Shape::MESH_1D) {
      99            0 :             if (topoInfo.netLayerDetails.localNetInsSizeOfLayer[0] == 1) {
     100            0 :                 primQueueGenName = "InsScatterNHR";
     101              :             } else {
     102            0 :                 primQueueGenName = "InsScatterParallelMesh1DNHR";
     103              :             }
     104            0 :         } else if (topoInfo.level0Shape == Level0Shape::MESH_2D) {
     105            0 :             HCCL_WARNING(
     106              :                 "[Algo][ScatterAutoSelector] level0Shape[%d] is not supported yet for aicpu levelNum > 1.",
     107              :                 topoInfo.level0Shape);
     108            0 :             return SelectorStatus::NOT_MATCH;
     109            0 :         } else if (topoInfo.level0Shape == Level0Shape::CLOS) {
     110            0 :             HCCL_WARNING(
     111              :                 "[Algo][ScatterAutoSelector] level0Shape[%d] is not supported yet for aicpu levelNum > 1.",
     112              :                 topoInfo.level0Shape);
     113            0 :             return SelectorStatus::NOT_MATCH;
     114              :         } else {
     115            0 :             return SelectorStatus::NOT_MATCH;
     116              :         }
     117              :     } else {
     118            0 :         if (topoInfo.level0Shape == Level0Shape::MESH_1D) {
     119            0 :             primQueueGenName = "InsScatterMesh1D";
     120            0 :         } else if (topoInfo.level0Shape == Level0Shape::MESH_2D) {
     121            0 :             primQueueGenName = "InsScatterMesh2D";
     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 = "InsScatterMesh1D";
     126              :             } else {
     127            0 :                 if (topoInfo.level0PcieMix) {
     128              :                     // 预留PCIE mix入口,如果要更新算法可以直接改
     129            0 :                     primQueueGenName = "InsScatterParallelMesh1DNHRPcie";
     130              :                 }
     131            0 :                 primQueueGenName = "InsScatterMesh1D";
     132              :             }
     133            0 :         } else if (topoInfo.level0Shape == Level0Shape::CLOS) {
     134            0 :             if (topoInfo.level0PcieMix) {
     135            0 :                 primQueueGenName = "InsScatterNHR";
     136              :             } else {
     137            0 :                 primQueueGenName = "InsScatterMesh1D";
     138              :             }
     139              :         } else {
     140            0 :             HCCL_WARNING("[ScatterAutoSelector] topo not match");
     141            0 :             return SelectorStatus::NOT_MATCH;
     142              :         }
     143              :     }
     144            0 :     HCCL_INFO("[Algo][ScatterAutoSelector][%s] Algo match [%s]", __func__, primQueueGenName.c_str());
     145            0 :     return SelectorStatus::MATCH;
     146              : }
     147              : 
     148            0 : SelectorStatus ScatterAutoSelector::SelectAivAlgo(
     149              :     const TopoInfo& topoInfo, const CollAlgOperator& op,
     150              :     const std::map<OpType, std::vector<HcclAlgoType>>& configAlgMap, std::string& primQueueGenName) const
     151              : {
     152              :     (void)op;
     153              :     (void)configAlgMap;
     154            0 :     HCCL_DEBUG("[ScatterAutoSelector][%s] start, topoInfo levelNum[%u]", __func__, topoInfo.levelNum);
     155              : 
     156              :     // aiv 直接走打平 mesh
     157            0 :     primQueueGenName = "AivScatterMesh1D";
     158              : 
     159            0 :     HCCL_INFO("[Algo][ScatterAutoSelector][%s] Algo match [%s]", __func__, primQueueGenName.c_str());
     160            0 :     return SelectorStatus::MATCH;
     161              : }
     162              : 
     163              : REGISTER_SELECTOR_BY_OPTYPE(OpType::SCATTER, 18, ScatterAutoSelector);
     164              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1