LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_ccu_context/all_reduce - ccu_context_all_reduce_nhr1d_mem2mem.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 1 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 2 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 CUPT_KERNEL_CCU_CONTEXT_ALLREDUCE_NHR_1D_H_
      12              : #define CUPT_KERNEL_CCU_CONTEXT_ALLREDUCE_NHR_1D_H_
      13              : #include <vector>
      14              : 
      15              : #include <ios>
      16              : #include "log.h"
      17              : #include "ccu_context_alg_base.h"
      18              : #include "ccu_datatype.h"
      19              : #include "ccu_instruction_all_reduce_nhr1d_mem2mem.h"
      20              : 
      21              : namespace Hccl {
      22              : 
      23              : class CcuContextAllReduceNHR1D : public CcuContextAlgBase {
      24              : public:
      25              :     CcuContextAllReduceNHR1D(
      26              :         const CcuCtxArg& arg, const std::vector<CcuTransport*>& transports, const CcuTransportGroup& group);
      27            0 :     ~CcuContextAllReduceNHR1D() override {}
      28              : 
      29              :     void Algorithm() override;
      30              :     std::vector<uint64_t> GeneArgs(const CcuTaskArg& arg) override;
      31              : 
      32              : private:
      33              :     void LoadArgs();
      34              :     void InitResources();
      35              :     void PreSync();
      36              :     void PostSync();
      37              :     void AxisSync(uint32_t signalIndex);
      38              :     void LocalCopySlices();
      39              :     void DoLocalCopySlice(CcuRep::Memory& src, CcuRep::Memory& dst, const u32& copySliceIdx, u32 signalIndex);
      40              :     std::vector<u32> GetNonTxSliceIdxs(const std::vector<u32>& txSliceIdxs) const;
      41              :     void DoReduceScatterNHR();
      42              :     void DoReduceScatterNHRSingleStep(const NHRStepInfo& nhrStepInfo);
      43              :     void DoWriteReduceSlice(
      44              :         const u32& toRank, CcuRep::Memory& src, CcuRep::Memory& dst, const u32& sendSliceIdx, u32 signalIndex);
      45              :     void DoAllGatherNHR();
      46              :     void DoAllGatherNHRSingleStep(const NHRStepInfo& nhrStepInfo);
      47              :     void DoSendRecvSlice(
      48              :         const u32& toRank, CcuRep::Memory& src, CcuRep::Memory& dst, const u32& sendSliceIdx, u32 signalIndex);
      49              : 
      50              :     // 构造函数中
      51              :     uint64_t dimSize_{0};
      52              :     uint32_t axisId_{0};
      53              :     uint32_t axisSize_{0};
      54              :     uint32_t localSize_{0}; // 本rank所在行或列的总rank数
      55              :     uint32_t repeatNum_{0};
      56              :     uint32_t myRankIdx_{0};
      57              :     uint32_t signalNum_{0}; // 需要使用的signal数量
      58              :     DataType dataType_;
      59              :     // DataType outputDataType_;
      60              :     std::vector<NHRStepInfo> stepInfoVector_; // nhr算法执行过程中的参数
      61              :     std::map<u32, u32> indexMap_;
      62              : 
      63              :     // load进来参数
      64              :     CcuRep::Variable input_;
      65              :     std::vector<CcuRep::Variable> output_;
      66              :     std::vector<CcuRep::Variable> token_;
      67              :     std::vector<CcuRep::Variable> sliceOffset_;
      68              :     CcuRep::Variable die0Size_;
      69              :     CcuRep::Variable die1Size_;
      70              :     CcuRep::Variable sliceSize_;
      71              :     CcuRep::Variable die0SliceSize_;
      72              :     CcuRep::Variable die1SliceSize_;
      73              :     CcuRep::Variable die0LastSliceSize_;
      74              :     CcuRep::Variable die1LastSliceSize_;
      75              :     CcuRep::Variable isInputOutputEqual_;
      76              : 
      77              :     // 跨轴同步信号
      78              :     std::string localAxisSignalName_;
      79              :     std::string anotherAxisSignalName_;
      80              :     CcuRep::MaskSignal localAxisSignal_;
      81              :     CcuRep::MaskSignal anotherAxisSignal_;
      82              :     CcuRep::MaskSignal localSignal_;
      83              : 
      84              :     CcuRep::Memory srcMem_;
      85              :     CcuRep::Memory dstMem_;
      86              : 
      87              :     CcuRep::Variable repeatInputOffset_;
      88              :     CcuRep::Variable repeatOutputOffset_;
      89              : };
      90              : } // namespace Hccl
      91              : 
      92              : #endif // HCCLV2_CCU_CONTEXT_ALL_REDUCE_NHR_1D_H_
        

Generated by: LCOV version 2.0-1