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