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_v_auto_selector.h"
12 : #include "selector_registry.h"
13 : #include "coll_operator.h"
14 :
15 : namespace Hccl {
16 0 : SelectorStatus AllGatherVAutoSelector::SelectCcuMsAlgo(const TopoInfo &topoInfo, const CollAlgOperator &op,
17 : const std::map<OpType, std::vector<HcclAlgoType>> &configAlgMap, std::string &primQueueGenName) const
18 : {
19 : (void)op;
20 : (void)configAlgMap;
21 0 : HCCL_DEBUG("[AllGatherVAutoSelector][%s] start, topoInfo levelNum[%u]", __func__, topoInfo.levelNum);
22 0 : if (topoInfo.levelNum > 1) {
23 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] levelNum > 1 is not supported yet for ccu_ms mode.");
24 0 : return SelectorStatus::NOT_MATCH;
25 : } else {
26 0 : if (topoInfo.level0Shape == Level0Shape::MESH_1D) {
27 0 : if (Is2DieFullMesh()) {
28 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] 2DieFullMesh[%d] is not supported yet for ccu_ms mode.",
29 : topoInfo.level0Shape);
30 0 : return SelectorStatus::NOT_MATCH;
31 : } else {
32 0 : primQueueGenName = "CcuAllGatherVMesh1D";
33 : }
34 0 : } else if (topoInfo.level0Shape == Level0Shape::MESH_2D) {
35 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] level0Shape[%d] is not supported yet for ccu_ms mode.",
36 : topoInfo.level0Shape);
37 0 : return SelectorStatus::NOT_MATCH;
38 0 : } else if (topoInfo.level0Shape == Level0Shape::MESH_1D_CLOS) {
39 0 : if (IsLayerAllConnetedWithTopo(topoInfo, 0, TopoType::MESH_1D)) {
40 : // MESH_1D 即可链接所有卡, 使用 MESH_1D 算法
41 0 : primQueueGenName = "CcuAllGatherVMesh1D";
42 0 : } else if (topoInfo.level0PcieMix) {
43 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] level0 PCIE mix is not supported yet for ccu_ms mode.");
44 0 : return SelectorStatus::NOT_MATCH;
45 : } else { // MS 不支持
46 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] level0Shape[%d] is not supported yet for ccu_ms mode.",
47 : topoInfo.level0Shape);
48 0 : return SelectorStatus::NOT_MATCH;
49 : }
50 0 : } else if (topoInfo.level0Shape == Level0Shape::CLOS) {
51 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] level0Shape[%d] is not supported yet for ccu_ms mode.",
52 : topoInfo.level0Shape);
53 0 : return SelectorStatus::NOT_MATCH;
54 : } else {
55 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] level0Shape[%d] is not supported yet for ccu_ms mode.",
56 : topoInfo.level0Shape);
57 0 : return SelectorStatus::NOT_MATCH;
58 : }
59 : }
60 0 : HCCL_INFO("[Algo][AllGatherVAutoSelector][%s] Algo match [%s]", __func__, primQueueGenName.c_str());
61 0 : return SelectorStatus::MATCH;
62 : }
63 :
64 0 : SelectorStatus AllGatherVAutoSelector::SelectCcuScheduleAlgo(const TopoInfo &topoInfo, const CollAlgOperator &op,
65 : const std::map<OpType, std::vector<HcclAlgoType>> &configAlgMap, std::string &primQueueGenName) const
66 : {
67 : (void)op;
68 : (void)configAlgMap;
69 0 : HCCL_DEBUG("[AllGatherVAutoSelector][%s] start, topoInfo levelNum[%u]", __func__, topoInfo.levelNum);
70 :
71 0 : if (topoInfo.levelNum > 1) {
72 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] levelNum > 1 is not supported yet for ccu_schedule mode.");
73 0 : return SelectorStatus::NOT_MATCH;
74 : } else {
75 0 : if (topoInfo.level0Shape == Level0Shape::MESH_1D) {
76 0 : if (Is2DieFullMesh()) {
77 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] 2DieFullMesh is not supported yet for ccu schedule mode.");
78 0 : return SelectorStatus::NOT_MATCH;
79 : } else {
80 0 : primQueueGenName = "CcuAllGatherVMesh1D";
81 : }
82 0 : } else if (topoInfo.level0Shape == Level0Shape::MESH_2D) {
83 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] level0Shape[%d] is not supported yet for ccu schedule mode.",
84 : topoInfo.level0Shape);
85 0 : return SelectorStatus::NOT_MATCH;
86 0 : } else if (topoInfo.level0Shape == Level0Shape::MESH_1D_CLOS) {
87 0 : if (IsLayerAllConnetedWithTopo(topoInfo, 0, TopoType::MESH_1D)) {
88 : // MESH_1D 即可链接所有卡, 使用 MESH_1D 算法
89 0 : primQueueGenName = "CcuAllGatherVMesh1D";
90 0 : } else if (topoInfo.level0PcieMix) {
91 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] level0 PCIE mix is not supported yet for ccu_ms mode.");
92 0 : return SelectorStatus::NOT_MATCH;
93 : } else {
94 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] level0Shape[%d] is not supported yet for ccu schedule mode.",
95 : topoInfo.level0Shape);
96 0 : return SelectorStatus::NOT_MATCH;
97 : }
98 0 : } else if (topoInfo.level0Shape == Level0Shape::CLOS) {
99 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] level0Shape[%d] is not supported yet for ccu schedule mode.",
100 : topoInfo.level0Shape);
101 0 : return SelectorStatus::NOT_MATCH;
102 : } else {
103 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] level0Shape[%d] is not supported yet for ccu schedule mode.",
104 : topoInfo.level0Shape);
105 0 : return SelectorStatus::NOT_MATCH;
106 : }
107 : }
108 0 : HCCL_INFO("[Algo][AllGatherVAutoSelector][%s] Algo match [%s]", __func__, primQueueGenName.c_str());
109 0 : return SelectorStatus::MATCH;
110 : }
111 :
112 0 : SelectorStatus AllGatherVAutoSelector::SelectAicpuAlgo(const TopoInfo &topoInfo, const CollAlgOperator &op,
113 : const std::map<OpType, std::vector<HcclAlgoType>> &configAlgMap, std::string &primQueueGenName) const
114 : {
115 : (void)topoInfo;
116 : (void)op;
117 : (void)configAlgMap;
118 : (void)primQueueGenName;
119 :
120 : // 暂时没有 aicpu 算法
121 0 : HCCL_WARNING("[Algo][AllGatherVAutoSelector] No aicpu algorithm for aicpu mode. Auto select failed.");
122 0 : return SelectorStatus::NOT_MATCH;
123 : }
124 :
125 : REGISTER_SELECTOR_BY_OPTYPE(OpType::ALLGATHERV, 18, AllGatherVAutoSelector);
126 : } // namespace Hccl
|