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

Generated by: LCOV version 2.0-1