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