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 : #ifndef ENDPOINT_PAIR_MGR_H
11 : #define ENDPOINT_PAIR_MGR_H
12 :
13 : #include <cstddef>
14 : #include <cstdint>
15 : #include <cstring>
16 : #include <unordered_map>
17 : #include <mutex>
18 : #include "endpoint_pair.h"
19 :
20 : namespace hcomm {
21 :
22 : using EpChannelMap = std::unordered_map<EndpointDescPair, std::unordered_map<CommEngine, std::vector<ChannelHandle>>>;
23 : class EndpointPairMgr {
24 : public:
25 10 : EndpointPairMgr() {};
26 :
27 10 : ~EndpointPairMgr() = default;
28 :
29 : HcclResult Get(const EndpointDescPair &endpointDescPair, EndpointPair *&out,
30 : const Hccl::RankIpPortMapPtr& rankIpPortMap);
31 : EpChannelMap GetEpChannelMap();
32 :
33 : private:
34 : std::unordered_map<EndpointDescPair, std::unique_ptr<EndpointPair>> endpointPairMap_{};
35 : };
36 :
37 : } // namespace hcomm
38 :
39 : #endif // ENDPOINT_PAIR_MGR_H
|