LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_reduce_scatter - coll_reduce_scatter_executor.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-08-18 17:47:01 Functions: 50.0 % 2 1

            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 COLL_REDUCESCATTER_EXECUTOR_H
      12              : #define COLL_REDUCESCATTER_EXECUTOR_H
      13              : #include "coll_comm_executor.h"
      14              : 
      15              : namespace hccl {
      16              : 
      17              : constexpr u64 CCE_REDUCE_ALIGN_FACTOR = 2; // cce reduce数据大小32字节对齐  2是指前后各有
      18              : 
      19              : class CollReduceScatterExecutor : public CollCommExecutor {
      20              : public:
      21              :     explicit CollReduceScatterExecutor(const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher);
      22           50 :     ~CollReduceScatterExecutor() override = default;
      23              : 
      24              :     HcclResult Orchestrate(OpParam& param, AlgResourceResponse& algRes) override;
      25              : 
      26              : protected:
      27              :     // ReduceScatter Loop Executor公共接口
      28              :     virtual u64 CalcLoopMaxCount(const u32 unitSize);
      29              :     virtual bool IsHugeData(const u64 curSize, OpParam* param = nullptr);
      30              :     virtual bool IsSmallData(const u64 totalSize, const u64 curSize);
      31              :     virtual bool IsPreloadCopyOptimizeCondition(const OpParam& param, ExecMem& execMem);
      32              :     virtual HcclResult RunLoop(OpParam& param, AlgResourceResponse& algRes);
      33              :     virtual HcclResult RunLoopV(OpParam& param, AlgResourceResponse& algRes);
      34              : 
      35              :     // 工具类
      36              :     std::vector<std::vector<Slice>> ReduceScatterRingSlicePrepare(
      37              :         u32 ringNum, u32 sliceNum, bool useInlineReduce, const DeviceMem& outputMem, std::vector<Slice>& dataSegsSlice,
      38              :         const std::string& tag);
      39              :     std::vector<std::vector<Slice>> ReduceScatterRingSlicePrepareContinuous(
      40              :         u32 ringNum, u32 sliceNum, bool useInlineReduce, DeviceMem& outputMem, u32 level1RankSize, u32 level2RankSize,
      41              :         std::vector<Slice>& dataSegsSlice, const std::string& tag);
      42              :     std::vector<std::vector<Slice>> AnyPathReduceScatterRingSlicePrepare(
      43              :         u32 ringNum, u32 sliceNum, bool useInlineReduce, DeviceMem& outputMem, std::vector<Slice>& dataSegsSlice,
      44              :         const std::string& tag);
      45              :     HcclResult PrepareAivBuffers(
      46              :         u32 rankSize, u32 rankId, u32 rankOffset, DeviceMem& inputMem, DeviceMem& outputMem, std::vector<LINK>& links,
      47              :         void** dataBuffers, void** flagBuffers, UserMemType dataMemType, UserMemType flagMemType, u32 dataMemOffset,
      48              :         u32 flagMemOffset);
      49              :     HcclResult RetryPostSync(OpParam& param, ExecMem& execMem);
      50              :     bool CCLMemSlice_{true};     // 每次Loop是否需要对CCLMem进行切片
      51              :     bool DMAReduceFlag_{false};  // 是否DMA消减
      52              :     bool scratchMemFlag_{false}; // 是否需要申请scratch memory,不需要申请则传入outputmem为scratchmem
      53              :     u64 totalSize_{0};           // 总数据量
      54              :     bool isReduceScatterV_{false};
      55              : 
      56              : private:
      57              :     HcclResult RunLoopInner(OpParam& param, const ReduceType& reduceType, ExecMem& execMem);
      58              :     HcclResult RunLoopInnerV(OpParam& param, const ReduceType& reduceType, ExecMem& execMem);
      59              : 
      60              :     bool CalcCurCountsAndCurDispls(
      61              :         const u64 maxTotalCount, std::vector<u64>& countsLeft, std::vector<u64>& displs, std::vector<u64>& curCounts,
      62              :         std::vector<u64>& curDispls, u32 unitSize);
      63              :     void PrintCurCountAndCurDispls(const std::vector<u64>& curCounts, const std::vector<u64>& curDispls);
      64              : };
      65              : 
      66              : } // namespace hccl
      67              : 
      68              : #endif
        

Generated by: LCOV version 2.0-1