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