LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/base/alg_template - alg_template_base_pub.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 75.0 % 12 9
Test Date: 2026-07-28 12:11:00 Functions: 100.0 % 3 3

            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 {
     181              :     SLICE_TYPE_TX,
     182              :     SLICE_TYPE_RX
     183              : };
     184              : 
     185              : using GroupSlicesInfo = std::vector<MemBlockInfo>;
     186              : 
     187              : enum class HalvingDoublingType {
     188              :     BINARY_BLOCK_HALVING_DOUBLING,
     189              :     RECURSIVE_HALVING_DOUBLING,
     190              :     RESERVED_ALGORITHM_TYPE
     191              : };
     192              : 
     193              : using SliceType = enum SliceType;
     194              : 
     195              : enum class RunStage {
     196              :     RUN_PREPARE,
     197              :     RUN_REDUCE_SCATTER,
     198              :     RUN_ALLGATHER,
     199              :     RUN_ALLREDUCE,
     200              :     RUN_DEFAULT
     201              : };
     202              : 
     203              : struct PrepareData {
     204              :     u32 root = INVALID_VALUE_RANKID;
     205              :     u32 userRank = INVALID_VALUE_RANKID;
     206              :     u32 userRankSize = 0;
     207              :     u32 interRank = INVALID_VALUE_RANKID;
     208              :     u32 interRankSize = 0;
     209              : 
     210              :     u64 count = 0;
     211              :     HcclDataType dataType = HCCL_DATA_TYPE_RESERVED;
     212              :     HcclReduceOp reductionOp = HCCL_REDUCE_RESERVED;
     213              :     u64 baseOffset = 0;
     214              : 
     215              :     DeviceMem inputMem;
     216              :     DeviceMem outputMem;
     217              :     DeviceMem scratchMem;
     218              :     DeviceMem cclInMem;
     219              :     DeviceMem cclOutMem;
     220              : 
     221              :     Stream stream;
     222              :     const std::vector<Stream>* subStreamsPtr = nullptr;
     223              :     const std::vector<std::shared_ptr<LocalNotify>>* signalPtr = nullptr;
     224              :     const std::vector<std::shared_ptr<LocalNotify>>* signalAuxPtr = nullptr;
     225              : 
     226              :     const std::vector<LINK>* linksPtr = nullptr;
     227              :     const std::vector<Slice>* slicesPtr = nullptr;
     228              :     const std::vector<std::vector<Slice>>* multRingsSlicesPtr = nullptr;
     229              :     const std::vector<u32>* nicRankListPtr = nullptr;
     230              : 
     231              :     HcclWorkflowMode workMode = HcclWorkflowMode::HCCL_WORKFLOW_MODE_RESERVED;
     232              :     HcomCollOpInfo *opInfo = nullptr;
     233              :     bool disableDMAReduce = false;
     234              :     bool isSuPodAsym = false;
     235              :     HcclCMDType opType = HcclCMDType::HCCL_CMD_INVALID;
     236              : 
     237              :     const SendRecvInfo *localSendRecvInfoPtr = nullptr;
     238              :     const ZCopySendRecvInfo *sendRecvInfoPtr = nullptr;
     239              :     u32 devNumInlocalPod = 0;
     240              :     u32 rankIdxInPod = 0;
     241              :     u64 reduceAttr = 0;
     242              : 
     243              :     AlgOpContext algOpContext;
     244              : 
     245              :     bool needAlltoallvCache = false; // 用于alltoallv类算子的aicpu cache
     246              : };
     247              : 
     248              : struct HcclTopoInfo;
     249              : class TopoMatcher;
     250              : class ExecutorBase {
     251              : public:
     252              :     explicit ExecutorBase(const HcclDispatcher dispatcher);
     253              :     virtual ~ExecutorBase();
     254              : 
     255              :     virtual HcclResult RunAsync();
     256              :     virtual HcclResult RunAsync(const u32 rank, const u32 rankSize,
     257              :         const std::vector<std::shared_ptr<Transport> > &links);
     258              :     virtual HcclResult RunAsyncStaged(const u32 rank, const u32 rankSize,
     259              :         const std::vector<std::shared_ptr<Transport> > &links, RunStage stage);
     260              :      /* 12个参数 */
     261              :     virtual HcclResult Prepare(DeviceMem &inputMem, DeviceMem &outputMem, DeviceMem &scratchMem, const u64 count,
     262              :                          const HcclDataType dataType, const Stream &stream,
     263              :                          const HcclReduceOp reductionOp = HCCL_REDUCE_RESERVED,
     264              :                          const u32 root = INVALID_VALUE_RANKID,
     265              :                          const std::vector<Slice> &slices = std::vector<Slice>(ZERO_SLICE),
     266              :                          const u64 baseOffset = 0, std::vector<u32> nicRankList = {0, 1, 2, 3, 4, 5, 6, 7},
     267              :                          const bool disableDMAReduce = false);
     268              :     
     269              :     /* 11个参数 */
     270              :     virtual HcclResult Prepare(DeviceMem &inputMem, DeviceMem &scratchMem, const u64 count,
     271              :                          const HcclDataType dataType,
     272              :                          const Stream &stream, const HcclReduceOp reductionOp = HCCL_REDUCE_RESERVED,
     273              :                          const u32 root = INVALID_VALUE_RANKID,
     274              :                          const std::vector<Slice> &slices = std::vector<Slice>(ZERO_SLICE),
     275              :                          const u64 baseOffset = 0, std::vector<u32> nicRankList = {0, 1, 2, 3, 4, 5, 6, 7},
     276              :                          const bool disableDMAReduce = false);
     277              : 
     278              :     virtual HcclResult Prepare(DeviceMem &inputMem, DeviceMem &outputMem, DeviceMem &scratchMem, const u64 count,
     279              :                         const HcclDataType dataType, const Stream &stream,
     280              :                         const std::vector<std::vector<Slice>> &multRingsSlices,
     281              :                         const HcclReduceOp reductionOp = HCCL_REDUCE_RESERVED,
     282              :                         const u32 root = INVALID_VALUE_RANKID,
     283              :                         const u64 baseOffset = 0,
     284              :                         const bool disableDMAReduce = false);
     285              : 
     286              :     virtual HcclResult Prepare(PrepareData &param);
     287              : 
     288              :     /* 1个参数 */
     289              :     // AllGatherNHR, ScatterNHR
     290              :     virtual HcclResult Prepare(bool needSaveRankMap);
     291              : 
     292              :     // AHC 扩展参数
     293              :     virtual HcclResult Prepare(AHCExtendPreparePara &extendParam);
     294              : 
     295              :     // GatherStar
     296              :     virtual HcclResult Prepare(u32 userRank);
     297              : 
     298              :     /* 2个参数 */
     299              :     // ReduceScatterNB, ReduceScatterNHRV1, ReduceScatterRing, ReduceScatterRecursiveHalvingDoubling
     300              :     virtual HcclResult Prepare(u64 reduceAttrBitMap, HcomCollOpInfo *opInfo = nullptr);
     301              : 
     302              :     // ReduceScatterNHR
     303              :     virtual HcclResult Prepare(u64 reduceAttrBitMap, bool needMerge);
     304              : 
     305              :     // ReduceScatterMeshMixSingleStream, ReduceScatterMesh
     306              :     virtual HcclResult Prepare(u64 reduceAttrBitMap, u32 streamIndex);
     307              : 
     308              :     // ScatterMesh
     309              :     virtual HcclResult Prepare(u32 interRank, u32 interRankSize);
     310              : 
     311              :     /* 3个参数 */
     312              :     // for AllGatherHalvingDoubling based on input_scratch_Mem_nicRankList Prepare
     313              :     // and should be called soon template AllGatherHalvingDoubling created
     314              :     virtual HcclResult Prepare(u32 blockSize, UserMemType hdInputMemType, UserMemType hdOutputMemType);
     315              : 
     316              :     /* 4个参数 */
     317              :     // ScatterRingDirect
     318              :     virtual HcclResult Prepare(HcomCollOpInfo *opInfo, const u32 userRank, const std::vector<u32> &ringsOrders,
     319              :          const std::vector<Slice> &userMemInputSlices);
     320              : 
     321              :     // AllGatherRingDirect
     322              :     virtual HcclResult Prepare(HcomCollOpInfo *opInfo, u32 userRank,
     323              :         const std::vector<Slice> &userMemOutputSlices, bool isSdma = true);
     324              : 
     325              :     /* 5个参数 */
     326              :     // AHC 5个参数,带扩展参数
     327              :     virtual HcclResult Prepare(u64 totalCount, const std::vector<std::vector<std::vector<u32>>> &subGroups,
     328              :         std::map<AHCConcOpType, TemplateType> &ahcAlgOption, bool extendFlag = false,
     329              :         AHCExtendPreparePara extendPara = AHCExtendPreparePara());
     330              : 
     331              :     /* 6个参数 */
     332              :     // AlltoAllVStagedPairwise
     333              :     virtual HcclResult Prepare(DeviceMem &sendMem, DeviceMem &recvMem, StageAlltoAllVAddrInfo &sendAddrInfo, 
     334              :         StageAlltoAllVAddrInfo &recvAddrInfo, bool isAlltoAllZCopyMode, Stream &mainStream);
     335              : 
     336              :     /* 7个参数 */
     337              :     virtual HcclResult Prepare(u64 reduceAttrBitMap, std::vector<Stream> &meshStreams, 
     338              :         std::vector<std::shared_ptr<LocalNotify>> &meshSignal, std::vector<std::shared_ptr<LocalNotify>> &meshSignalAux, 
     339              :         u32 userRank, HcomCollOpInfo *opInfo, bool aicpu);
     340              : 
     341              :     // AlltoAllVPairWise
     342              :     virtual HcclResult Prepare(AlltoAllVBufferInfo &sendBuffer, AlltoAllVBufferInfo &recvBuffer, 
     343              :         bool isAlltoAllZCopyMode, const Stream &stream, HcclWorkflowMode workMode, 
     344              :         std::map<u32, std::vector<u64>> &rankSendDisplsMap, std::map<u32, std::vector<u64>> &rankRecvDisplsMap);
     345              : 
     346              :     // AlignedAllGatherDoubleRing
     347              :     virtual HcclResult Prepare(HcomCollOpInfo *opInfo, const u32 userRank, std::vector<Stream> &subStreams, 
     348              :         std::vector<std::shared_ptr<LocalNotify>> &mainSignals, std::vector<std::shared_ptr<LocalNotify>> &subSignals, 
     349              :         const std::vector<std::vector<u32>> &ringsOrders, 
     350              :         const std::vector<std::vector<Slice>> &userMemOutputSlicesOfDoubleRing);
     351              : 
     352              :     // AllGatherMeshAtomic, AllgatherMeshDirect, AllGatherMesh, AllGatherMeshMix, GatherMesh
     353              :     virtual HcclResult Prepare(std::vector<Stream> &meshStreams, std::vector<std::shared_ptr<LocalNotify>> &meshSignal, 
     354              :         std::vector<std::shared_ptr<LocalNotify>> &meshSignalAux, u32 userRank = INVALID_VALUE_RANKID, 
     355              :         HcomCollOpInfo *opInfo = nullptr, u32 interRank = INVALID_VALUE_RANKID, u32 interRankSize = 0);
     356              : 
     357              :     /* 8个参数 */
     358              :     virtual HcclResult Prepare(u64 reduceAttrBitMap, std::vector<Stream> &meshStreams, 
     359              :         std::vector<std::shared_ptr<LocalNotify>> &meshSignal, std::vector<std::shared_ptr<LocalNotify>> &meshSignalAux, 
     360              :         u32 interRank, u32 interRankSize, u32 userRank, HcomCollOpInfo *opInfo);
     361              : 
     362              :     // AlltoAllVStagedPairwise
     363              :     virtual HcclResult Prepare(DeviceMem &sendMem, DeviceMem &recvMem, DeviceMem &scratchInputMem, 
     364              :         DeviceMem &scratchOutputMem, StageAlltoAllVAddrInfo &sendAddrInfo, StageAlltoAllVAddrInfo &recvAddrInfo, 
     365              :         bool isAlltoAllZCopyMode, Stream &mainStream);
     366              : 
     367              :     // AllGatherRingConcurrentDirect ScatterRingConcurrentDirect
     368              :     virtual HcclResult Prepare(HcomCollOpInfo *opInfo, const u32 userRank, std::vector<Stream> &subStreams, 
     369              :         const std::vector<std::shared_ptr<LocalNotify>> &mainSignals, 
     370              :         const std::vector<std::shared_ptr<LocalNotify>> &subSignals, const std::vector<u32> &ringsOrder, 
     371              :         const std::vector<Slice> &userMemSlices, bool isSdma = true);
     372              : 
     373              :     /* 9个参数 */
     374              :     // scatterDoubleRingDirect
     375              :     virtual HcclResult Prepare(HcomCollOpInfo *opInfo, const u32 userRank, const u32 subRingRank, 
     376              :         std::vector<Stream> &subStreams, const std::vector<std::shared_ptr<LocalNotify>> &mainSignals, 
     377              :         const std::vector<std::shared_ptr<LocalNotify>> &subSignals, const std::vector<std::vector<u32>> &ringsOrders, 
     378              :         const std::vector<std::vector<Slice>> &multiRingSlices, 
     379              :         const std::vector<std::vector<Slice>> &userMemInputSlices);
     380              :     
     381              :     // ReduceScatterRingConcurrentDirect
     382              :     virtual HcclResult Prepare(const u64 reduceAttrBitMap, const HcomCollOpInfo *opInfo, const u32 userRank, 
     383              :         std::vector<Stream> &subStreams, const std::vector<std::shared_ptr<LocalNotify>> &mainSignals, 
     384              :         const std::vector<std::shared_ptr<LocalNotify>> &subSignals, const std::vector<u32> &ringsOrder, 
     385              :         const std::vector<Slice> &userMemInputSlices, bool isSdma = true);
     386              : 
     387              :     // AlltoAllVPairWise
     388              :     virtual HcclResult Prepare(AlltoAllVBufferInfo &sendBuffer, AlltoAllVBufferInfo &recvBuffer, 
     389              :         DeviceMem &scratchInputMem, DeviceMem &scratchOutputMem, bool isAlltoAllZCopyMode, const Stream &stream, 
     390              :         HcclWorkflowMode workMode, std::map<u32, std::vector<u64>> &rankSendDisplsMap, 
     391              :         std::map<u32, std::vector<u64>> &rankRecvDisplsMap);
     392              :     
     393              :     /* 10个参数 */
     394              :     virtual HcclResult Prepare(const HcomCollOpInfo *opInfo, DeviceMem &cclBufferA, DeviceMem &cclBufferB, 
     395              :         const u64 count, const SubCommInfo &level1CommInfo, const SubCommInfo &level0CommInfo, Stream &mainStream, 
     396              :         std::vector<Stream> &subStream, std::vector<std::shared_ptr<LocalNotify>> &notifyMain, 
     397              :         std::vector<std::shared_ptr<LocalNotify>> &notifySub);
     398              :     
     399              :     // AlltoAllPipelineMeshPairwiseCCLEnough, AlltoAllPipelineMeshPairwisePingPong
     400              :     virtual HcclResult Prepare(u32 userRank, A2aPipelineMemory A2aPipelineMemory, const SubCommInfo &level0CommInfo, 
     401              :         const SubCommInfo &level1CommInfo, Stream &mainStream, std::vector<Stream> &subStream,
     402              :         std::vector<std::shared_ptr<LocalNotify>> &notifyMain, std::vector<std::shared_ptr<LocalNotify>> &notifySub, 
     403              :         std::vector<SendRecvInfo> &allMeshAggregationSendRecvInfo, 
     404              :         HcclWorkflowMode workMode = HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE);
     405              : 
     406              :     // AlltoAllVSatgedMesh
     407              :     virtual HcclResult Prepare(DeviceMem &sendMem, DeviceMem &recvMem, StageAlltoAllVAddrInfo &sendAddrInfo, 
     408              :         StageAlltoAllVAddrInfo &recvAddrInfo, bool isAlltoAllZCopyMode, u32 userRank, Stream &mainStream, 
     409              :         std::vector<Stream> &subStreams, std::vector<std::shared_ptr<LocalNotify>> &meshSignalMainToSub, 
     410              :         std::vector<std::shared_ptr<LocalNotify>> &meshSignalSubToMain);
     411              : 
     412              :     // ReduceScatterPlantLocalReduce
     413              :     virtual HcclResult Prepare(void *inputMemPtr, DeviceMem &cclInMem, DeviceMem &outputMem,
     414              :         const Stream &stream, std::vector<Stream> &subStreams, 
     415              :         std::vector<std::shared_ptr<LocalNotify>> &meshSignal, std::vector<std::shared_ptr<LocalNotify>> &meshSignalAux,
     416              :         GroupSlicesInfo &grouSlicesInfo, const HcclReduceOp reductionOp, u32 all2allOffset, const HcclDataType dataType,
     417              :         bool isNeedSpaceBorrow, bool reverseMemUsage = false, bool isA3CrossNode = false);
     418              : 
     419              :     // ReduceScatterPlantLocalReduceCombine
     420              :     virtual HcclResult Prepare(DeviceMem &cclInMem, DeviceMem &outputMem,
     421              :         const Stream &stream, std::vector<Stream> &subStreams, std::vector<std::shared_ptr<LocalNotify>> &meshSignal,
     422              :         std::vector<std::shared_ptr<LocalNotify>> &meshSignalAux, MemBlockInfo &memBlockInfo,
     423              :         const HcclReduceOp reductionOp, const HcclDataType dataType, bool isUseCclIn, bool isLevel0LastRank, bool isNeedSpaceBorrow);
     424              :     
     425              :     /* 11个参数 */
     426              :     // Prepare for AllGatherPipeline
     427              :     virtual HcclResult Prepare(HcomCollOpInfo *opInfo, u32 userRank, u64 &count, DeviceMem &cclBufferPartOne, 
     428              :         DeviceMem &cclBufferPartTwo, SubCommInfo &level0CommInfo, SubCommInfo &level1CommInfo, Stream &mainStream, 
     429              :         std::vector<Stream> &subStream, std::vector<std::shared_ptr<LocalNotify>> &notifyMain,
     430              :         std::vector<std::shared_ptr<LocalNotify>> &notifySub);
     431              : 
     432              :     // Prepare for AllGatherUnifiedMarch
     433              :     virtual HcclResult Prepare(const Stream &mainStream, SubCommInfo &level0CommInfo, DeviceMem &userInput, 
     434              :         DeviceMem &userOutput, DeviceMem &usrInMem, DeviceMem &usrOutMem, u64 blockDataByte,
     435              :         std::vector<Stream> &subStreams, const std::vector<std::shared_ptr<LocalNotify>> &meshSignalMainToSub, 
     436              :         const std::vector<std::shared_ptr<LocalNotify>> &meshSignalSubToMain,
     437              :         const std::vector<std::vector<Slice>> &multRingsUserMemSlice, const u64 baseOffset = 0);
     438              : 
     439              :     // Prepare for AllGatherHccsSio
     440              :     virtual HcclResult Prepare(SubCommInfo &outerCommInfoHccs, SubCommInfo &outerCommInfoSio, DeviceMem &usrInMem,
     441              :         DeviceMem &usrOutMem, u64 totalCount, const HcclDataType dataType, const Stream &mainStream,
     442              :         std::vector<Stream> &meshStreams, std::vector<std::shared_ptr<LocalNotify>> &meshSignal,
     443              :         std::vector<std::shared_ptr<LocalNotify>> &meshSignalAux, u32 userRank, HcomCollOpInfo *opInfo);
     444              :     
     445              :     // Prepare for AlltoAllvContinuousPipeline
     446              :     virtual HcclResult Prepare(const u32 userRank, const A2aPipelineMemory &a2aPipelineMemory,
     447              :         const SubCommInfo &level0CommInfo, const SubCommInfo &level1CommInfo,
     448              :         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,
     451              :         const HcclWorkflowMode workMode);
     452              : 
     453              :     /* 12个参数 */
     454              :     // AlltoAllVFor310P
     455              :     virtual HcclResult Prepare(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(DeviceMem &sendMem, DeviceMem &recvMem, DeviceMem &scratchInputMem, 
     463              :         DeviceMem &scratchOutputMem, StageAlltoAllVAddrInfo &sendAddrInfo, StageAlltoAllVAddrInfo &recvAddrInfo, 
     464              :         bool isAlltoAllZCopyMode, u32 userRank, Stream &mainStream, std::vector<Stream> &subStreams,
     465              :         std::vector<std::shared_ptr<LocalNotify>> &meshSignalMainToSub,
     466              :         std::vector<std::shared_ptr<LocalNotify>> &meshSignalSubToMain);
     467              : 
     468              :     // ReduceScatterPipeline
     469              :     virtual HcclResult Prepare(HcomCollOpInfo *opInfo, DeviceMem &cclBuffer, const u64 count, const u64 bufferSize,
     470              :         const u64 offset, const SubCommInfo &level0CommInfo, const SubCommInfo &level1CommInfo, Stream &mainStream,
     471              :         std::vector<Stream> &subStream, std::vector<std::shared_ptr<LocalNotify>> &notifyMain, 
     472              :         std::vector<std::shared_ptr<LocalNotify>> &notifySub, u64 reduceAttrBitMap);
     473              :     
     474              :     // ReduceScatterVPipeline
     475              :     virtual HcclResult Prepare(HcomCollOpInfo *opInfo, DeviceMem &cclBuffer, const u64 bufferSize,
     476              :         const std::vector<Slice> &slices, const SubCommInfo &level0CommInfo, const SubCommInfo &level1CommInfo,
     477              :         Stream &mainStream, std::vector<Stream> &subStream,
     478              :         std::vector<std::shared_ptr<LocalNotify>> &notifyMain,
     479              :         std::vector<std::shared_ptr<LocalNotify>> &notifySub,
     480              :         u64 reduceAttrBitMap);
     481              : 
     482              :     // BroadcastStar
     483              :     virtual HcclResult Prepare(DeviceMem &inputMem, DeviceMem &outputMem, DeviceMem &scratchMem, const u64 count,
     484              :         const HcclDataType dataType, const Stream &stream, const HcclReduceOp reductionOp, const u32 root, 
     485              :         const std::vector<Slice> &slices, const u64 baseOffset, std::vector<u32> nicRankList, u32 userRank);
     486              : 
     487              :     // Prepare for AllGatherVPipeline
     488              :     virtual HcclResult Prepare(HcomCollOpInfo *opInfo, u32 userRank, u64 &count, DeviceMem &cclBufferPartOne, 
     489              :         DeviceMem &cclBufferPartTwo, SubCommInfo &level0CommInfo, SubCommInfo &level1CommInfo, Stream &mainStream, 
     490              :         std::vector<Stream> &subStream, std::vector<std::shared_ptr<LocalNotify>> &notifyMain,
     491              :         std::vector<std::shared_ptr<LocalNotify>> &notifySub, std::vector<Slice>& userOutSlice);
     492              : 
     493              :     /* 13个参数 */
     494              :     // BroadcastHD
     495              :     virtual HcclResult Prepare(DeviceMem &inputMem, DeviceMem &outputMem, DeviceMem &scratchMem, const u64 count,
     496              :         const HcclDataType dataType, const Stream &stream, const HcclReduceOp reductionOp, const u32 root,
     497              :         std::vector<Stream> &meshStreams, const std::vector<std::shared_ptr<LocalNotify>> &meshSignal,
     498              :         const std::vector<std::shared_ptr<LocalNotify>> &meshSignalAux, u32 interRank, const HcomCollOpInfo *opInfo);
     499              : 
     500              :     /* 14个参数 */
     501              :     // ReduceScatterUnifiedMarch
     502              :     virtual HcclResult Prepare(Stream &mainStream, SubCommInfo &level0CommInfo, DeviceMem &userInput,
     503              :         DeviceMem &userOutput, DeviceMem &usrInMem, DeviceMem &scratchMem, u64 totalCount,
     504              :         std::vector<Stream> &subStreams, const std::vector<std::shared_ptr<LocalNotify>> &meshSignalMainToSub,
     505              :         const std::vector<std::shared_ptr<LocalNotify>> &meshSignalSubToMain, const HcclDataType dataType,
     506              :         const HcclReduceOp reductionOp, const std::vector<std::vector<Slice>> &multRingsUserMemSlice,
     507              :         u64 reduceAttrBitMap);
     508              : 
     509              :     // ReduceScatterHalvingDoubling
     510              :     virtual HcclResult Prepare(DeviceMem &inputMem, DeviceMem &outputMem, DeviceMem &scratchMem, const u64 count,
     511              :         const HcclDataType dataType, const Stream &stream, const HcclReduceOp reductionOp, const u32 root,
     512              :         const std::vector<Slice> &slices, const u64 baseOffset, const u32 blockSize, const u64 reduceAttrBitMap,
     513              :         const UserMemType hdInputMemType, const UserMemType hdOutputMemType);
     514              : 
     515              :     /* 15个参数 */
     516              :     // AlltoAllVMeshReadOnly
     517              :     virtual HcclResult Prepare(DeviceMem &userInput, DeviceMem &userOutput, DeviceMem &scratchPingMem, 
     518              :         DeviceMem &scratchPongMem, StageAlltoAllVAddrInfo &sendAddrInfo, StageAlltoAllVAddrInfo &recvAddrInfo,
     519              :         HcclWorkflowMode workMode, Stream &mainStream, std::vector<Stream> &subStreams, 
     520              :         const std::vector<std::shared_ptr<LocalNotify>> &meshSignalMainToSub,
     521              :         const std::vector<std::shared_ptr<LocalNotify>> &meshSignalSubToMain, u32 userRank, u32 intraRankSize,
     522              :         const std::vector<LINK> &links, std::vector<SendRecvInfo> &allMeshAggregationSendRecvInfo);
     523              : 
     524              :     /* 16个参数 */
     525              :     // ReduceScatterHDStage, ReduceScatterLocalReduce, ReduceScatterMeshAtomic, ReduceScatterMeshDirect
     526              :     virtual HcclResult Prepare(DeviceMem &inputMem, DeviceMem &outputMem, DeviceMem &scratchMem, const u64 count,
     527              :         const HcclDataType dataType, const Stream &stream, const HcclReduceOp reductionOp, const u32 root,
     528              :         const std::vector<Slice> &slices, const u64 baseOffset, const u64 reduceAttrBitMap,
     529              :         std::vector<Stream> &meshStreams, std::vector<std::shared_ptr<LocalNotify>> &meshSignal,
     530              :         std::vector<std::shared_ptr<LocalNotify>> &meshSignalAux, u32 userRank, const HcomCollOpInfo *opInfo = nullptr);
     531              : 
     532              :     //ReduceScatterHccsSio
     533              :     virtual HcclResult Prepare(DeviceMem &inputMem, DeviceMem &outputMem, DeviceMem &scratchMem, const u64 count,
     534              :         const HcclDataType dataType, const Stream &stream, const HcclReduceOp reductionOp, 
     535              :         const u32 root,  const u64 baseOffset, 
     536              :         const u64 reduceAttrBitMap, std::vector<Stream> &meshStreams, 
     537              :         std::vector<std::shared_ptr<LocalNotify>> &meshSignal, 
     538              :         std::vector<std::shared_ptr<LocalNotify>> &meshSignalAux, 
     539              :         u32 userRank, SubCommInfo subCommInfoHccs, SubCommInfo subCommInfoSio, HcomCollOpInfo *opInfo);
     540              : 
     541              :     /* 17个参数 */
     542              :     // ReduceScatterMeshMix
     543              :     virtual HcclResult Prepare(DeviceMem &inputMem, DeviceMem &outputMem, DeviceMem &scratchMem, const u64 count,
     544              :         const HcclDataType dataType, const Stream &stream, const HcclReduceOp reductionOp, const u32 root,
     545              :         const std::vector<Slice> &slices, const u64 baseOffset, const u64 reduceAttrBitMap,
     546              :         std::vector<Stream> &meshStreams,  const std::vector<std::shared_ptr<LocalNotify>> &meshSignal,
     547              :         const std::vector<std::shared_ptr<LocalNotify>> &meshSignalAux, u32 interRank, u32 interRankSize,
     548              :         HcomCollOpInfo *opInfo);
     549              : 
     550              :     /* 19个参数 */
     551              :     // AlignedReduceScatterDoubleRing, AlignedReduceScatter, DoubleRingWithSerialLocalCopy
     552              :     virtual HcclResult Prepare(DeviceMem &inputMem, DeviceMem &outputMem, DeviceMem &scratchMem, const u64 count,
     553              :         const HcclDataType dataType, const Stream &stream, const std::vector<std::vector<Slice>> &multRingsSlices,
     554              :         const HcclReduceOp reductionOp, const u32 root, const u64 baseOffset, const bool disableDMAReduce,
     555              :         const u64 reduceAttrBitMap, const HcomCollOpInfo *opInfo, const u32 userRank, std::vector<Stream> &subStreams,
     556              :         const std::vector<std::shared_ptr<LocalNotify>> &mainSignals,
     557              :         const std::vector<std::shared_ptr<LocalNotify>> &subSignals, const std::vector<std::vector<u32>> &ringsOrders,
     558              :         const std::vector<std::vector<Slice>> &userMemInputSlicesOfDoubleRing);
     559              : 
     560              :     // ReduceScatterDeterPipeline
     561              :     virtual HcclResult Prepare(HcomCollOpInfo *opInfo, DeviceMem &buffer, const u64 count,
     562              :         const u64 offset, const std::vector<Slice> &slices, const SubCommInfo &level0CommInfo,
     563              :         const SubCommInfo &level1CommInfo, Stream &mainStream, std::vector<Stream> &subStream,
     564              :         std::vector<std::shared_ptr<LocalNotify>> &notifyMain, std::vector<std::shared_ptr<LocalNotify>> &notifySub);
     565              : 
     566              :     // AllReduceDeterPipeline
     567              :     virtual HcclResult Prepare(HcomCollOpInfo *opInfo, DeviceMem &inBuffer, DeviceMem &outBuffer, const u64 count,
     568              :         const std::vector<Slice> &slices, const SubCommInfo &level0CommInfo,
     569              :         const SubCommInfo &level1CommInfo, Stream &mainStream, std::vector<Stream> &subStream,
     570              :         std::vector<std::shared_ptr<LocalNotify>> &notifyMain, std::vector<std::shared_ptr<LocalNotify>> &notifySub);
     571              : 
     572              :     HcclResult Sum(const std::vector<Slice> &inputSlices, u32 start, u32 num, u64 &sizeOut);
     573              :     HcclResult RegisterProfiler(s32 planeId, s32 stage, s32 step, const Stream &stream);
     574              :     static HcclResult ExecEmptyTask(DeviceMem &inputMem, DeviceMem &outputMem, Stream &stream,
     575              :         const HcclDispatcher dispatcher);
     576              :     HcclResult CheckConcurrentDirectParameters(const u32 rank, const u32 rankSize, const std::vector<LINK> &links);
     577          185 :     u32 DataUnitSize(HcclDataType dataType) const
     578              :     {
     579          185 :         if (dataType >= HCCL_DATA_TYPE_RESERVED) {
     580            0 :             HCCL_ERROR("[AlgTemplateBase][DataUnitSize]data type[%s] out of range[%d, %d]",
     581              :                 GetDataTypeEnumStr(dataType).c_str(), HCCL_DATA_TYPE_INT8, HCCL_DATA_TYPE_RESERVED - 1);
     582            0 :             return 0;
     583              :         }
     584              : 
     585          185 :         return SIZE_TABLE[dataType];
     586              :     }
     587              : 
     588              :     static std::vector<bool> CalcLinksRelation(const u32 rank, const u32 rankSize, const u32 rootRank = 0,
     589              :         HalvingDoublingType algorithmType = HalvingDoublingType::RECURSIVE_HALVING_DOUBLING);
     590              : 
     591              :     static HcclResult PrepareSliceData(u64 dataCount, u32 unitSize, u32 sliceNum, u64 piplineOffset,
     592              :         std::vector<Slice> &dataSlice);
     593              :     static HcclResult PrepareSliceMeshStreams(const std::vector<Slice> &rankSegsSlice, u32 streamCount,
     594              :         std::vector<std::vector<Slice>> &mutliStreamsSlices);
     595              : 
     596          136 :     static inline u64 RoundUpWithDivisor(u64 value, u64 divisor)
     597              :     {
     598          136 :         if ((value == 0) || (divisor == 0)) {
     599            0 :             return divisor;
     600              :         }
     601              :         // divisor必须大于等于1, 返回value向上取divisor的整数倍的值
     602          136 :         return ((value + (divisor - 1)) / divisor) * divisor;
     603              :     }
     604              :     inline u64 ByteOffset(u64 countOffset) const
     605              :     {
     606              :         return countOffset * DataUnitSize(dataType_);
     607              :     }
     608              :     inline u64 SliceOffset(u32 sliceIndex, u64 countPerSlice) const
     609              :     {
     610              :         return sliceIndex * countPerSlice * DataUnitSize(dataType_);
     611              :     }
     612            1 :     inline void CloseBarrier()
     613              :     {
     614            1 :         barrierSwitchOn_ = false;
     615            1 :     }
     616              :     virtual HcclResult GetNslbAdjInfo(const u32 rank, const u32 rankSize,
     617              :                                       const std::vector<LINK> &links, AdjInfo& nslbAdjInfo);
     618              : 
     619              :     // 只用于alltoallv类算子的aicpu cache
     620              :     virtual HcclResult GetHcclOffsetDstRanksMap(std::unordered_map<uint64_t, std::vector<uint32_t>>& hcclOffsetDstRanksMap) const;
     621              : 
     622              : protected:
     623              :     HcclResult ExecuteBarrier(const std::shared_ptr<Transport> &preLink, const std::shared_ptr<Transport> &aftLink);
     624              :     HcclResult ExecuteBarrier(const std::shared_ptr<Transport> &preLink,
     625              :         const std::shared_ptr<Transport> &aftLink, Stream &stream);
     626              :     HcclResult ExecuteBarrier(const std::shared_ptr<Transport> &preLink, 
     627              :         const std::shared_ptr<Transport> &aftLink, u32 notifyIdx);
     628              :     HcclResult ExecuteBarrier(const std::shared_ptr<Transport> &preLink,
     629              :         const std::shared_ptr<Transport> &aftLink, u32 notifyIdx, Stream &stream);
     630              :     HcclResult ExecuteBarrier(std::shared_ptr<Transport> link, Stream &stream);
     631              :     HcclResult ExecuteRxSync(std::shared_ptr<Transport> link, UserMemType srcMemType, u64 srcOffset,
     632              :         void *dst, u64 len, Stream &stream) const;
     633              :     HcclResult ExecuteTxSync(std::shared_ptr<Transport> link, UserMemType dstMemType, u64 dstOffset,
     634              :         void *src, u64 len, Stream &stream) const;
     635              :     virtual HcclResult PrepareRunAsync(const u32 rank, const u32 rankSize,
     636              :         const std::vector<std::shared_ptr<Transport> > &links);
     637              :     const HcclDispatcher dispatcher_;
     638              :     std::vector<Slice> slicesDummy_;
     639              :     std::vector<Slice> &slices_;
     640              :     DeviceMem inputMem_;   /* * 输入memory */
     641              :     DeviceMem outputMem_;  /* * 输出memory */
     642              :     DeviceMem scratchMem_; /* * 草稿memory */
     643              : 
     644              :     u64 count_; //  需处理的每块memory数据总个数
     645              :     u64 dataBytes_; //  数据所占的字节数
     646              :     HcclDataType dataType_;
     647              :     HcclReduceOp reductionOp_;
     648              :     u32 root_;
     649              :     bool disableDMAReduce_;
     650              : 
     651              :     // Added on Mar.24th, for profiling template
     652              :     StepData profilerInput_;
     653              :     u64 baseOffset_;
     654              : 
     655              :     Stream stream_;
     656              : 
     657              :     // 用于chunk算法
     658              :     std::vector<u32> nicRankList_;
     659              :     std::vector<std::vector<u32>> rankSliceLists_;
     660              :     bool barrierSwitchOn_;
     661              :     // 用于91093 aligend double ring算法
     662              :     std::vector<std::vector<Slice>> multRingsSlices_;
     663              :     AlgOpContext algOpContext_;
     664              : private:
     665              :     static void CalcBinaryBlockParams(u32 rank, u32 rankSize, u32 &stepsInBlock, u32 &lowerBlockSize,
     666              :         u32 &myBlockSize, u32 &rankInMyBlock, u32 &myBlockOffset, u32 &higherBlockSize);
     667              :     static HcclResult CalcBinaryBlockHalvingDoubleLinkReleation(u32 rank,  u32 rankSize,
     668              :                                                                       std::vector<bool> &linkRelation);
     669              : 
     670              :     static void CalcLinkInBlock(u32 blockSize, u32 rankInBlock, std::list<u32> &linkRankIndexInBlock);
     671              :     static void CalcLinkBetweenParts(u32 part1Size, std::list<u32> &linkRankIndexInBlock,
     672              :                                              std::list<u32> &linkRankIndex, bool oddRank);
     673              :     static void CalcRecursiveHalvingDobuleLinkReleation(u32 rank, u32 rankSize, u32 rootRank,
     674              :                                                                    std::vector<bool> &linkRelation);
     675              :     static void CalcRecursiveHdLinkRelationForFirstScene(u32 rank,
     676              :         u32 part1Size, u32 blockSize, std::vector<bool> &linkRelation);
     677              :     static void CalcRecursiveHdLinkRelationForSecondScene(u32 rank,
     678              :         u32 part1Size, u32 blockSize, std::vector<bool> &linkRelation);
     679              : };
     680              : using AlgTemplateBase = ExecutorBase;
     681              : }  // namespace hccl
     682              : 
     683              : #endif /* EXECUTOR_BASE_PUB_H */
        

Generated by: LCOV version 2.0-1