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 MEM_TRANSPORT_LITE_MANAGER_H
12 : #define MEM_TRANSPORT_LITE_MANAGER_H
13 :
14 : #include <vector>
15 : #include "types.h"
16 : #include "virtual_topo.h"
17 : #include "mem_transport_lite.h"
18 : #include "mirror_task_manager_lite.h"
19 : #include "mem_transport_callback_lite.h"
20 :
21 : namespace Hccl {
22 :
23 : class MemTransportLiteMgr {
24 : public:
25 132 : explicit MemTransportLiteMgr(MirrorTaskManagerLite* mirrorTaskMgrLite) : mirrorTaskMgrLite_(mirrorTaskMgrLite) {}
26 :
27 : MemTransportLite* GetOpbase(const LinkData& linkData);
28 :
29 : MemTransportLite* GetOffload(const std::string& opTag, const LinkData& linkData);
30 :
31 : void Reset();
32 :
33 : void ParseOpbasePackedData(std::vector<char>& data);
34 : void ParseOpbaseAllPackedData(BinaryStream& binaryStream);
35 : void ParseOffloadPackedData(const std::string& opTag, std::vector<char>& data);
36 : void ParseOffloadAllPackedData(BinaryStream& binaryStream);
37 :
38 : void ParseAllPackedData(std::vector<char>& data);
39 :
40 : private:
41 : MirrorTaskManagerLite* mirrorTaskMgrLite_{nullptr};
42 : bool IsOpbaseExist(const LinkData& linkData);
43 :
44 : using MemTransportLiteMap = std::unordered_map<LinkData, std::unique_ptr<MemTransportLite>, hash<Hccl::LinkData>>;
45 :
46 : MemTransportLiteMap opBaseTranspMap;
47 :
48 : using OffloadTransportLiteMap = std::unordered_map<
49 : std::string, std::unordered_map<LinkData, std::unique_ptr<MemTransportLite>, hash<Hccl::LinkData>>>;
50 :
51 : OffloadTransportLiteMap offloadTranspMap;
52 : };
53 : } // namespace Hccl
54 : #endif
|