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