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 { return flushOpcodeSupport_; }
38 :
39 3 : void SetFlushOpcodeSupport() { flushOpcodeSupport_ = true; }
40 :
41 : private:
42 : bool flushOpcodeSupport_{false};
43 : bool flushIsInitialized{false};
44 : void* localMem{nullptr};
45 : void* deviceMem{nullptr};
46 : MrHandle localMrHandle{nullptr};
47 : MrHandle remoteMrHandle{nullptr};
48 : QpHandle qpHandle{nullptr};
49 : RdmaHandle rdmaHandle{nullptr};
50 :
51 : // 初始化方法
52 : HcclResult GetRdmaHandle(IpAddress ip, u32 devPhyId, void** rdmaHandle) const;
53 : HcclResult GetLbMax(int* lbMax) const;
54 : HcclResult AllocateDeviceMemory();
55 : HcclResult AllocateLocalMemory();
56 : HcclResult CreateLoopbackQp();
57 : HcclResult RegisterLocalMr();
58 : HcclResult RegisterRemoteMr();
59 :
60 : // 销毁方法
61 : HcclResult DeregisterMr(MrHandle& mrHandle, std::string logTag) const;
62 : HcclResult DestroyLoopbackQp();
63 : HcclResult FreeLocalMemory();
64 : HcclResult FreeDeviceMemory();
65 : };
66 :
67 : } // namespace Hccl
68 :
69 : #endif
|