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