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 "send_recv_auto_selector.h"
12 : #include "selector_registry.h"
13 : #include "coll_operator.h"
14 :
15 : namespace Hccl {
16 :
17 0 : SelectorStatus SendRecvAutoSelector::SelectAicpuAlgo(const TopoInfo &topoInfo,
18 : const CollAlgOperator &op,
19 : const std::map<OpType, std::vector<HcclAlgoType>> &configAlgMap,
20 : std::string &primQueueGenName) const
21 : {
22 : (void) topoInfo;
23 0 : std::vector<HcclAlgoType> algos = std::vector<HcclAlgoType>(HCCL_ALGO_LEVEL_NUM, HcclAlgoType::HCCL_ALGO_TYPE_DEFAULT);
24 0 : auto it = configAlgMap.find(op.opType);
25 0 : if (it != configAlgMap.end()) {
26 0 : algos = it->second;
27 : }
28 :
29 0 : HCCL_INFO("hccl algo op config: config opType:%s, level0:%u, level1:%u, level2:%u, level3:%u",
30 : op.opType.Describe().c_str(), algos[0], algos[1], algos[2], algos[3]);
31 :
32 0 : if(op.opType == OpType::SEND) {
33 0 : primQueueGenName = "InsSend";
34 0 : return SelectorStatus::MATCH;
35 0 : } else if (op.opType == OpType::RECV){
36 0 : primQueueGenName = "InsRecv";
37 0 : return SelectorStatus::MATCH;
38 : }
39 0 : return SelectorStatus::NOT_MATCH;
40 0 : }
41 :
42 0 : SelectorStatus SendRecvAutoSelector::SelectAivAlgo(const TopoInfo &topoInfo, const CollAlgOperator &op,
43 : const std::map<OpType, std::vector<HcclAlgoType>> &configAlgMap, std::string &primQueueGenName) const
44 : {
45 : (void) topoInfo;
46 0 : std::vector<HcclAlgoType> algos = std::vector<HcclAlgoType>(HCCL_ALGO_LEVEL_NUM, HcclAlgoType::HCCL_ALGO_TYPE_DEFAULT);
47 0 : auto it = configAlgMap.find(op.opType);
48 0 : if (it != configAlgMap.end()) {
49 0 : algos = it->second;
50 : }
51 :
52 0 : HCCL_INFO("[SendRecvAutoSelector] select AIV algo for Send/Recv");
53 :
54 0 : if(op.opType == OpType::SEND) {
55 0 : primQueueGenName = "AivSend";
56 0 : return SelectorStatus::MATCH;
57 0 : } else if (op.opType == OpType::RECV){
58 0 : primQueueGenName = "AivRecv";
59 0 : return SelectorStatus::MATCH;
60 : }
61 0 : return SelectorStatus::NOT_MATCH;
62 0 : }
63 :
64 : REGISTER_SELECTOR_BY_OPTYPE(OpType::SEND, 18, SendRecvAutoSelector);
65 : REGISTER_SELECTOR_BY_OPTYPE(OpType::RECV, 18, SendRecvAutoSelector);
66 : } // namespace Hccl
|