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