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