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 HCCL_FLUSH_HANDLE_H
11 : #define HCCL_FLUSH_HANDLE_H
12 :
13 : #include <string>
14 :
15 : #include "hccp_common.h"
16 : #include "hccl_types.h"
17 : #include "rdma_handle_manager.h"
18 :
19 : namespace Hccl {
20 : constexpr u64 FLUSH_BUFFER_SIZE = 8; // 每次读取8字节
21 : class FlushHandle {
22 : public:
23 : FlushHandle();
24 : ~FlushHandle();
25 :
26 : // 初始化 handle
27 : HcclResult Init(IpAddress ip, u32 devPhyId);
28 :
29 : // 销毁 handle
30 : HcclResult Destroy();
31 :
32 : // 成员变量
33 : MrInfoT loopBackQpMrRemoteInfo = {};
34 : MrInfoT loopBackQpMrLocalInfo = {};
35 : LoopbackQpPair loopBackQpParam = {};
36 :
37 2 : bool GetFlushOpcodeSupport() const
38 : {
39 2 : return flushOpcodeSupport_;
40 : }
41 :
42 3 : void SetFlushOpcodeSupport() {
43 3 : flushOpcodeSupport_ = true;
44 3 : }
45 :
46 : private:
47 : bool flushOpcodeSupport_{false};
48 : bool flushIsInitialized{false};
49 : void* localMem{nullptr};
50 : void* deviceMem{nullptr};
51 : MrHandle localMrHandle{nullptr};
52 : MrHandle remoteMrHandle{nullptr};
53 : QpHandle qpHandle{nullptr};
54 : RdmaHandle rdmaHandle{nullptr};
55 :
56 : // 初始化方法
57 : HcclResult GetRdmaHandle(IpAddress ip, u32 devPhyId, void **rdmaHandle) const;
58 : HcclResult GetLbMax(int *lbMax) const;
59 : HcclResult AllocateDeviceMemory();
60 : HcclResult AllocateLocalMemory();
61 : HcclResult CreateLoopbackQp();
62 : HcclResult RegisterLocalMr();
63 : HcclResult RegisterRemoteMr();
64 :
65 : // 销毁方法
66 : HcclResult DeregisterMr(MrHandle &mrHandle, std::string logTag) const;
67 : HcclResult DestroyLoopbackQp();
68 : HcclResult FreeLocalMemory();
69 : HcclResult FreeDeviceMemory();
70 : };
71 :
72 : } // namespace Hccl
73 :
74 : #endif
|