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 1 : ExchangeIpcBufferDto()
24 2 : {
25 1 : }
26 :
27 8 : ExchangeIpcBufferDto(u64 addr, u64 size, u64 offset, u32 pid, const char *memInfo) : addr(addr), size(size), offset(offset), pid(pid), memInfo(memInfo)
28 : {
29 4 : }
30 :
31 3 : void Serialize(Hccl::BinaryStream &stream) override
32 : {
33 3 : stream << addr << size << offset << pid << name << memInfo;
34 3 : }
35 :
36 0 : void Deserialize(Hccl::BinaryStream &stream) override
37 : {
38 0 : stream >> addr >> size >> offset >> pid >> name >> memInfo;
39 0 : }
40 :
41 3 : std::string Describe() const override
42 : {
43 3 : std::string strName(name, name + RTS_IPC_MEM_NAME_LEN);
44 3 : return StringFormat("ExchangeIpcBufferDto[addr=0x%llx, size=0x%llx, offset=0x%llx, pid=%u, name=%s, memInfo=%s]", addr, size,
45 6 : offset, pid, strName.c_str(), memInfo.c_str());
46 3 : }
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
|