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(
26 : const HcclNetDevCtx netDevCtx, void* addr, u64 size, const RmaMemType memType,
27 : const LocalRdmaRmaBufferImpl& parent);
28 :
29 : ~LocalRdmaRmaBufferImpl() override;
30 :
31 : LocalRdmaRmaBufferImpl(const LocalRdmaRmaBufferImpl& that) = delete;
32 : LocalRdmaRmaBufferImpl& operator=(const LocalRdmaRmaBufferImpl& that) = delete;
33 :
34 : HcclResult Init();
35 : HcclResult Destroy();
36 :
37 : std::string& Serialize();
38 : HcclResult Remap(void* addr, u64 length);
39 :
40 12 : inline u32 GetKey() const { return lkey; }
41 :
42 : private:
43 : s32 deviceLogicId{-1};
44 : RdmaHandle rdmaHandle{nullptr};
45 : MrHandle mrHandle{nullptr};
46 : u32 lkey{0};
47 : std::string devAddrID{""};
48 : bool initialized_ = false;
49 : std::string serializeStr_;
50 : };
51 : } // namespace hccl
52 : #endif // LOCAL_RDMA_RMA_BUFFER_IMPL_H
|