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 HCCL_TASK_LOGIC_INFO_PUB_H
12 : #define HCCL_TASK_LOGIC_INFO_PUB_H
13 :
14 : #include <vector>
15 : #include <memory>
16 : #include <hccl/base.h>
17 : #include "mem_device_pub.h"
18 : #include "adapter_rts_common.h"
19 :
20 : namespace hccl {
21 : enum class UserMemType {
22 : INPUT_MEM,
23 : OUTPUT_MEM,
24 : MEM_RESERVED
25 : };
26 :
27 : struct TxMemoryInfo {
28 : UserMemType dstMemType;
29 : u64 dstOffset;
30 : const void *src;
31 : u64 len;
32 : };
33 :
34 : struct RxMemoryInfo {
35 : UserMemType srcMemType;
36 : u64 srcOffset;
37 : void *dst;
38 : u64 len;
39 : };
40 :
41 : struct RxWithReduceMemoryInfo {
42 : UserMemType recvSrcMemType;
43 : u64 recvSrcOffset;
44 : void *recvDst;
45 : u64 recvLen;
46 : void *reduceSrc;
47 : void *reduceDst;
48 : u64 reduceDataCount;
49 : };
50 :
51 : enum class TaskLogicType {
52 : TRANSPORT_TYPE,
53 : DISPATCHER_TYPE,
54 : TYPE_RESERVED
55 : };
56 :
57 : enum class TaskLogicFuncType {
58 : TRANSPORT_TXACK_TYPE, /* transport task type */
59 : TRANSPORT_RXACK_TYPE,
60 : TRANSPORT_TXASYNC_TYPE,
61 : TRANSPORT_RXASYNC_TYPE,
62 : TRANSPORT_TXDATASIGNAL_TYPE,
63 : TRANSPORT_RXDATASIGNAL_TYPE,
64 :
65 : DISPATCHER_SIGNALWAIT_TYPE = 100, /* dispatcher task type */
66 : DISPATCHER_SIGNALRECORD_TYPE,
67 : DISPATCHER_MEMCPYASYNC_TYPE,
68 : TYPE_RESERVED
69 : };
70 :
71 : struct ParaTxAck {
72 : void *stream;
73 : };
74 :
75 : struct ParaRxAck {
76 : void *stream;
77 : };
78 :
79 : struct ParaTxAsync {
80 : std::vector<TxMemoryInfo> txMems;
81 : };
82 :
83 : struct ParaRxAsync {
84 : std::vector<RxMemoryInfo> rxMems;
85 : };
86 :
87 : struct ParaTxDataSignal {
88 : void *stream;
89 : };
90 :
91 : struct ParaRxDataSignal {
92 : void *stream;
93 : };
94 :
95 : struct ParaSignalWait {
96 : void *signal;
97 : u32 userRank;
98 : u32 remoteRank;
99 : s32 stage;
100 : };
101 :
102 : struct ParaSignalRecord {
103 : void *signal;
104 : u32 userRank;
105 : u64 offset;
106 : s32 stage;
107 : };
108 :
109 : struct ParaMemAsync {
110 : void *dst;
111 : uint64_t destMax;
112 : void *src;
113 : u64 count;
114 : HcclRtMemcpyKind kind;
115 : };
116 :
117 : struct TaskLogicCmdInfo {
118 : TaskLogicType taskLogicType; /* logic task 操作类型:0: transport, 1: dispatcher */
119 : u32 index; /* 对应vtransport、vdispatcher的index信息 */
120 : };
121 :
122 : struct TaskLogicInfo {
123 : TaskLogicCmdInfo taskLogicCmd; /* logic task 操作类型 */
124 : TaskLogicFuncType taskFuncType; /* logic task 具体执行方法 */
125 : union {
126 : union {
127 : ParaTxAck txAck;
128 : ParaRxAck rxAck;
129 : ParaTxDataSignal txDataSignal;
130 : ParaRxDataSignal rxDataSignal;
131 : } transportTaskLogicPara;
132 :
133 : union {
134 : ParaSignalWait signalWait;
135 : ParaSignalRecord signalRecord;
136 : ParaMemAsync memAsync;
137 : } dispatcherTaskLogicPara;
138 : } taskLogicPara;
139 : ParaTxAsync txAsync;
140 : ParaRxAsync rxAsync;
141 0 : TaskLogicInfo() {};
142 : TaskLogicInfo(u32 index, TaskLogicType taskLogicType, TaskLogicFuncType funcType);
143 : TaskLogicInfo(u32 index, TaskLogicType taskLogicType, TaskLogicFuncType funcType,
144 : std::vector<TxMemoryInfo> &txMems);
145 : TaskLogicInfo(u32 index, TaskLogicType taskLogicType, TaskLogicFuncType funcType,
146 : std::vector<RxMemoryInfo> &rxMems);
147 : TaskLogicInfo(u32 index, TaskLogicType taskLogicType, TaskLogicFuncType funcType, void *signal, u32 userRank,
148 : u32 remoteUserRank, s32 stage);
149 : TaskLogicInfo(u32 index, TaskLogicType taskLogicType, TaskLogicFuncType funcType, void *signal, u32 userRank,
150 : u64 offset, s32 stage);
151 : TaskLogicInfo(u32 index, TaskLogicType taskLogicType, TaskLogicFuncType funcType, void *dst, uint64_t destMax,
152 : void *src, u64 count, HcclRtMemcpyKind kind);
153 : };
154 : } // namespace hccl
155 : #endif /* HCCL_TASK_LOGIC_INFO_PUB_H */
|