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