Line data Source code
1 :
2 : /**
3 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
4 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5 : * CANN Open Software License Agreement Version 2.0 (the "License").
6 : * Please refer to the License for details. You may not use this file except in compliance with the License.
7 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9 : * See LICENSE in the root of the software repository for the full text of the License.
10 : */
11 :
12 : #ifndef HCCLV2_LOCAL_RDMA_RMA_BUFFER_H
13 : #define HCCLV2_LOCAL_RDMA_RMA_BUFFER_H
14 :
15 : #include "local_rma_buffer.h"
16 : #include "orion_adapter_hccp.h"
17 :
18 : namespace Hccl {
19 :
20 : class LocalRdmaRmaBuffer : public LocalRmaBuffer {
21 : public:
22 : LocalRdmaRmaBuffer(std::shared_ptr<Buffer> buf, RdmaHandle rdmaHandle);
23 :
24 : // 别名构造函数:共享父buffer的RDMA注册资源,不调用RaRegisterMr
25 : LocalRdmaRmaBuffer(std::shared_ptr<Buffer> buf, RdmaHandle rdmaHandle, u32 lkey, u32 rkey, MrHandle mrHandle);
26 :
27 : ~LocalRdmaRmaBuffer() override;
28 :
29 : LocalRdmaRmaBuffer(const LocalRdmaRmaBuffer& that) = delete;
30 :
31 : LocalRdmaRmaBuffer& operator=(const LocalRdmaRmaBuffer& that) = delete;
32 :
33 : std::string Describe() const override;
34 :
35 : std::unique_ptr<Serializable> GetExchangeDto() override;
36 :
37 40 : u32 GetLkey() const { return lkey; }
38 9 : u32 GetRkey() const { return rkey; }
39 9 : MrHandle GetMrHandle() const { return mrHandle; }
40 29 : std::pair<uintptr_t, u64> GetBufferInfo() { return make_pair(buf->GetAddr(), buf->GetSize()); }
41 :
42 : std::vector<char> Desc;
43 :
44 : private:
45 : RdmaHandle rdmaHandle;
46 : u8 key[RDMA_MEM_KEY_MAX_LEN]{0};
47 : u32 lkey{0};
48 : u32 rkey{0};
49 : MrHandle mrHandle{nullptr};
50 : };
51 :
52 : } // namespace Hccl
53 : #endif // HCCLV2_LOCAL_RDMA_RMA_BUFFER_H
|