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 : #ifndef HCCLV2_EXCHANGE_IPC_BUFFER_DTO_H
11 : #define HCCLV2_EXCHANGE_IPC_BUFFER_DTO_H
12 :
13 : #include <string>
14 : #include "types.h"
15 : #include "binary_stream.h"
16 : #include "serializable.h"
17 : #include "orion_adapter_rts.h"
18 : #include "string_util.h"
19 : namespace Hccl {
20 :
21 : class ExchangeIpcBufferDto : public Serializable { // Ipc Rma Buffer 需要交换的DTO
22 : public:
23 9 : ExchangeIpcBufferDto() {}
24 :
25 6 : ExchangeIpcBufferDto(u64 addr, u64 size, u64 offset, u32 pid, const char* memInfo)
26 12 : : addr(addr),
27 6 : size(size),
28 6 : offset(offset),
29 6 : pid(pid),
30 12 : memInfo(memInfo)
31 6 : {}
32 :
33 5 : void Serialize(Hccl::BinaryStream& stream) override { stream << addr << size << offset << pid << name << memInfo; }
34 :
35 2 : void Deserialize(Hccl::BinaryStream& stream) override
36 : {
37 2 : stream >> addr >> size >> offset >> pid >> name >> memInfo;
38 2 : }
39 :
40 5 : std::string Describe() const override
41 : {
42 5 : std::string strName(name, name + RTS_IPC_MEM_NAME_LEN);
43 : return StringFormat(
44 5 : "ExchangeIpcBufferDto[addr=0x%llx, size=0x%llx, offset=0x%llx, pid=%u, name=%s, memInfo=%s]", addr, size,
45 10 : offset, pid, strName.c_str(), memInfo.c_str());
46 5 : }
47 :
48 : u64 addr{0};
49 : u64 size{0};
50 : u64 offset{0};
51 : u32 pid{0};
52 : char_t name[RTS_IPC_MEM_NAME_LEN]{0};
53 : std::string memInfo{""};
54 : };
55 :
56 : } // namespace Hccl
57 :
58 : #endif
|