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 HCCLV2_LOCAL_RDMA_RMA_BUFFER_H
12 : #define HCCLV2_LOCAL_RDMA_RMA_BUFFER_H
13 :
14 : #include "local_rma_buffer.h"
15 : #include "orion_adapter_hccp.h"
16 :
17 : namespace Hccl {
18 :
19 : class LocalRdmaRmaBuffer : public LocalRmaBuffer {
20 : public:
21 : LocalRdmaRmaBuffer(std::shared_ptr<Buffer> buf, RdmaHandle rdmaHandle);
22 :
23 : // 别名构造函数:共享父buffer的RDMA注册资源,不调用RaRegisterMr
24 : LocalRdmaRmaBuffer(std::shared_ptr<Buffer> buf, RdmaHandle rdmaHandle, u32 lkey, u32 rkey, MrHandle mrHandle);
25 :
26 : ~LocalRdmaRmaBuffer() override;
27 :
28 : LocalRdmaRmaBuffer(const LocalRdmaRmaBuffer& that) = delete;
29 :
30 : LocalRdmaRmaBuffer& operator=(const LocalRdmaRmaBuffer& that) = delete;
31 :
32 : std::string Describe() const override;
33 :
34 : std::unique_ptr<Serializable> GetExchangeDto() override;
35 :
36 40 : u32 GetLkey() const { return lkey; }
37 9 : u32 GetRkey() const { return rkey; }
38 9 : MrHandle GetMrHandle() const { return mrHandle; }
39 29 : std::pair<uintptr_t, u64> GetBufferInfo() { return make_pair(buf->GetAddr(), buf->GetSize()); }
40 :
41 : std::vector<char> Desc;
42 :
43 : private:
44 : RdmaHandle rdmaHandle;
45 : u8 key[RDMA_MEM_KEY_MAX_LEN]{0};
46 : u32 lkey{0};
47 : u32 rkey{0};
48 : MrHandle mrHandle{nullptr};
49 : };
50 :
51 : } // namespace Hccl
52 : #endif // HCCLV2_LOCAL_RDMA_RMA_BUFFER_H
|