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_H
12 : #define LOCAL_RDMA_RMA_BUFFER_H
13 :
14 : #include <memory>
15 : #include <string>
16 : #include "hccl_common.h"
17 : #include "hccl_network_pub.h"
18 : #include "rma_buffer.h"
19 :
20 : namespace hccl {
21 : class LocalRdmaRmaBufferImpl;
22 :
23 : class LocalRdmaRmaBuffer : public RmaBuffer {
24 : public:
25 : LocalRdmaRmaBuffer(const HcclNetDevCtx netDevCtx, void* addr, u64 size,
26 : const RmaMemType memType = RmaMemType::DEVICE);
27 :
28 : // 别名构造函数:共享父buffer的RDMA注册资源
29 : LocalRdmaRmaBuffer(const HcclNetDevCtx netDevCtx, void* addr, u64 size,
30 : const RmaMemType memType, const LocalRdmaRmaBuffer& parent);
31 :
32 : HcclResult Init();
33 : HcclResult Destroy();
34 : ~LocalRdmaRmaBuffer() override;
35 :
36 : LocalRdmaRmaBuffer(const LocalRdmaRmaBuffer &that) = delete;
37 : LocalRdmaRmaBuffer &operator=(const LocalRdmaRmaBuffer &that) = delete;
38 :
39 : // Init成功后调用Serialize和获取属性接口
40 : std::string &Serialize();
41 :
42 : u32 GetKey() const;
43 : HcclResult Remap(void* addr, u64 length);
44 :
45 : private:
46 2 : const LocalRdmaRmaBufferImpl& GetImpl() const { return *pimpl_; }
47 : std::unique_ptr<LocalRdmaRmaBufferImpl> pimpl_;
48 : };
49 : }
50 : #endif // LOCAL_RDMA_RMA_BUFFER_H
|