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 PRIVATE_TYPES_H
12 : #define PRIVATE_TYPES_H
13 : #include "hccl_common.h"
14 : #include "transport_heterog_def.h"
15 : #include "adapter_hccp.h"
16 : using HcclRtPointAttr = void*; // 获取指针属性,主要是页表大小
17 : using BinHandle = void*;
18 : constexpr u32 NOTIFY_INFO_LENGTH = 256;
19 :
20 : constexpr u32 HETEROG_RANK_TABLE_MAX_LEN = 10240; // ranktable max len 10 * 1024 = 10KB
21 : namespace hccl {
22 :
23 : using MemMsg = struct TagMemMsg {
24 : void* addr;
25 : u64 len;
26 : MemType memType;
27 : s32 mrRegFlag;
28 : u64 offset;
29 : u32 rkey;
30 : u32 lkey;
31 : u32 notifyId;
32 :
33 4695 : TagMemMsg()
34 4695 : : addr(nullptr),
35 4695 : len(0),
36 4695 : memType(MemType::MEM_TYPE_RESERVED),
37 4695 : mrRegFlag(0),
38 4695 : offset(0),
39 4695 : rkey(0),
40 4695 : lkey(0),
41 4695 : notifyId(INVALID_UINT)
42 4695 : {}
43 : };
44 :
45 : struct TransportResourceInfo {
46 : static constexpr s32 QP_FLAG_RC = 0;
47 : static constexpr s32 NORMAL_QP_MODE = 0;
48 : static constexpr s32 DEFAULT_DEVICE_LOGIC_ID = 0;
49 : static constexpr s32 DEFAULT_LKEY_VALUE = 0;
50 : static constexpr s32 DEFAULT_BATCH_NUM = 128;
51 :
52 : const std::unique_ptr<MrManager>& mrManager;
53 : const std::unique_ptr<LocklessRingMemoryAllocate<HcclMessageInfo>>& pMsgInfosMem;
54 : const std::unique_ptr<LocklessRingMemoryAllocate<HcclRequestInfo>>& pReqInfosMem;
55 : const std::unique_ptr<HeterogMemBlocksManager>& memBlocksManager;
56 : const std::unique_ptr<LocklessRingMemoryAllocate<RecvWrInfo>>& pRecvWrInfosMem;
57 : SrqInfo tagSrqInfo;
58 : SrqInfo dataSrqInfo;
59 : s32 flag;
60 : u32 lkey;
61 : s32 qpMode;
62 : s32 deviceLogicId;
63 : bool isHdcMode;
64 : u32 memBlockNum;
65 : bool remoteIsHdc;
66 : bool isESMode;
67 : bool isGlobalMrmanagerInit;
68 : u32 hdcHostWqeBatchNum;
69 : bool isRawConn{false};
70 : TransportResourceInfo() = delete;
71 2 : TransportResourceInfo(
72 : const std::unique_ptr<MrManager>& mrManager,
73 : const std::unique_ptr<LocklessRingMemoryAllocate<HcclMessageInfo>>& pMsgInfosMem,
74 : const std::unique_ptr<LocklessRingMemoryAllocate<HcclRequestInfo>>& pReqInfosMem,
75 : const std::unique_ptr<HeterogMemBlocksManager>& memBlocksManager,
76 : const std::unique_ptr<LocklessRingMemoryAllocate<RecvWrInfo>>& pRecvWrInfosMem)
77 2 : : mrManager(mrManager),
78 2 : pMsgInfosMem(pMsgInfosMem),
79 2 : pReqInfosMem(pReqInfosMem),
80 2 : memBlocksManager(memBlocksManager),
81 2 : pRecvWrInfosMem(pRecvWrInfosMem),
82 2 : tagSrqInfo(SrqInfo()),
83 2 : dataSrqInfo(SrqInfo()),
84 2 : flag(QP_FLAG_RC),
85 2 : lkey(0),
86 2 : qpMode(NORMAL_QP_MODE),
87 2 : deviceLogicId(DEFAULT_DEVICE_LOGIC_ID),
88 2 : isHdcMode(false),
89 2 : memBlockNum(MEM_BLOCK_NUM),
90 2 : remoteIsHdc(false),
91 2 : isESMode(false),
92 2 : isGlobalMrmanagerInit(false),
93 2 : hdcHostWqeBatchNum(DEFAULT_BATCH_NUM)
94 2 : {}
95 : TransportResourceInfo(const struct TransportResourceInfo& that)
96 : : mrManager(that.mrManager),
97 : pMsgInfosMem(that.pMsgInfosMem),
98 : pReqInfosMem(that.pReqInfosMem),
99 : memBlocksManager(that.memBlocksManager),
100 : pRecvWrInfosMem(that.pRecvWrInfosMem)
101 : {
102 : tagSrqInfo = (that.tagSrqInfo);
103 : dataSrqInfo = (that.dataSrqInfo);
104 : flag = (that.flag);
105 : lkey = (that.lkey);
106 : qpMode = (that.qpMode);
107 : deviceLogicId = (that.deviceLogicId);
108 : isHdcMode = (that.isHdcMode);
109 : memBlockNum = (that.memBlockNum);
110 : remoteIsHdc = false;
111 : isESMode = (that.isESMode);
112 : isGlobalMrmanagerInit = (that.isGlobalMrmanagerInit);
113 : hdcHostWqeBatchNum = (that.hdcHostWqeBatchNum);
114 : isRawConn = (that.isRawConn);
115 : }
116 : };
117 : // 全局工作空间类型
118 : enum class GlobalWorkSpaceType {
119 : OVERFLOW_DETECT_MODE = 0,
120 : };
121 :
122 : template <typename T>
123 1 : inline std::vector<u8> CustomTypeToVectorByte(T& data)
124 : {
125 1 : std::vector<u8> v((reinterpret_cast<u8*>(&data)), (reinterpret_cast<u8*>(&data) + sizeof(T)));
126 1 : return v;
127 : }
128 : } // namespace hccl
129 :
130 : #endif /* PRIVATE_TYPES_H */
|