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 ALG_TEMPLATE_BASE_PUB_H
12 : #define ALG_TEMPLATE_BASE_PUB_H
13 :
14 : #include <cstring>
15 : #include <vector>
16 : #include <memory>
17 : #include <list>
18 : #include "hccl/base.h"
19 : #include "externalinput_pub.h"
20 : #include "mem_device_pub.h"
21 : #include "stream_pub.h"
22 : #include "transport_pub.h"
23 : #include "adapter_pub.h"
24 : #include "dispatcher.h"
25 : #include "local_notify.h"
26 : #include "template_v1_utils.h"
27 : #include "op_context.h"
28 : #include "comm_ahc_pub.h"
29 :
30 : namespace hccl {
31 : constexpr s32 HCCL_EXEC_STAGE_NOT_SET = -1;
32 : constexpr s32 HCCL_EXEC_STEP_NOT_SET = -1;
33 : constexpr s32 HCCL_EXEC_PLANE_NOT_SET = -1;
34 : constexpr u64 ZERO_SLICE = 0;
35 : constexpr u32 TWO_RANK_SIZE = 2;
36 : constexpr u32 DMA_REDUCE_TWO_OFFSET = 2;
37 : constexpr u32 DMA_REDUCE_THREE_OFFSET = 3;
38 : constexpr u64 HCCL_CHUNK_SIZE = 1024 * 1024 * 1024; // 1024*1024*1024的size
39 : constexpr u64 HCCL_MIN_PIPLINE_SLICE_ALIGN = 512;
40 : constexpr u64 HCCL_MIN_SLICE_ALIGN_910B = 16384;
41 : constexpr u64 HCCL_MIN_SLICE_ALIGN_910_93 = 16384;
42 : constexpr u64 HCCL_MIN_SLICE_ALIGN_ONCHIP = 512;
43 : constexpr u64 HCCL_MIN_SLICE_ALIGN = 128;
44 : constexpr u64 HCCL_NIC_MAX_NUM = 8;
45 : constexpr u64 DOUBLE_RING_NUM = 2;
46 : constexpr u64 DOUBLE_RING_STREAM_NUM = 3;
47 : constexpr u32 ALIGNED_SUB_RING_INDEX = 0;
48 : constexpr u32 ALIGNED_MAIN_RING_INDEX = 1;
49 :
50 : // AnyPath相关,SDMA数据量切分比例
51 : constexpr u32 MAX_SPLIT_VALUE = 100;
52 : constexpr u32 BEST_SPLIT_VALUE_SR = 87;
53 : constexpr u32 BEST_SPLIT_VALUE_DR = 90;
54 : constexpr u64 HCCL_SPLIT_SIZE_INTER_SERVER = 8388608; // 每卡通信量的切分边界
55 :
56 : enum TemplateType {
57 : // 内置template
58 : TEMPLATE_ALL_GATHER_HD_STAGE = 0, // AllGatherHDStage
59 : TEMPLATE_ALL_2_ALL_V_DIRECT_FULL_MESH = 1, // AlltoAllVDirectFullMesh
60 : TEMPLATE_ALL_REDUCE_REDUCE_BCAST = 2, // AllReduceReduceBcast
61 : TEMPLATE_BROADCAST_NHR_V1 = 3, // BroadcastNHRV1
62 : TEMPLATE_BROADCAST_NHR = 4, // BroadcastNHR
63 : TEMPLATE_BROADCAST_NHR_ONESHOT = 5, // BroadcastNHROneshot
64 : TEMPLATE_BROADCAST_NB = 6, // BroadcastNB
65 : TEMPLATE_BROADCAST_NB_BINARY = 7, // BroadcastNBBinary
66 : TEMPLATE_BROADCAST_HD = 8, // BroadcastHD
67 : TEMPLATE_BROADCAST_RECURSIVE_HD = 10, // BcastRecursiveHalvingDoubling
68 : TEMPLATE_BROADCAST_RING = 11, // BroadcastRing
69 : TEMPLATE_BROADCAST_STAR = 12, // BroadcastStar
70 : TEMPLATE_ALL_2_ALL_V_FOR310P = 13, // AlltoAllVFor310P
71 : TEMPLATE_ALL_2_ALL_V_PAIRWISE = 15, // AlltoAllVPairwise
72 : TEMPLATE_ALL_2_ALL_V_STAGED_MESH = 16, // AlltoAllVStagedMesh
73 : TEMPLATE_ALL_2_ALL_V_STAGED_PAIRWISE = 17, // AlltoAllVStagedPairwise
74 : TEMPLATE_REDUCESCATTER_HDSTAGE = 18, // ReduceScatterHDStage
75 : TEMPLATE_REDUCESCATTER_LOCAL_REDUCE = 19, // ReduceScatterLocalReduce
76 : TEMPLATE_REDUCESCATTER_NB = 20, // ReduceScatterNB
77 : TEMPLATE_REDUCESCATTER_NHR = 21, // ReduceScatterNHR
78 : TEMPLATE_REDUCESCATTER_NHR_V1 = 22, // ReduceScatterNHRV1
79 : TEMPLATE_REDUCESCATTER_PIPELINE = 23, // ReduceScatterPipeline
80 : TEMPLATE_REDUCESCATTER_UNIFIED_MARCH = 24, // ReduceScatterUnifiedMarch
81 : TEMPLATE_REDUCESCATTER_DB_RING_SLC = 25, // AlignedReduceScatterDoubleRingWithSerialLocalCopy
82 : TEMPLATE_REDUCESCATTER_DB_RING = 26, // AlignedReduceScatterDoubleRing
83 : TEMPLATE_REDUCESCATTER_HD = 27, // ReduceScatterHalvingDoubling
84 : TEMPLATE_REDUCESCATTER_MESH_DIRECT = 28, // ReduceScatterMeshDirect
85 : TEMPLATE_REDUCESCATTER_MESH_ATOMIC = 29, // ReduceScatterMeshAtomic
86 : TEMPLATE_REDUCESCATTER_MESH_MIX_SS = 30, // ReduceScatterMeshMixSingleStream
87 : TEMPLATE_REDUCESCATTER_MESH_MIX = 31, // ReduceScatterMeshMix
88 : TEMPLATE_REDUCESCATTER_MESH = 32, // ReduceScatterMesh
89 : TEMPLATE_REDUCESCATTER_RECURSIVE_HD = 33, // ReduceScatterRecursiveHalvingDoubling
90 : TEMPLATE_REDUCESCATTER_RING_DIRECT = 34, // ReduceScatterRingConcurrentDirect
91 : TEMPLATE_REDUCESCATTER_RING = 35, // ReduceScatterRing
92 : TEMPLATE_ALL_REDUCE_RECURSIVE_HALVING_DOUBLING = 36,
93 : TEMPLATE_ALL_REDUCE_RING = 37,
94 : TEMPLATE_REDUCE_RECURSIVE_HALVING_DOUBLING = 38,
95 : TEMPLATE_REDUCE_RING = 39,
96 : TEMPLATE_REDUCE_NHR_ONE_SHOT = 40,
97 : TEMPLATE_ALL_REDUCE_CHUNK_MESH = 41,
98 : TEMPLATE_ALL_REDUCE_DOUBLING_DIRECT = 42,
99 : TEMPLATE_ALL_REDUCE_DOUBLING = 43,
100 : TEMPLATE_ALL_REDUCE_HD_OPTIM = 44,
101 : TEMPLATE_ALL_REDUCE_LOCAL_REDUCE_BCAST = 45,
102 : TEMPLATE_ALL_REDUCE_LOCAL_REDUCE = 46,
103 : TEMPLATE_ALL_REDUCE_MESH_DIRECT_ONESHOT = 47,
104 : TEMPLATE_ALL_REDUCE_MESH_DIRECT = 48,
105 : TEMPLATE_ALL_REDUCE_NB = 49,
106 : TEMPLATE_ALL_REDUCE_NHR_ONESHOT = 50,
107 : TEMPLATE_ALL_REDUCE_NHR_V1 = 51,
108 : TEMPLATE_ALL_REDUCE_NHR = 52,
109 : TEMPLATE_ALL_REDUCE_OPBASE_PIPELINE = 53,
110 : TEMPLATE_ALIGNED_ALL_GATHER_DOUBLE_RING = 54, // AlignedAllGatherDoubleRing
111 : TEMPLATE_ALL_GATHER_HALVING_DOUBLING = 55, // AllGatherHalvingDoubling
112 : TEMPLATE_ALL_GATHER_MESH = 56, // AllGatherMesh
113 : TEMPLATE_ALL_GATHER_MESH_ATOMIC = 57, // AllGatherMeshAtomic
114 : TEMPLATE_ALL_GATHER_MESH_DIRECT = 58, // AllGatherMeshDirect
115 : TEMPLATE_ALL_GATHER_MESH_MIX = 59, // AllGatherMeshMix
116 : TEMPLATE_ALL_GATHER_RECURSIVE_HALVING_DOUBLING = 60, // AllGatherRecursiveHalvingDoubling
117 : TEMPLATE_ALL_GATHER_RING_CONCURRENT_DIRECT = 61, // AllGatherRingConcurrentDirect
118 : TEMPLATE_ALL_GATHER_RING = 62, // AllGatherRing
119 : TEMPLATE_ALL_GATHER_NB = 63, // AllGatherNB
120 : TEMPLATE_ALL_GATHER_NHRV1 = 64, // AllGatherNHRV1
121 : TEMPLATE_ALL_GATHER_NHR = 65, // AllGatherNHR
122 : TEMPLATE_ALL_GATHER_PIPELINE = 66, // AllGatherPipeline
123 : TEMPLATE_ALL_GATHER_UNIFIED_MARCH = 67, // AllGatherUnifiedMarch
124 :
125 : TEMPLATE_MULTI_ROOT_SCATTER_RING = 68, // MultiRootScatterRing
126 : TEMPLATE_SCATTER_DOUBLE_RING_DIRECT = 69, // ScatterDoubleRingDirect
127 : TEMPLATE_SCATTER_MESH = 70, // ScatterMesh
128 : TEMPLATE_SCATTER_RING_CONCURRENT_DIRECT = 71, // ScatterRingConcurrentDirect
129 : TEMPLATE_SCATTER_RING = 72, // ScatterRing
130 : TEMPLATE_SCATTER_NB = 73, // ScatterNB
131 : TEMPLATE_SCATTER_NHR = 74, // ScatterNHR
132 : TEMPLATE_SCATTER_RING_DIRECT = 75, // ScatterRingDirect
133 :
134 : TEMPLATE_GATHER_MESH = 76, // GatherMesh
135 : TEMPLATE_GATHER_RING = 77, // GatherRing
136 : TEMPLATE_GATHER_STAR = 78, // GatherStar
137 :
138 : TEMPLATE_ALL_2_ALL_PIPELINE_MESH_PAIRWISE_CCL_ENOUGH = 79, // AlltoallPipelineMeshPairwiseCCLEnough
139 : TEMPLATE_ALL_2_ALL_PIPELINE_MESH_PAIRWISE_PING_PONG = 80, // AlltoallPipelineMeshPairwisePingPong
140 :
141 : TEMPLATE_ALL_REDUCE_AHC = 81,
142 : TEMPLATE_ALL_REDUCE_AHC_BROKE = 82,
143 : TEMPLATE_ALL_GATHER_AHC = 83,
144 : TEMPLATE_ALL_GATHER_AHC_BROKE = 84,
145 : TEMPLATE_REDUCESCATTER_AHC = 85,
146 : TEMPLATE_REDUCESCATTER_AHC_BROKE = 86,
147 : TEMPLATE_ALL_GATHER_RING_DIRECT = 87, // AllGatherRingDirect
148 : TEMPLATE_ALL_GATHER_HCCS_SIO = 88,
149 : TEMPLATE_REDUCESCATTER_HCCS_SIO = 89,
150 :
151 : TEMPLATE_ALLREDUCE_GRAPH_PIPELINE = 90, // AllReduceGraphPipeline
152 :
153 : TEMPLATE_ALL_GATHER_GRAPH_PIPELINE = 91, // AllGatherGraphPipeline AG图模式pipeline
154 : TEMPLATE_REDUCESCATTER_GRAPH_PIPELINE = 92, // ReduceScatterGraphPipeline AG图模式pipeline
155 :
156 : TEMPLATE_ALL_GATHER_SLIM_RING = 93,
157 : TEMPLATE_REDUCESCATTER_SLIM_RING = 94,
158 :
159 : TEMPLATE_REDUCESCATTER_PLANT_LOCAL_REDUCE = 95, // ReduceScatterPlantLocalReduce RS规约保序单机
160 : TEMPLATE_REDUCESCATTER_PLANT_LOCAL_REDUCE_COMBINE = 96, // ReduceScatterPlantLocalReduceCombine RS规约保序跨机
161 : TEMPLATE_REDUCESCATTER_V_PIPELINE = 97, // ReduceScatterVPipeline RSV多机Pipeline
162 :
163 : TEMPLATE_ALL_GATHER_V_PIPELINE = 98, // AllGatherV pipeline
164 :
165 : TEMPLATE_ALL_REDUCE_DOUBLING_LOCAL_REDUCE = 99, // AllReduceDoublingLocalReduce AR 910A单机小数据量tbe reduce优化
166 :
167 : TEMPLATE_ALL_2_ALL_V_CONTINUOUS_PIPELINE = 100, // AlltoallvContinuousPipeline
168 :
169 : TEMPLATE_ALL_GATHER_V_GRAPH_PIPELINE = 101, // AllGatherV Graph pipeline
170 : TEMPLATE_REDUCESCATTER_MULTI_DETERMINISTIC_PIPELINE = 102,
171 : TEMPLATE_ALL_REDUCE_MULTI_DETERMINISTIC_PIPELINE = 103,
172 : TEMPLATE_ALL_2_ALL_FULL_MESH_SYMMETRIC_MEMORY = 104,
173 :
174 : TEMPLATE_NATIVE_MAX_NUM, // 内置template最大值
175 :
176 : TEMPLATE_CUSTOM_BEGIN = 1000, // 用户自定义template起始值
177 : TEMPLATE_CUSTOM_MAX_NUM = 2000 // 用户自定义template最大值
178 : };
179 :
180 : enum class SliceType { SLICE_TYPE_TX, SLICE_TYPE_RX };
181 :
182 : using GroupSlicesInfo = std::vector<MemBlockInfo>;
183 :
184 : enum class HalvingDoublingType { BINARY_BLOCK_HALVING_DOUBLING, RECURSIVE_HALVING_DOUBLING, RESERVED_ALGORITHM_TYPE };
185 :
186 : using SliceType = enum SliceType;
187 :
188 : enum class RunStage { RUN_PREPARE, RUN_REDUCE_SCATTER, RUN_ALLGATHER, RUN_ALLREDUCE, RUN_DEFAULT };
189 :
190 : struct PrepareData {
191 : u32 root = INVALID_VALUE_RANKID;
192 : u32 userRank = INVALID_VALUE_RANKID;
193 : u32 userRankSize = 0;
194 : u32 interRank = INVALID_VALUE_RANKID;
195 : u32 interRankSize = 0;
196 :
197 : u64 count = 0;
198 : HcclDataType dataType = HCCL_DATA_TYPE_RESERVED;
199 : HcclReduceOp reductionOp = HCCL_REDUCE_RESERVED;
200 : u64 baseOffset = 0;
201 :
202 : DeviceMem inputMem;
203 : DeviceMem outputMem;
204 : DeviceMem scratchMem;
205 : DeviceMem cclInMem;
206 : DeviceMem cclOutMem;
207 :
208 : Stream stream;
209 : const std::vector<Stream>* subStreamsPtr = nullptr;
210 : const std::vector<std::shared_ptr<LocalNotify>>* signalPtr = nullptr;
211 : const std::vector<std::shared_ptr<LocalNotify>>* signalAuxPtr = nullptr;
212 :
213 : const std::vector<LINK>* linksPtr = nullptr;
214 : const std::vector<Slice>* slicesPtr = nullptr;
215 : const std::vector<std::vector<Slice>>* multRingsSlicesPtr = nullptr;
216 : const std::vector<u32>* nicRankListPtr = nullptr;
217 :
218 : HcclWorkflowMode workMode = HcclWorkflowMode::HCCL_WORKFLOW_MODE_RESERVED;
219 : HcomCollOpInfo* opInfo = nullptr;
220 : bool disableDMAReduce = false;
221 : bool isSuPodAsym = false;
222 : HcclCMDType opType = HcclCMDType::HCCL_CMD_INVALID;
223 :
224 : const SendRecvInfo* localSendRecvInfoPtr = nullptr;
225 : const ZCopySendRecvInfo* sendRecvInfoPtr = nullptr;
226 : u32 devNumInlocalPod = 0;
227 : u32 rankIdxInPod = 0;
228 : u64 reduceAttr = 0;
229 :
230 : AlgOpContext algOpContext;
231 :
232 : bool needAlltoallvCache = false; // 用于alltoallv类算子的aicpu cache
233 : };
234 :
235 : struct HcclTopoInfo;
236 : class TopoMatcher;
237 : class ExecutorBase {
238 : public:
239 : explicit ExecutorBase(const HcclDispatcher dispatcher);
240 : virtual ~ExecutorBase();
241 :
242 : virtual HcclResult RunAsync();
243 : virtual HcclResult
244 : RunAsync(const u32 rank, const u32 rankSize, const std::vector<std::shared_ptr<Transport>>& links);
245 : virtual HcclResult RunAsyncStaged(
246 : const u32 rank, const u32 rankSize, const std::vector<std::shared_ptr<Transport>>& links, RunStage stage);
247 : /* 12个参数 */
248 : virtual HcclResult Prepare(
249 : DeviceMem& inputMem, DeviceMem& outputMem, DeviceMem& scratchMem, const u64 count, const HcclDataType dataType,
250 : const Stream& stream, const HcclReduceOp reductionOp = HCCL_REDUCE_RESERVED,
251 : const u32 root = INVALID_VALUE_RANKID, const std::vector<Slice>& slices = std::vector<Slice>(ZERO_SLICE),
252 : const u64 baseOffset = 0, std::vector<u32> nicRankList = {0, 1, 2, 3, 4, 5, 6, 7},
253 : const bool disableDMAReduce = false);
254 :
255 : /* 11个参数 */
256 : virtual HcclResult Prepare(
257 : DeviceMem& inputMem, DeviceMem& scratchMem, const u64 count, const HcclDataType dataType, const Stream& stream,
258 : const HcclReduceOp reductionOp = HCCL_REDUCE_RESERVED, const u32 root = INVALID_VALUE_RANKID,
259 : const std::vector<Slice>& slices = std::vector<Slice>(ZERO_SLICE), const u64 baseOffset = 0,
260 : std::vector<u32> nicRankList = {0, 1, 2, 3, 4, 5, 6, 7}, const bool disableDMAReduce = false);
261 :
262 : virtual HcclResult Prepare(
263 : DeviceMem& inputMem, DeviceMem& outputMem, DeviceMem& scratchMem, const u64 count, const HcclDataType dataType,
264 : const Stream& stream, const std::vector<std::vector<Slice>>& multRingsSlices,
265 : const HcclReduceOp reductionOp = HCCL_REDUCE_RESERVED, const u32 root = INVALID_VALUE_RANKID,
266 : const u64 baseOffset = 0, const bool disableDMAReduce = false);
267 :
268 : virtual HcclResult Prepare(PrepareData& param);
269 :
270 : /* 1个参数 */
271 : // AllGatherNHR, ScatterNHR
272 : virtual HcclResult Prepare(bool needSaveRankMap);
273 :
274 : // AHC 扩展参数
275 : virtual HcclResult Prepare(AHCExtendPreparePara& extendParam);
276 :
277 : // GatherStar
278 : virtual HcclResult Prepare(u32 userRank);
279 :
280 : /* 2个参数 */
281 : // ReduceScatterNB, ReduceScatterNHRV1, ReduceScatterRing, ReduceScatterRecursiveHalvingDoubling
282 : virtual HcclResult Prepare(u64 reduceAttrBitMap, HcomCollOpInfo* opInfo = nullptr);
283 :
284 : // ReduceScatterNHR
285 : virtual HcclResult Prepare(u64 reduceAttrBitMap, bool needMerge);
286 :
287 : // ReduceScatterMeshMixSingleStream, ReduceScatterMesh
288 : virtual HcclResult Prepare(u64 reduceAttrBitMap, u32 streamIndex);
289 :
290 : // ScatterMesh
291 : virtual HcclResult Prepare(u32 interRank, u32 interRankSize);
292 :
293 : /* 3个参数 */
294 : // for AllGatherHalvingDoubling based on input_scratch_Mem_nicRankList Prepare
295 : // and should be called soon template AllGatherHalvingDoubling created
296 : virtual HcclResult Prepare(u32 blockSize, UserMemType hdInputMemType, UserMemType hdOutputMemType);
297 :
298 : /* 4个参数 */
299 : // ScatterRingDirect
300 : virtual HcclResult Prepare(
301 : HcomCollOpInfo* opInfo, const u32 userRank, const std::vector<u32>& ringsOrders,
302 : const std::vector<Slice>& userMemInputSlices);
303 :
304 : // AllGatherRingDirect
305 : virtual HcclResult
306 : Prepare(HcomCollOpInfo* opInfo, u32 userRank, const std::vector<Slice>& userMemOutputSlices, bool isSdma = true);
307 :
308 : /* 5个参数 */
309 : // AHC 5个参数,带扩展参数
310 : virtual HcclResult Prepare(
311 : u64 totalCount, const std::vector<std::vector<std::vector<u32>>>& subGroups,
312 : std::map<AHCConcOpType, TemplateType>& ahcAlgOption, bool extendFlag = false,
313 : AHCExtendPreparePara extendPara = AHCExtendPreparePara());
314 :
315 : /* 6个参数 */
316 : // AlltoAllVStagedPairwise
317 : virtual HcclResult Prepare(
318 : DeviceMem& sendMem, DeviceMem& recvMem, StageAlltoAllVAddrInfo& sendAddrInfo,
319 : StageAlltoAllVAddrInfo& recvAddrInfo, bool isAlltoAllZCopyMode, Stream& mainStream);
320 :
321 : /* 7个参数 */
322 : virtual HcclResult Prepare(
323 : u64 reduceAttrBitMap, std::vector<Stream>& meshStreams, std::vector<std::shared_ptr<LocalNotify>>& meshSignal,
324 : std::vector<std::shared_ptr<LocalNotify>>& meshSignalAux, u32 userRank, HcomCollOpInfo* opInfo, bool aicpu);
325 :
326 : // AlltoAllVPairWise
327 : virtual HcclResult Prepare(
328 : AlltoAllVBufferInfo& sendBuffer, AlltoAllVBufferInfo& recvBuffer, bool isAlltoAllZCopyMode,
329 : const Stream& stream, HcclWorkflowMode workMode, std::map<u32, std::vector<u64>>& rankSendDisplsMap,
330 : std::map<u32, std::vector<u64>>& rankRecvDisplsMap);
331 :
332 : // AlignedAllGatherDoubleRing
333 : virtual HcclResult Prepare(
334 : HcomCollOpInfo* opInfo, const u32 userRank, std::vector<Stream>& subStreams,
335 : std::vector<std::shared_ptr<LocalNotify>>& mainSignals, std::vector<std::shared_ptr<LocalNotify>>& subSignals,
336 : const std::vector<std::vector<u32>>& ringsOrders,
337 : const std::vector<std::vector<Slice>>& userMemOutputSlicesOfDoubleRing);
338 :
339 : // AllGatherMeshAtomic, AllgatherMeshDirect, AllGatherMesh, AllGatherMeshMix, GatherMesh
340 : virtual HcclResult Prepare(
341 : std::vector<Stream>& meshStreams, std::vector<std::shared_ptr<LocalNotify>>& meshSignal,
342 : std::vector<std::shared_ptr<LocalNotify>>& meshSignalAux, u32 userRank = INVALID_VALUE_RANKID,
343 : HcomCollOpInfo* opInfo = nullptr, u32 interRank = INVALID_VALUE_RANKID, u32 interRankSize = 0);
344 :
345 : /* 8个参数 */
346 : virtual HcclResult Prepare(
347 : u64 reduceAttrBitMap, std::vector<Stream>& meshStreams, std::vector<std::shared_ptr<LocalNotify>>& meshSignal,
348 : std::vector<std::shared_ptr<LocalNotify>>& meshSignalAux, u32 interRank, u32 interRankSize, u32 userRank,
349 : HcomCollOpInfo* opInfo);
350 :
351 : // AlltoAllVStagedPairwise
352 : virtual HcclResult Prepare(
353 : DeviceMem& sendMem, DeviceMem& recvMem, DeviceMem& scratchInputMem, DeviceMem& scratchOutputMem,
354 : StageAlltoAllVAddrInfo& sendAddrInfo, StageAlltoAllVAddrInfo& recvAddrInfo, bool isAlltoAllZCopyMode,
355 : Stream& mainStream);
356 :
357 : // AllGatherRingConcurrentDirect ScatterRingConcurrentDirect
358 : virtual HcclResult Prepare(
359 : HcomCollOpInfo* opInfo, const u32 userRank, std::vector<Stream>& subStreams,
360 : const std::vector<std::shared_ptr<LocalNotify>>& mainSignals,
361 : const std::vector<std::shared_ptr<LocalNotify>>& subSignals, const std::vector<u32>& ringsOrder,
362 : const std::vector<Slice>& userMemSlices, bool isSdma = true);
363 :
364 : /* 9个参数 */
365 : // scatterDoubleRingDirect
366 : virtual HcclResult Prepare(
367 : HcomCollOpInfo* opInfo, const u32 userRank, const u32 subRingRank, std::vector<Stream>& subStreams,
368 : const std::vector<std::shared_ptr<LocalNotify>>& mainSignals,
369 : const std::vector<std::shared_ptr<LocalNotify>>& subSignals, const std::vector<std::vector<u32>>& ringsOrders,
370 : const std::vector<std::vector<Slice>>& multiRingSlices,
371 : const std::vector<std::vector<Slice>>& userMemInputSlices);
372 :
373 : // ReduceScatterRingConcurrentDirect
374 : virtual HcclResult Prepare(
375 : const u64 reduceAttrBitMap, const HcomCollOpInfo* opInfo, const u32 userRank, std::vector<Stream>& subStreams,
376 : const std::vector<std::shared_ptr<LocalNotify>>& mainSignals,
377 : const std::vector<std::shared_ptr<LocalNotify>>& subSignals, const std::vector<u32>& ringsOrder,
378 : const std::vector<Slice>& userMemInputSlices, bool isSdma = true);
379 :
380 : // AlltoAllVPairWise
381 : virtual HcclResult Prepare(
382 : AlltoAllVBufferInfo& sendBuffer, AlltoAllVBufferInfo& recvBuffer, DeviceMem& scratchInputMem,
383 : DeviceMem& scratchOutputMem, bool isAlltoAllZCopyMode, const Stream& stream, HcclWorkflowMode workMode,
384 : std::map<u32, std::vector<u64>>& rankSendDisplsMap, std::map<u32, std::vector<u64>>& rankRecvDisplsMap);
385 :
386 : /* 10个参数 */
387 : virtual HcclResult Prepare(
388 : const HcomCollOpInfo* opInfo, DeviceMem& cclBufferA, DeviceMem& cclBufferB, const u64 count,
389 : const SubCommInfo& level1CommInfo, const SubCommInfo& level0CommInfo, Stream& mainStream,
390 : std::vector<Stream>& subStream, std::vector<std::shared_ptr<LocalNotify>>& notifyMain,
391 : std::vector<std::shared_ptr<LocalNotify>>& notifySub);
392 :
393 : // AlltoAllPipelineMeshPairwiseCCLEnough, AlltoAllPipelineMeshPairwisePingPong
394 : virtual HcclResult Prepare(
395 : u32 userRank, A2aPipelineMemory A2aPipelineMemory, const SubCommInfo& level0CommInfo,
396 : const SubCommInfo& level1CommInfo, Stream& mainStream, std::vector<Stream>& subStream,
397 : std::vector<std::shared_ptr<LocalNotify>>& notifyMain, std::vector<std::shared_ptr<LocalNotify>>& notifySub,
398 : std::vector<SendRecvInfo>& allMeshAggregationSendRecvInfo,
399 : HcclWorkflowMode workMode = HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE);
400 :
401 : // AlltoAllVSatgedMesh
402 : virtual HcclResult Prepare(
403 : DeviceMem& sendMem, DeviceMem& recvMem, StageAlltoAllVAddrInfo& sendAddrInfo,
404 : StageAlltoAllVAddrInfo& recvAddrInfo, bool isAlltoAllZCopyMode, u32 userRank, Stream& mainStream,
405 : std::vector<Stream>& subStreams, std::vector<std::shared_ptr<LocalNotify>>& meshSignalMainToSub,
406 : std::vector<std::shared_ptr<LocalNotify>>& meshSignalSubToMain);
407 :
408 : // ReduceScatterPlantLocalReduce
409 : virtual HcclResult Prepare(
410 : void* inputMemPtr, DeviceMem& cclInMem, DeviceMem& outputMem, const Stream& stream,
411 : std::vector<Stream>& subStreams, std::vector<std::shared_ptr<LocalNotify>>& meshSignal,
412 : std::vector<std::shared_ptr<LocalNotify>>& meshSignalAux, GroupSlicesInfo& grouSlicesInfo,
413 : const HcclReduceOp reductionOp, u32 all2allOffset, const HcclDataType dataType, bool isNeedSpaceBorrow,
414 : bool reverseMemUsage = false, bool isA3CrossNode = false);
415 :
416 : // ReduceScatterPlantLocalReduceCombine
417 : virtual HcclResult Prepare(
418 : DeviceMem& cclInMem, DeviceMem& outputMem, const Stream& stream, std::vector<Stream>& subStreams,
419 : std::vector<std::shared_ptr<LocalNotify>>& meshSignal, std::vector<std::shared_ptr<LocalNotify>>& meshSignalAux,
420 : MemBlockInfo& memBlockInfo, const HcclReduceOp reductionOp, const HcclDataType dataType, bool isUseCclIn,
421 : bool isLevel0LastRank, bool isNeedSpaceBorrow);
422 :
423 : /* 11个参数 */
424 : // Prepare for AllGatherPipeline
425 : virtual HcclResult Prepare(
426 : HcomCollOpInfo* opInfo, u32 userRank, u64& count, DeviceMem& cclBufferPartOne, DeviceMem& cclBufferPartTwo,
427 : SubCommInfo& level0CommInfo, SubCommInfo& level1CommInfo, Stream& mainStream, std::vector<Stream>& subStream,
428 : std::vector<std::shared_ptr<LocalNotify>>& notifyMain, std::vector<std::shared_ptr<LocalNotify>>& notifySub);
429 :
430 : // Prepare for AllGatherUnifiedMarch
431 : virtual HcclResult Prepare(
432 : const Stream& mainStream, SubCommInfo& level0CommInfo, DeviceMem& userInput, DeviceMem& userOutput,
433 : DeviceMem& usrInMem, DeviceMem& usrOutMem, u64 blockDataByte, std::vector<Stream>& subStreams,
434 : const std::vector<std::shared_ptr<LocalNotify>>& meshSignalMainToSub,
435 : const std::vector<std::shared_ptr<LocalNotify>>& meshSignalSubToMain,
436 : const std::vector<std::vector<Slice>>& multRingsUserMemSlice, const u64 baseOffset = 0);
437 :
438 : // Prepare for AllGatherHccsSio
439 : virtual HcclResult Prepare(
440 : SubCommInfo& outerCommInfoHccs, SubCommInfo& outerCommInfoSio, DeviceMem& usrInMem, DeviceMem& usrOutMem,
441 : u64 totalCount, const HcclDataType dataType, const Stream& mainStream, std::vector<Stream>& meshStreams,
442 : std::vector<std::shared_ptr<LocalNotify>>& meshSignal, std::vector<std::shared_ptr<LocalNotify>>& meshSignalAux,
443 : u32 userRank, HcomCollOpInfo* opInfo);
444 :
445 : // Prepare for AlltoAllvContinuousPipeline
446 : virtual HcclResult Prepare(
447 : const u32 userRank, const A2aPipelineMemory& a2aPipelineMemory, const SubCommInfo& level0CommInfo,
448 : const SubCommInfo& level1CommInfo, const Stream& mainStream, std::vector<Stream>& subStream,
449 : std::vector<std::shared_ptr<LocalNotify>>& notifyMain, std::vector<std::shared_ptr<LocalNotify>>& notifySub,
450 : std::vector<SendRecvInfo>& sendRecvInfoList, const HcclDataType dataType, const HcclWorkflowMode workMode);
451 :
452 : /* 12个参数 */
453 : // AlltoAllVFor310P
454 : virtual HcclResult Prepare(
455 : DeviceMem& userInput, DeviceMem& userOutput, DeviceMem& cclInMem, DeviceMem& cclOutMem,
456 : const std::vector<std::shared_ptr<LocalNotify>>& signalMainToSub,
457 : const std::vector<std::shared_ptr<LocalNotify>>& signalSubToMain, Stream& mainStream,
458 : std::vector<Stream>& subStreams, const std::vector<LINK>& links, u32 userRank, u32 userRankSize,
459 : std::vector<SendRecvInfo>& allMeshAggregationSendRecvInfo);
460 :
461 : // AlltoAllVStagedMesh
462 : virtual HcclResult Prepare(
463 : DeviceMem& sendMem, DeviceMem& recvMem, DeviceMem& scratchInputMem, DeviceMem& scratchOutputMem,
464 : StageAlltoAllVAddrInfo& sendAddrInfo, StageAlltoAllVAddrInfo& recvAddrInfo, bool isAlltoAllZCopyMode,
465 : u32 userRank, Stream& mainStream, std::vector<Stream>& subStreams,
466 : std::vector<std::shared_ptr<LocalNotify>>& meshSignalMainToSub,
467 : std::vector<std::shared_ptr<LocalNotify>>& meshSignalSubToMain);
468 :
469 : // ReduceScatterPipeline
470 : virtual HcclResult Prepare(
471 : HcomCollOpInfo* opInfo, DeviceMem& cclBuffer, const u64 count, const u64 bufferSize, const u64 offset,
472 : const SubCommInfo& level0CommInfo, const SubCommInfo& level1CommInfo, Stream& mainStream,
473 : std::vector<Stream>& subStream, std::vector<std::shared_ptr<LocalNotify>>& notifyMain,
474 : std::vector<std::shared_ptr<LocalNotify>>& notifySub, u64 reduceAttrBitMap);
475 :
476 : // ReduceScatterVPipeline
477 : virtual HcclResult Prepare(
478 : HcomCollOpInfo* opInfo, DeviceMem& cclBuffer, const u64 bufferSize, const std::vector<Slice>& slices,
479 : const SubCommInfo& level0CommInfo, const SubCommInfo& level1CommInfo, Stream& mainStream,
480 : std::vector<Stream>& subStream, std::vector<std::shared_ptr<LocalNotify>>& notifyMain,
481 : std::vector<std::shared_ptr<LocalNotify>>& notifySub, u64 reduceAttrBitMap);
482 :
483 : // BroadcastStar
484 : virtual HcclResult Prepare(
485 : DeviceMem& inputMem, DeviceMem& outputMem, DeviceMem& scratchMem, const u64 count, const HcclDataType dataType,
486 : const Stream& stream, const HcclReduceOp reductionOp, const u32 root, const std::vector<Slice>& slices,
487 : const u64 baseOffset, std::vector<u32> nicRankList, u32 userRank);
488 :
489 : // Prepare for AllGatherVPipeline
490 : virtual HcclResult Prepare(
491 : HcomCollOpInfo* opInfo, u32 userRank, u64& count, DeviceMem& cclBufferPartOne, DeviceMem& cclBufferPartTwo,
492 : SubCommInfo& level0CommInfo, SubCommInfo& level1CommInfo, Stream& mainStream, std::vector<Stream>& subStream,
493 : std::vector<std::shared_ptr<LocalNotify>>& notifyMain, std::vector<std::shared_ptr<LocalNotify>>& notifySub,
494 : std::vector<Slice>& userOutSlice);
495 :
496 : /* 13个参数 */
497 : // BroadcastHD
498 : virtual HcclResult Prepare(
499 : DeviceMem& inputMem, DeviceMem& outputMem, DeviceMem& scratchMem, const u64 count, const HcclDataType dataType,
500 : const Stream& stream, const HcclReduceOp reductionOp, const u32 root, std::vector<Stream>& meshStreams,
501 : const std::vector<std::shared_ptr<LocalNotify>>& meshSignal,
502 : const std::vector<std::shared_ptr<LocalNotify>>& meshSignalAux, u32 interRank, const HcomCollOpInfo* opInfo);
503 :
504 : /* 14个参数 */
505 : // ReduceScatterUnifiedMarch
506 : virtual HcclResult Prepare(
507 : Stream& mainStream, SubCommInfo& level0CommInfo, DeviceMem& userInput, DeviceMem& userOutput,
508 : DeviceMem& usrInMem, DeviceMem& scratchMem, u64 totalCount, std::vector<Stream>& subStreams,
509 : const std::vector<std::shared_ptr<LocalNotify>>& meshSignalMainToSub,
510 : const std::vector<std::shared_ptr<LocalNotify>>& meshSignalSubToMain, const HcclDataType dataType,
511 : const HcclReduceOp reductionOp, const std::vector<std::vector<Slice>>& multRingsUserMemSlice,
512 : u64 reduceAttrBitMap);
513 :
514 : // ReduceScatterHalvingDoubling
515 : virtual HcclResult Prepare(
516 : DeviceMem& inputMem, DeviceMem& outputMem, DeviceMem& scratchMem, const u64 count, const HcclDataType dataType,
517 : const Stream& stream, const HcclReduceOp reductionOp, const u32 root, const std::vector<Slice>& slices,
518 : const u64 baseOffset, const u32 blockSize, const u64 reduceAttrBitMap, const UserMemType hdInputMemType,
519 : const UserMemType hdOutputMemType);
520 :
521 : /* 15个参数 */
522 : // AlltoAllVMeshReadOnly
523 : virtual HcclResult Prepare(
524 : DeviceMem& userInput, DeviceMem& userOutput, DeviceMem& scratchPingMem, DeviceMem& scratchPongMem,
525 : StageAlltoAllVAddrInfo& sendAddrInfo, StageAlltoAllVAddrInfo& recvAddrInfo, HcclWorkflowMode workMode,
526 : Stream& mainStream, std::vector<Stream>& subStreams,
527 : const std::vector<std::shared_ptr<LocalNotify>>& meshSignalMainToSub,
528 : const std::vector<std::shared_ptr<LocalNotify>>& meshSignalSubToMain, u32 userRank, u32 intraRankSize,
529 : const std::vector<LINK>& links, std::vector<SendRecvInfo>& allMeshAggregationSendRecvInfo);
530 :
531 : /* 16个参数 */
532 : // ReduceScatterHDStage, ReduceScatterLocalReduce, ReduceScatterMeshAtomic, ReduceScatterMeshDirect
533 : virtual HcclResult Prepare(
534 : DeviceMem& inputMem, DeviceMem& outputMem, DeviceMem& scratchMem, const u64 count, const HcclDataType dataType,
535 : const Stream& stream, const HcclReduceOp reductionOp, const u32 root, const std::vector<Slice>& slices,
536 : const u64 baseOffset, const u64 reduceAttrBitMap, std::vector<Stream>& meshStreams,
537 : std::vector<std::shared_ptr<LocalNotify>>& meshSignal, std::vector<std::shared_ptr<LocalNotify>>& meshSignalAux,
538 : u32 userRank, const HcomCollOpInfo* opInfo = nullptr);
539 :
540 : // ReduceScatterHccsSio
541 : virtual HcclResult Prepare(
542 : DeviceMem& inputMem, DeviceMem& outputMem, DeviceMem& scratchMem, const u64 count, const HcclDataType dataType,
543 : const Stream& stream, const HcclReduceOp reductionOp, const u32 root, const u64 baseOffset,
544 : const u64 reduceAttrBitMap, std::vector<Stream>& meshStreams,
545 : std::vector<std::shared_ptr<LocalNotify>>& meshSignal, std::vector<std::shared_ptr<LocalNotify>>& meshSignalAux,
546 : u32 userRank, SubCommInfo subCommInfoHccs, SubCommInfo subCommInfoSio, HcomCollOpInfo* opInfo);
547 :
548 : /* 17个参数 */
549 : // ReduceScatterMeshMix
550 : virtual HcclResult Prepare(
551 : DeviceMem& inputMem, DeviceMem& outputMem, DeviceMem& scratchMem, const u64 count, const HcclDataType dataType,
552 : const Stream& stream, const HcclReduceOp reductionOp, const u32 root, const std::vector<Slice>& slices,
553 : const u64 baseOffset, const u64 reduceAttrBitMap, std::vector<Stream>& meshStreams,
554 : const std::vector<std::shared_ptr<LocalNotify>>& meshSignal,
555 : const std::vector<std::shared_ptr<LocalNotify>>& meshSignalAux, u32 interRank, u32 interRankSize,
556 : HcomCollOpInfo* opInfo);
557 :
558 : /* 19个参数 */
559 : // AlignedReduceScatterDoubleRing, AlignedReduceScatter, DoubleRingWithSerialLocalCopy
560 : virtual HcclResult Prepare(
561 : DeviceMem& inputMem, DeviceMem& outputMem, DeviceMem& scratchMem, const u64 count, const HcclDataType dataType,
562 : const Stream& stream, const std::vector<std::vector<Slice>>& multRingsSlices, const HcclReduceOp reductionOp,
563 : const u32 root, const u64 baseOffset, const bool disableDMAReduce, const u64 reduceAttrBitMap,
564 : const HcomCollOpInfo* opInfo, const u32 userRank, std::vector<Stream>& subStreams,
565 : const std::vector<std::shared_ptr<LocalNotify>>& mainSignals,
566 : const std::vector<std::shared_ptr<LocalNotify>>& subSignals, const std::vector<std::vector<u32>>& ringsOrders,
567 : const std::vector<std::vector<Slice>>& userMemInputSlicesOfDoubleRing);
568 :
569 : // ReduceScatterDeterPipeline
570 : virtual HcclResult Prepare(
571 : HcomCollOpInfo* opInfo, DeviceMem& buffer, const u64 count, const u64 offset, const std::vector<Slice>& slices,
572 : const SubCommInfo& level0CommInfo, const SubCommInfo& level1CommInfo, Stream& mainStream,
573 : std::vector<Stream>& subStream, std::vector<std::shared_ptr<LocalNotify>>& notifyMain,
574 : std::vector<std::shared_ptr<LocalNotify>>& notifySub);
575 :
576 : // AllReduceDeterPipeline
577 : virtual HcclResult Prepare(
578 : HcomCollOpInfo* opInfo, DeviceMem& inBuffer, DeviceMem& outBuffer, const u64 count,
579 : const std::vector<Slice>& slices, const SubCommInfo& level0CommInfo, const SubCommInfo& level1CommInfo,
580 : Stream& mainStream, std::vector<Stream>& subStream, std::vector<std::shared_ptr<LocalNotify>>& notifyMain,
581 : std::vector<std::shared_ptr<LocalNotify>>& notifySub);
582 :
583 : HcclResult Sum(const std::vector<Slice>& inputSlices, u32 start, u32 num, u64& sizeOut);
584 : HcclResult RegisterProfiler(s32 planeId, s32 stage, s32 step, const Stream& stream);
585 : static HcclResult
586 : ExecEmptyTask(DeviceMem& inputMem, DeviceMem& outputMem, Stream& stream, const HcclDispatcher dispatcher);
587 : HcclResult CheckConcurrentDirectParameters(const u32 rank, const u32 rankSize, const std::vector<LINK>& links);
588 185 : u32 DataUnitSize(HcclDataType dataType) const
589 : {
590 185 : if (dataType >= HCCL_DATA_TYPE_RESERVED) {
591 0 : HCCL_ERROR(
592 : "[AlgTemplateBase][DataUnitSize]data type[%s] out of range[%d, %d]",
593 : GetDataTypeEnumStr(dataType).c_str(), HCCL_DATA_TYPE_INT8, HCCL_DATA_TYPE_RESERVED - 1);
594 0 : return 0;
595 : }
596 :
597 185 : return SIZE_TABLE[dataType];
598 : }
599 :
600 : static std::vector<bool> CalcLinksRelation(
601 : const u32 rank, const u32 rankSize, const u32 rootRank = 0,
602 : HalvingDoublingType algorithmType = HalvingDoublingType::RECURSIVE_HALVING_DOUBLING);
603 :
604 : static HcclResult
605 : PrepareSliceData(u64 dataCount, u32 unitSize, u32 sliceNum, u64 piplineOffset, std::vector<Slice>& dataSlice);
606 : static HcclResult PrepareSliceMeshStreams(
607 : const std::vector<Slice>& rankSegsSlice, u32 streamCount, std::vector<std::vector<Slice>>& mutliStreamsSlices);
608 :
609 136 : static inline u64 RoundUpWithDivisor(u64 value, u64 divisor)
610 : {
611 136 : if ((value == 0) || (divisor == 0)) {
612 0 : return divisor;
613 : }
614 : // divisor必须大于等于1, 返回value向上取divisor的整数倍的值
615 136 : return ((value + (divisor - 1)) / divisor) * divisor;
616 : }
617 : inline u64 ByteOffset(u64 countOffset) const { return countOffset * DataUnitSize(dataType_); }
618 : inline u64 SliceOffset(u32 sliceIndex, u64 countPerSlice) const
619 : {
620 : return sliceIndex * countPerSlice * DataUnitSize(dataType_);
621 : }
622 1 : inline void CloseBarrier() { barrierSwitchOn_ = false; }
623 : virtual HcclResult
624 : GetNslbAdjInfo(const u32 rank, const u32 rankSize, const std::vector<LINK>& links, AdjInfo& nslbAdjInfo);
625 :
626 : // 只用于alltoallv类算子的aicpu cache
627 : virtual HcclResult
628 : GetHcclOffsetDstRanksMap(std::unordered_map<uint64_t, std::vector<uint32_t>>& hcclOffsetDstRanksMap) const;
629 :
630 : protected:
631 : HcclResult ExecuteBarrier(const std::shared_ptr<Transport>& preLink, const std::shared_ptr<Transport>& aftLink);
632 : HcclResult ExecuteBarrier(
633 : const std::shared_ptr<Transport>& preLink, const std::shared_ptr<Transport>& aftLink, Stream& stream);
634 : HcclResult
635 : ExecuteBarrier(const std::shared_ptr<Transport>& preLink, const std::shared_ptr<Transport>& aftLink, u32 notifyIdx);
636 : HcclResult ExecuteBarrier(
637 : const std::shared_ptr<Transport>& preLink, const std::shared_ptr<Transport>& aftLink, u32 notifyIdx,
638 : Stream& stream);
639 : HcclResult ExecuteBarrier(std::shared_ptr<Transport> link, Stream& stream);
640 : HcclResult ExecuteRxSync(
641 : std::shared_ptr<Transport> link, UserMemType srcMemType, u64 srcOffset, void* dst, u64 len,
642 : Stream& stream) const;
643 : HcclResult ExecuteTxSync(
644 : std::shared_ptr<Transport> link, UserMemType dstMemType, u64 dstOffset, void* src, u64 len,
645 : Stream& stream) const;
646 : virtual HcclResult
647 : PrepareRunAsync(const u32 rank, const u32 rankSize, const std::vector<std::shared_ptr<Transport>>& links);
648 : const HcclDispatcher dispatcher_;
649 : std::vector<Slice> slicesDummy_;
650 : std::vector<Slice>& slices_;
651 : DeviceMem inputMem_; /* * 输入memory */
652 : DeviceMem outputMem_; /* * 输出memory */
653 : DeviceMem scratchMem_; /* * 草稿memory */
654 :
655 : u64 count_; // 需处理的每块memory数据总个数
656 : u64 dataBytes_; // 数据所占的字节数
657 : HcclDataType dataType_;
658 : HcclReduceOp reductionOp_;
659 : u32 root_;
660 : bool disableDMAReduce_;
661 :
662 : // Added on Mar.24th, for profiling template
663 : StepData profilerInput_;
664 : u64 baseOffset_;
665 :
666 : Stream stream_;
667 :
668 : // 用于chunk算法
669 : std::vector<u32> nicRankList_;
670 : std::vector<std::vector<u32>> rankSliceLists_;
671 : bool barrierSwitchOn_;
672 : // 用于91093 aligend double ring算法
673 : std::vector<std::vector<Slice>> multRingsSlices_;
674 : AlgOpContext algOpContext_;
675 :
676 : private:
677 : static void CalcBinaryBlockParams(
678 : u32 rank, u32 rankSize, u32& stepsInBlock, u32& lowerBlockSize, u32& myBlockSize, u32& rankInMyBlock,
679 : u32& myBlockOffset, u32& higherBlockSize);
680 : static HcclResult
681 : CalcBinaryBlockHalvingDoubleLinkReleation(u32 rank, u32 rankSize, std::vector<bool>& linkRelation);
682 :
683 : static void CalcLinkInBlock(u32 blockSize, u32 rankInBlock, std::list<u32>& linkRankIndexInBlock);
684 : static void CalcLinkBetweenParts(
685 : u32 part1Size, std::list<u32>& linkRankIndexInBlock, std::list<u32>& linkRankIndex, bool oddRank);
686 : static void
687 : CalcRecursiveHalvingDobuleLinkReleation(u32 rank, u32 rankSize, u32 rootRank, std::vector<bool>& linkRelation);
688 : static void
689 : CalcRecursiveHdLinkRelationForFirstScene(u32 rank, u32 part1Size, u32 blockSize, std::vector<bool>& linkRelation);
690 : static void
691 : CalcRecursiveHdLinkRelationForSecondScene(u32 rank, u32 part1Size, u32 blockSize, std::vector<bool>& linkRelation);
692 : };
693 : using AlgTemplateBase = ExecutorBase;
694 : } // namespace hccl
695 :
696 : #endif /* EXECUTOR_BASE_PUB_H */
|