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_IPC_RMA_BUFFER_H
12 : #define HCCLV2_LOCAL_IPC_RMA_BUFFER_H
13 :
14 : #include "local_rma_buffer.h"
15 : #include "orion_adapter_rts.h"
16 :
17 : namespace Hccl {
18 :
19 : class LocalIpcRmaBuffer : public LocalRmaBuffer {
20 : public:
21 : explicit LocalIpcRmaBuffer(std::shared_ptr<Buffer> buf);
22 :
23 : // 别名构造函数:共享父buffer的IPC资源,不创建新的IPC内存名
24 : LocalIpcRmaBuffer(std::shared_ptr<Buffer> buf, const LocalIpcRmaBuffer& parent);
25 :
26 : ~LocalIpcRmaBuffer() override;
27 :
28 : LocalIpcRmaBuffer(const LocalIpcRmaBuffer& that) = delete;
29 :
30 : LocalIpcRmaBuffer& operator=(const LocalIpcRmaBuffer& that) = delete;
31 :
32 : std::string Describe() const override;
33 :
34 : void Grant(u32 pid);
35 :
36 : std::unique_ptr<Serializable> GetExchangeDto() override;
37 48 : std::pair<uintptr_t, u64> GetBufferInfo() { return std::make_pair(buf->GetAddr(), buf->GetSize()); }
38 :
39 12 : void* GetIpcPtr() const { return ipcPtr; }
40 :
41 : protected:
42 : char name[RTS_IPC_MEM_NAME_LEN];
43 : void* ipcPtr{nullptr};
44 : u64 ipcOffset{0};
45 : u64 ipcSize{0};
46 : };
47 :
48 : } // namespace Hccl
49 : #endif // HCCLV2_LOCAL_IPC_RMA_BUFFER_H
|