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