LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/base/alg_template/inc_all_reduce_deter - all_reduce_local_reduce_pub.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 4 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 1 0

            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 ALL_REDUCE_LOCAL_REDUCE_PUB_H
      12              : #define ALL_REDUCE_LOCAL_REDUCE_PUB_H
      13              : 
      14              : #include "alg_template_base_pub.h"
      15              : 
      16              : namespace hccl {
      17              : class AllReduceLocalReduce : public AlgTemplateBase {
      18              : public:
      19              :     using AlgTemplateBase::Prepare;
      20              :     explicit AllReduceLocalReduce(const HcclDispatcher dispatcher);
      21              :     ~AllReduceLocalReduce() override;
      22              : 
      23              :     /* 新增的两段式构造函数,获取实例后要无脑调用实现构造函数功能,后续还要调用其它的基类Prepare函数实现其它成员变量初始化
      24              :      */
      25              :     HcclResult Prepare(
      26              :         u64 reduceAttrBitMap, std::vector<Stream>& meshStreams, std::vector<std::shared_ptr<LocalNotify>>& meshSignal,
      27              :         std::vector<std::shared_ptr<LocalNotify>>& meshSignalAux, u32 interRank, u32 interRankSize, u32 userRank,
      28              :         HcomCollOpInfo* opInfo) override;
      29              : 
      30              :     HcclResult RunAsync(const u32 rank, const u32 rankSize, const std::vector<LINK>& links) override;
      31              : 
      32              : protected:
      33              : private:
      34              :     HcclResult MainRecordSub();
      35              :     HcclResult SubWaitMain();
      36              :     HcclResult MainWaitSub();
      37              :     HcclResult SubRecordMain();
      38              :     HcclResult PrepareSlice(
      39              :         u64 dataCount, u32 unitSize, u32 sliceNum, std::vector<Slice>& dataSlice, std::vector<Slice>& startSlice);
      40              :     HcclResult PrepareAllreduceSliceData();
      41              :     HcclResult RunReduceScatter(u32 rank, u32 rankSize, const std::vector<LINK>& links);
      42              :     HcclResult RunLocalReduce(u32 rank, u32 rankSize);
      43              :     HcclResult RunAllGather(u32 rank, u32 rankSize, const std::vector<LINK>& links);
      44            0 :     inline u32 BackwardRank(u32 rank, u32 rankSize, u32 step) const
      45              :     {
      46            0 :         if (rankSize == 0) {
      47            0 :             return 0;
      48              :         }
      49            0 :         return (rank + rankSize - step) % rankSize;
      50              :     }
      51              :     u64 reduceAttr_;
      52              :     u32 localRank_;
      53              :     u32 localRankSize_;
      54              :     u32 userRank_;
      55              :     std::vector<Stream> meshStreams_;                                   /* * 多stream* */
      56              :     std::vector<std::shared_ptr<LocalNotify>>* meshSignal_{nullptr};    /* 每个ring创建一个signal */
      57              :     std::vector<std::shared_ptr<LocalNotify>>* meshSignalAux_{nullptr}; /* 从stream wait,主stream record */
      58              :     HcomCollOpInfo* opInfo_{nullptr};
      59              :     std::vector<Slice> startOffset;
      60              : };
      61              : } // namespace hccl
      62              : #endif /* ALL_REDUCE_LOCAL_REDUCE_PUB_H */
        

Generated by: LCOV version 2.0-1