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_mesh2d_two_shot_mem2mem.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 3 0
Test Date: 2026-08-04 10:52:23 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 HCCLV2_CCU_CONTEXT_ALL_REDUCE_MESH_2D_TWO_SHOT_MEM2MEM_H_
      12              : #define HCCLV2_CCU_CONTEXT_ALL_REDUCE_MESH_2D_TWO_SHOT_MEM2MEM_H_
      13              : 
      14              : #include <vector>
      15              : #include <ios>
      16              : #include "log.h"
      17              : #include "ccu_context_alg_base.h"
      18              : #include "ccu_datatype.h"
      19              : #include "ccu_assist.h"
      20              : 
      21              : namespace Hccl {
      22              : 
      23              : class CcuContextAllReduceMeshTwoShotMem2Mem2D : public CcuContextAlgBase {
      24              : public:
      25              :     CcuContextAllReduceMeshTwoShotMem2Mem2D(const CcuCtxArg &arg, const std::vector<CcuTransport *> &transports,
      26              :                                             const CcuTransportGroup &group);
      27            0 :     ~CcuContextAllReduceMeshTwoShotMem2Mem2D() override
      28            0 :     {
      29            0 :     }
      30              : 
      31              :     void                  Algorithm() override;
      32              :     std::vector<uint64_t> GeneArgs(const CcuTaskArg &arg) override;
      33              : 
      34              : private:
      35              :     void                  InitVariables();
      36              :     void                  LoadArgs();
      37              :     void                  SyncAll(int ckeIdx);
      38              :     void                  PreSync();
      39              :     void                  GetSliceOffsetAndGoSize(uint64_t currentSliceRankIdx, uint64_t currStepSliceType);
      40              :     void                  DoAxisSync(uint32_t signalIdx);
      41              :     void                  DoGroupSync(int ckeIdx, uint16_t selfBit, uint16_t allBit);
      42              :     void                  DoGroupReduce(std::vector<CcuRep::Variable> &srcAddr, CcuRep::Variable &dstAddr);
      43              :     void                  AllGatherStep(CcuRep::Variable &srcAddr, std::vector<CcuRep::Variable> &dstAddr);
      44              :     void                  CalMeshChunkSlices(uint64_t totalSize, uint64_t sliceNum, std::vector<uint64_t> &slices,
      45              :                                              std::vector<uint64_t> &offsets);
      46              :     std::vector<uint64_t> dimSize_;
      47              :     uint32_t              axisId_{0};
      48              :     DataType              dataType_;
      49              :     DataType              outputDataType_;
      50              : 
      51              :     uint32_t              otherAxisId_{0};
      52              :     std::vector<uint64_t> myRankIdxInAxis_;
      53              :     uint64_t              myRankIdxInCurrentAxis_{0};
      54              :     uint64_t              currentAxisRankSize_{0};
      55              :     uint64_t              myRankIdxInOtherAxis_{0};
      56              :     uint64_t              otherAxisRankSize_{0};
      57              : 
      58              :     uint16_t selfBit_{0};
      59              :     uint16_t allBit_{0};
      60              : 
      61              :     CcuRep::Variable curOffset_;
      62              :     CcuRep::Variable curSliceSize_;
      63              : 
      64              :     std::vector<CcuRep::Variable> inputAddr_;
      65              :     std::vector<CcuRep::Variable> outputAddr_;
      66              :     std::vector<CcuRep::Variable> token_;
      67              : 
      68              :     CcuRep::Variable normalRankXSliceSize_;
      69              :     CcuRep::Variable normalRankYSliceSize_;
      70              :     CcuRep::Variable lastRankXSliceSize_;
      71              :     CcuRep::Variable lastRankYSliceSize_;
      72              : 
      73              :     std::vector<CcuRep::Variable> normalXSlices_;
      74              :     std::vector<CcuRep::Variable> normalXOffsets_;
      75              :     std::vector<CcuRep::Variable> normalYSlices_;
      76              :     std::vector<CcuRep::Variable> normalYOffsets_;
      77              :     std::vector<CcuRep::Variable> lastXSlices_;
      78              :     std::vector<CcuRep::Variable> lastXOffsets_;
      79              :     std::vector<CcuRep::Variable> lastYSlices_;
      80              :     std::vector<CcuRep::Variable> lastYOffsets_;
      81              :     std::vector<CcuRep::Variable> curOffsetVec_;
      82              :     std::vector<CcuRep::Variable> curSliceVec_;
      83              : 
      84              :     GroupOpSize normalRankXGoSize_;
      85              :     GroupOpSize normalRankYGoSize_;
      86              :     GroupOpSize lastRankXGoSize_;
      87              :     GroupOpSize lastRankYGoSize_;
      88              :     GroupOpSize currGoSize_;
      89              : 
      90              :     std::string        currAxisSignalName_;
      91              :     std::string        otherAxisSignalName_;
      92              :     CcuRep::MaskSignal currAxisSignal_;
      93              :     CcuRep::MaskSignal otherAxisSignal_;
      94              : 
      95              :     // 算法模板运行时的参数
      96              :     std::vector<CcuRep::Memory> tmpAddrList_;
      97              :     CcuRep::Memory              tmpAddr_;
      98              : };
      99              : } // namespace Hccl
     100              : 
     101              : #endif // HCCLV2_CCU_CONTEXT_ALL_REDUCE_MESH_2D_TWO_SHOT_MEM2MEM_H_
        

Generated by: LCOV version 2.0-1