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 LOCAL_RDMA_RMA_BUFFER_IMPL_H
12 : #define LOCAL_RDMA_RMA_BUFFER_IMPL_H
13 :
14 : #include "hccl_common.h"
15 : #include "hccl_network_pub.h"
16 : #include "rma_buffer.h"
17 : #include "mem_name_repository_pub.h"
18 :
19 : namespace hccl {
20 : class LocalRdmaRmaBufferImpl : public RmaBuffer {
21 : public:
22 : LocalRdmaRmaBufferImpl(const HcclNetDevCtx netDevCtx, void* addr, u64 size, const RmaMemType memType);
23 :
24 : // 别名构造函数:共享父buffer的RDMA注册资源,不调用hrtRaRegGlobalMr
25 : LocalRdmaRmaBufferImpl(const HcclNetDevCtx netDevCtx, void* addr, u64 size, const RmaMemType memType,
26 : const LocalRdmaRmaBufferImpl& parent);
27 :
28 : ~LocalRdmaRmaBufferImpl() override;
29 :
30 : LocalRdmaRmaBufferImpl(const LocalRdmaRmaBufferImpl &that) = delete;
31 : LocalRdmaRmaBufferImpl &operator=(const LocalRdmaRmaBufferImpl &that) = delete;
32 :
33 : HcclResult Init();
34 : HcclResult Destroy();
35 :
36 : std::string &Serialize();
37 : HcclResult Remap(void* addr, u64 length);
38 :
39 12 : inline u32 GetKey() const
40 : {
41 12 : return lkey;
42 : }
43 :
44 : private:
45 : s32 deviceLogicId{-1};
46 : RdmaHandle rdmaHandle{nullptr};
47 : MrHandle mrHandle{nullptr};
48 : u32 lkey{0};
49 : std::string devAddrID{""};
50 : bool initialized_ = false;
51 : std::string serializeStr_;
52 : };
53 : }
54 : #endif // LOCAL_RDMA_RMA_BUFFER_IMPL_H
|