LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_ccu_context/reduce - ccu_instruction_reduce_mesh1d_mem2mem.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 52 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 9 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_INSTRUCTION_REDUCE_MESH_1D_MEM2MEM_H_
      12              : #define HCCLV2_CCU_INSTRUCTION_REDUCE_MESH_1D_MEM2MEM_H_
      13              : 
      14              : #include "template_utils.h"
      15              : #include "instruction.h"
      16              : #include "ins_queue.h"
      17              : #include "ccu_context_utils.h"
      18              : #include "ccu_ctx_signature.h"
      19              : #include "ccu_ins.h"
      20              : #include "ccu_rank_group.h"
      21              : 
      22              : namespace Hccl {
      23              : 
      24              : // 为ReduceMeshMem2Mem1D实现的CCUIns、CCUCtxArg与CCUTaskArg
      25              : class CcuCtxArgReduceMeshMem2Mem1D : public CcuCtxArg {
      26              : public:
      27            0 :     explicit CcuCtxArgReduceMeshMem2Mem1D(const std::vector<uint64_t> &dimSize, uint32_t rankId, uint32_t rootId,
      28              :                                           const CollAlgOperator &op, const std::vector<std::vector<RankId>> &tempVTopo)
      29            0 :         : dimSize_(dimSize), rankId_(rankId), rootId_(rootId), op_(op), tempVTopo_(tempVTopo)
      30              :     {
      31            0 :     }
      32            0 :     CcuCtxSignature GetCtxSignature() const override
      33              :     {
      34            0 :         CcuCtxSignature signature;
      35            0 :         GenerateCcuCtxSignature(signature, CcuInstType::CCU_REDUCE_MESH_1D_MEM2MEM, op_, tempVTopo_);
      36            0 :         return signature;
      37            0 :     }
      38              : 
      39              :     std::vector<uint64_t>            dimSize_;
      40              :     uint32_t                         rankId_;
      41              :     uint32_t                         rootId_;
      42              :     CollAlgOperator                  op_;
      43              :     std::vector<std::vector<RankId>> tempVTopo_;
      44              : };
      45              : 
      46              : class CcuTaskArgReduceMeshMem2Mem1D : public CcuTaskArg {
      47              : public:
      48            0 :     explicit CcuTaskArgReduceMeshMem2Mem1D(uint64_t inputAddr, uint64_t outputAddr, uint64_t token,
      49              :                                             uint64_t bigDataSliceNum, uint64_t bigDataSliceSize, uint64_t smallDataSliceNum,
      50              :                                             uint64_t smallDataSliceSize, uint64_t inputRepeatStride, uint64_t outputRepeatStride,
      51              :                                             uint64_t normalSliceSize, uint64_t lastSliceSize, uint64_t repeatNumVar)
      52            0 :         : inputAddr_(inputAddr), outputAddr_(outputAddr), token_(token), bigDataSliceNum_(bigDataSliceNum),
      53            0 :           bigDataSliceSize_(bigDataSliceSize), smallDataSliceNum_(smallDataSliceNum), smallDataSliceSize_(smallDataSliceSize),
      54            0 :           inputRepeatStride_(inputRepeatStride), outputRepeatStride_(outputRepeatStride),
      55            0 :           normalSliceSize_(normalSliceSize), lastSliceSize_(lastSliceSize), repeatNumVar_(repeatNumVar)
      56              :     {
      57            0 :     }
      58              : 
      59              :     uint64_t inputAddr_;
      60              :     uint64_t outputAddr_;
      61              :     uint64_t token_;
      62              :     uint64_t bigDataSliceNum_;
      63              :     uint64_t bigDataSliceSize_;
      64              :     uint64_t smallDataSliceNum_;
      65              :     uint64_t smallDataSliceSize_;
      66              :     uint64_t inputRepeatStride_;
      67              :     uint64_t outputRepeatStride_;
      68              :     uint64_t normalSliceSize_;
      69              :     uint64_t lastSliceSize_;
      70              :     uint64_t repeatNumVar_;
      71              : };
      72              : 
      73              : class CcuInstructionReduceMeshMem2Mem1D : public CcuInstruction {
      74              : public:
      75            0 :     CcuInstructionReduceMeshMem2Mem1D() : CcuInstruction()
      76              :     {
      77            0 :     }
      78              : 
      79            0 :     void Init(uint32_t rankId, uint32_t rootId, const CollAlgOperator &op,
      80              :               const std::vector<std::vector<RankId>> &tempVTopo, uint64_t inputAddr, uint64_t outputAddr,
      81              :               uint64_t token, uint64_t bigDataSliceNum, uint64_t bigDataSliceSize,uint64_t smallDataSliceNum,
      82              :               uint64_t smallDataSliceSize, uint64_t inputRepeatStride, uint64_t outputRepeatStride,
      83              :               uint64_t normalSliceSize, uint64_t lastSliceSize, uint64_t repeatNumVar)
      84              :     {
      85            0 :         u32 maxDimNum = 1;
      86            0 :         if (tempVTopo.size() != maxDimNum) {
      87            0 :             THROW<InvalidParamsException>(StringFormat(
      88              :                 "[CcuInstructionReduceMeshMem2Mem1D] tempVTopo size is not 1, size is [%zu].", tempVTopo.size()));
      89              :         }
      90            0 :         dimSize_.push_back(tempVTopo[0].size());
      91            0 :         rankId_ = rankId;
      92            0 :         rootId_ = rootId;
      93            0 :         op_                 = op;
      94            0 :         tempVTopo_          = tempVTopo;
      95            0 :         inputAddr_          = inputAddr;
      96            0 :         outputAddr_         = outputAddr;
      97            0 :         bigDataSliceNum_    = bigDataSliceNum;
      98            0 :         bigDataSliceSize_   = bigDataSliceSize;
      99            0 :         smallDataSliceNum_  = smallDataSliceNum;
     100            0 :         smallDataSliceSize_ = smallDataSliceSize;
     101            0 :         inputRepeatStride_  = inputRepeatStride;
     102            0 :         outputRepeatStride_ = outputRepeatStride;
     103            0 :         normalSliceSize_    = normalSliceSize;
     104            0 :         lastSliceSize_      = lastSliceSize;
     105            0 :         repeatNumVar_       = repeatNumVar;
     106            0 :         token_              = token;
     107            0 :         return;
     108              :     }
     109              : 
     110            0 :     CcuInstType GetInstType() const override
     111              :     {
     112            0 :         HCCL_INFO("CcuInstructionReduceMeshMem2Mem1D instype is CCU_REDUCE_MESH_1D_MEM2MEM.");
     113            0 :         return instType_;
     114              :     }
     115              : 
     116            0 :     std::unique_ptr<CcuCtxArg> GetCtxArg() const override
     117              :     {
     118            0 :         HCCL_INFO("[CcuInstructionReduceMeshMem2Mem1D] GetCtxArg begin");
     119            0 :         return std::make_unique<CcuCtxArgReduceMeshMem2Mem1D>(dimSize_, rankId_, rootId_, op_, tempVTopo_);
     120              :     }
     121              : 
     122              :     void SetInstType(CcuInstType instType) 
     123              :     { 
     124              :         instType_ = instType; 
     125              :     }
     126              : 
     127            0 :     std::string Describe() const override
     128              :     {
     129            0 :         return StringFormat("CcuInstructionReduceMeshMem2Mem1D rankId [%u], instType[%d]", rankId_, instType_);
     130              :     }
     131              : 
     132            0 :     std::unique_ptr<CcuTaskArg> GetTaskArg() const override
     133              :     {
     134            0 :         HCCL_INFO("[CcuInstructionReduceMeshMem2Mem1D] GetTaskArg begin");
     135            0 :         return std::make_unique<CcuTaskArgReduceMeshMem2Mem1D>(inputAddr_, outputAddr_, token_, bigDataSliceNum_,
     136            0 :                                                                 bigDataSliceSize_, smallDataSliceNum_, smallDataSliceSize_,
     137            0 :                                                                 inputRepeatStride_, outputRepeatStride_, normalSliceSize_,
     138            0 :                                                                 lastSliceSize_, repeatNumVar_);
     139              :     }
     140              : 
     141              : private:
     142              :     CcuInstType instType_ = CcuInstType::CCU_REDUCE_MESH_1D_MEM2MEM;
     143              :     std::vector<uint64_t>            dimSize_;
     144              :     uint32_t                         rootId_{0};
     145              :     uint32_t                         rankId_{0};
     146              :     CollAlgOperator                  op_;
     147              :     std::vector<std::vector<RankId>> tempVTopo_;
     148              :     uint64_t                         inputAddr_{0};
     149              :     uint64_t                         outputAddr_{0};
     150              :     uint64_t                         token_{0};
     151              :     uint64_t                         bigDataSliceSize_{0};
     152              :     uint64_t                         bigDataSliceNum_{0};
     153              :     uint64_t                         smallDataSliceSize_{0};
     154              :     uint64_t                         smallDataSliceNum_{0};
     155              :     uint64_t                         inputRepeatStride_{0};
     156              :     uint64_t                         outputRepeatStride_{0};
     157              :     uint64_t                         repeatNumVar_{0};
     158              :     uint64_t                         normalSliceSize_{0};
     159              :     uint64_t                         lastSliceSize_{0};
     160              : };
     161              :  
     162              : } // namespace Hccl
     163              : #endif // HCCLV2_CCU_INSTRUCTION_REDUCE_MESH_1D_MEM2MEM_H_
        

Generated by: LCOV version 2.0-1