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 : #ifndef HCCL_OPRETRY_LINK_MANAGE_H
12 : #define HCCL_OPRETRY_LINK_MANAGE_H
13 :
14 : #include <string>
15 : #include <unordered_map>
16 : #include <unordered_set>
17 : #include <vector>
18 : #include <mutex>
19 :
20 : #include "hccl/hccl_types.h"
21 : #include "hccl_common.h"
22 : #include "log.h"
23 : #include "aicpu_operator_pub.h"
24 :
25 : namespace hccl {
26 :
27 : constexpr u32 MAX_DEV_NUM = 16;
28 :
29 : class OpretryLinkManage {
30 : public:
31 : static OpretryLinkManage& GetInstance(s32 deviceLogicID);
32 :
33 : HcclResult AddLinkInfoByIdentifier(
34 : const std::string& identifier, const std::string& newTag, std::vector<u32>& remoteRankList, bool incre);
35 : HcclResult
36 : GetLinkInfoByIdentifier(const std::string& identifier, const std::string& newTag, std::vector<u32>& remoteRankList);
37 : HcclResult GetLinkInfoByIdentifier(const std::string& identifier, std::vector<u32>& remoteRankList);
38 : HcclResult DeleteLinkInfoByIdentifier(const std::string& identifier);
39 :
40 : private:
41 16 : OpretryLinkManage() = default;
42 : ~OpretryLinkManage();
43 :
44 : // 维护算子粒度的所有使用RDMA建链的对端rank
45 : std::unordered_map<std::string, std::unordered_map<std::string, std::vector<u32>>> allRemoteRankList_;
46 : // 维护通信域粒度的所有使用RDMA建链的对端rank
47 : std::unordered_map<std::string, std::unordered_set<u32>> groupAllRemoteRankList_;
48 :
49 : std::mutex opretryLinkMutex_;
50 : bool isDeInit_ = false;
51 : };
52 :
53 : } // namespace hccl
54 : #endif // HCCL_OPRETRY_RPING_H
|