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_UB_BUFFER_DTO_H
12 : #define HCCLV2_EXCHANGE_UB_BUFFER_DTO_H
13 : #include <map>
14 : #include <string>
15 : #include "serializable.h"
16 : #include "orion_adapter_hccp.h"
17 : #include "hccl_one_sided_data.h"
18 : namespace Hccl {
19 :
20 : class ExchangeUbBufferDto : public Serializable { // UB RMA Buffer / Notify /CntNotify 需要交换的DTO
21 : public:
22 13 : ExchangeUbBufferDto() {}
23 :
24 4 : ExchangeUbBufferDto(u64 addr, u64 size, u32 tokenValue, u32 tokenId, u32 keySize, u32 notifyId)
25 8 : : addr(addr),
26 4 : size(size),
27 4 : tokenValue(tokenValue),
28 4 : tokenId(tokenId),
29 4 : keySize(keySize),
30 4 : notifyId(notifyId)
31 4 : {}
32 :
33 14 : ExchangeUbBufferDto(
34 : u64 addr, u64 size, HcclMemType memType, const char* memInfo, u32 tokenValue, u32 tokenId, u32 keySize)
35 28 : : addr(addr),
36 14 : size(size),
37 14 : memType(memType),
38 14 : memInfo(memInfo),
39 14 : tokenValue(tokenValue),
40 14 : tokenId(tokenId),
41 14 : keySize(keySize)
42 14 : {}
43 :
44 17 : void Serialize(Hccl::BinaryStream& stream) override
45 : {
46 17 : stream << addr << size << memType << memInfo << tokenValue << tokenId << keySize << key << segVa << notifyId;
47 17 : }
48 :
49 11 : void Deserialize(Hccl::BinaryStream& stream) override
50 : {
51 11 : stream >> addr >> size >> memType >> memInfo >> tokenValue >> tokenId >> keySize >> key >> segVa >> notifyId;
52 11 : }
53 :
54 19 : std::string Describe() const override
55 : {
56 : return StringFormat(
57 19 : "ExchangeUbBufferDto[addr=0x%llx, size=0x%llx keySize=%u memInfo %s, notifyId=%u]", addr, size, keySize,
58 19 : memInfo.c_str(), notifyId);
59 : }
60 :
61 : u64 addr{0};
62 : u64 size{0};
63 : HcclMemType memType{HcclMemType::HCCL_MEM_TYPE_DEVICE};
64 : std::string memInfo;
65 : u8 key[HRT_UB_MEM_KEY_MAX_LEN]{0};
66 : u32 tokenValue{0};
67 : u32 tokenId{0};
68 : u32 keySize{0};
69 : u64 segVa{0};
70 : u32 notifyId{UINT32_MAX};
71 : };
72 :
73 : } // namespace Hccl
74 :
75 : #endif
|