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(
26 : const HcclNetDevCtx netDevCtx, void* addr, u64 size, const RmaMemType memType = RmaMemType::DEVICE);
27 :
28 : // 别名构造函数:共享父buffer的RDMA注册资源
29 : LocalRdmaRmaBuffer(
30 : const HcclNetDevCtx netDevCtx, void* addr, u64 size, const RmaMemType memType,
31 : const LocalRdmaRmaBuffer& parent);
32 :
33 : HcclResult Init();
34 : HcclResult Destroy();
35 : ~LocalRdmaRmaBuffer() override;
36 :
37 : LocalRdmaRmaBuffer(const LocalRdmaRmaBuffer& that) = delete;
38 : LocalRdmaRmaBuffer& operator=(const LocalRdmaRmaBuffer& that) = delete;
39 :
40 : // Init成功后调用Serialize和获取属性接口
41 : std::string& Serialize();
42 :
43 : u32 GetKey() const;
44 : HcclResult Remap(void* addr, u64 length);
45 :
46 : private:
47 4 : const LocalRdmaRmaBufferImpl& GetImpl() const { return *pimpl_; }
48 : std::unique_ptr<LocalRdmaRmaBufferImpl> pimpl_;
49 : };
50 : } // namespace hccl
51 : #endif // LOCAL_RDMA_RMA_BUFFER_H
|