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 128 : explicit MemTransportLiteMgr(MirrorTaskManagerLite *mirrorTaskMgrLite) : mirrorTaskMgrLite_(mirrorTaskMgrLite)
25 : {
26 128 : }
27 :
28 : MemTransportLite *GetOpbase(const LinkData &linkData);
29 :
30 : MemTransportLite *GetOffload(const std::string &opTag, const LinkData &linkData);
31 :
32 : void Reset();
33 :
34 : void ParseOpbasePackedData(std::vector<char> &data);
35 : void ParseOpbaseAllPackedData(BinaryStream &binaryStream);
36 : void ParseOffloadPackedData(const std::string &opTag, std::vector<char> &data);
37 : void ParseOffloadAllPackedData(BinaryStream &binaryStream);
38 :
39 : void ParseAllPackedData(std::vector<char> &data);
40 :
41 : private:
42 : MirrorTaskManagerLite *mirrorTaskMgrLite_ {nullptr};
43 : bool IsOpbaseExist(const LinkData &linkData);
44 :
45 : using MemTransportLiteMap = std::unordered_map<LinkData, std::unique_ptr<MemTransportLite>, hash<Hccl::LinkData>>;
46 :
47 : MemTransportLiteMap opBaseTranspMap;
48 :
49 : using OffloadTransportLiteMap
50 : = std::unordered_map<std::string, std::unordered_map<LinkData, std::unique_ptr<MemTransportLite>, hash<Hccl::LinkData>>>;
51 :
52 : OffloadTransportLiteMap offloadTranspMap;
53 : };
54 : } // namespace Hccl
55 : #endif
|