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 EID_INFO_MGR_H
12 : #define EID_INFO_MGR_H
13 :
14 : #include <mutex>
15 : #include <unordered_map>
16 :
17 : #include "hccl_res.h"
18 : #include "hccl_types.h"
19 : #include "hcomm_adapter_hccp.h"
20 :
21 : // 暂时使用orion ipaddr
22 : #include "ip_address.h"
23 :
24 : namespace hcomm {
25 :
26 : class EidInfoMgr {
27 : public:
28 : static EidInfoMgr& GetInstance(const uint32_t devicePhyId);
29 : HcclResult GetEidInfos(std::vector<DevEidInfo>& eidInfos);
30 : HcclResult GetEidInfoByAddr(const CommAddr& commAddr, DevEidInfo& eidInfo);
31 :
32 : private:
33 132 : explicit EidInfoMgr() = default;
34 132 : ~EidInfoMgr() = default;
35 : EidInfoMgr(const EidInfoMgr& that) = delete;
36 : EidInfoMgr& operator=(const EidInfoMgr& that) = delete;
37 :
38 : HcclResult Init();
39 :
40 : private:
41 : uint32_t devPhyId_{0};
42 : bool initflag_{false};
43 : std::mutex innerMutex_{};
44 :
45 : std::vector<DevEidInfo> eidInfos_{};
46 : std::unordered_map<Hccl::IpAddress, DevEidInfo> eidInfoMap_{};
47 : };
48 :
49 : }; // namespace hcomm
50 :
51 : #endif // EID_INFO_MGR_H
|