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 % 63 0
Test Date: 2026-08-18 17:47:01 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(
      28              :         const std::vector<uint64_t>& dimSize, uint32_t rankId, uint32_t rootId, const CollAlgOperator& op,
      29              :         const std::vector<std::vector<RankId>>& tempVTopo)
      30            0 :         : dimSize_(dimSize),
      31            0 :           rankId_(rankId),
      32            0 :           rootId_(rootId),
      33            0 :           op_(op),
      34            0 :           tempVTopo_(tempVTopo)
      35            0 :     {}
      36            0 :     CcuCtxSignature GetCtxSignature() const override
      37              :     {
      38            0 :         CcuCtxSignature signature;
      39            0 :         GenerateCcuCtxSignature(signature, CcuInstType::CCU_REDUCE_MESH_1D_MEM2MEM, op_, tempVTopo_);
      40            0 :         return signature;
      41            0 :     }
      42              : 
      43              :     std::vector<uint64_t> dimSize_;
      44              :     uint32_t rankId_;
      45              :     uint32_t rootId_;
      46              :     CollAlgOperator op_;
      47              :     std::vector<std::vector<RankId>> tempVTopo_;
      48              : };
      49              : 
      50              : class CcuTaskArgReduceMeshMem2Mem1D : public CcuTaskArg {
      51              : public:
      52            0 :     explicit CcuTaskArgReduceMeshMem2Mem1D(
      53              :         uint64_t inputAddr, uint64_t outputAddr, uint64_t token, uint64_t bigDataSliceNum, uint64_t bigDataSliceSize,
      54              :         uint64_t smallDataSliceNum, uint64_t smallDataSliceSize, uint64_t inputRepeatStride,
      55              :         uint64_t outputRepeatStride, uint64_t normalSliceSize, uint64_t lastSliceSize, uint64_t repeatNumVar)
      56            0 :         : inputAddr_(inputAddr),
      57            0 :           outputAddr_(outputAddr),
      58            0 :           token_(token),
      59            0 :           bigDataSliceNum_(bigDataSliceNum),
      60            0 :           bigDataSliceSize_(bigDataSliceSize),
      61            0 :           smallDataSliceNum_(smallDataSliceNum),
      62            0 :           smallDataSliceSize_(smallDataSliceSize),
      63            0 :           inputRepeatStride_(inputRepeatStride),
      64            0 :           outputRepeatStride_(outputRepeatStride),
      65            0 :           normalSliceSize_(normalSliceSize),
      66            0 :           lastSliceSize_(lastSliceSize),
      67            0 :           repeatNumVar_(repeatNumVar)
      68            0 :     {}
      69              : 
      70              :     uint64_t inputAddr_;
      71              :     uint64_t outputAddr_;
      72              :     uint64_t token_;
      73              :     uint64_t bigDataSliceNum_;
      74              :     uint64_t bigDataSliceSize_;
      75              :     uint64_t smallDataSliceNum_;
      76              :     uint64_t smallDataSliceSize_;
      77              :     uint64_t inputRepeatStride_;
      78              :     uint64_t outputRepeatStride_;
      79              :     uint64_t normalSliceSize_;
      80              :     uint64_t lastSliceSize_;
      81              :     uint64_t repeatNumVar_;
      82              : };
      83              : 
      84              : class CcuInstructionReduceMeshMem2Mem1D : public CcuInstruction {
      85              : public:
      86            0 :     CcuInstructionReduceMeshMem2Mem1D() : CcuInstruction() {}
      87              : 
      88            0 :     void Init(
      89              :         uint32_t rankId, uint32_t rootId, const CollAlgOperator& op, const std::vector<std::vector<RankId>>& tempVTopo,
      90              :         uint64_t inputAddr, uint64_t outputAddr, uint64_t token, uint64_t bigDataSliceNum, uint64_t bigDataSliceSize,
      91              :         uint64_t smallDataSliceNum, uint64_t smallDataSliceSize, uint64_t inputRepeatStride,
      92              :         uint64_t outputRepeatStride, uint64_t normalSliceSize, uint64_t lastSliceSize, uint64_t repeatNumVar)
      93              :     {
      94            0 :         u32 maxDimNum = 1;
      95            0 :         if (tempVTopo.size() != maxDimNum) {
      96            0 :             THROW<InvalidParamsException>(StringFormat(
      97              :                 "[CcuInstructionReduceMeshMem2Mem1D] tempVTopo size is not 1, size is [%zu].", tempVTopo.size()));
      98              :         }
      99            0 :         dimSize_.push_back(tempVTopo[0].size());
     100            0 :         rankId_ = rankId;
     101            0 :         rootId_ = rootId;
     102            0 :         op_ = op;
     103            0 :         tempVTopo_ = tempVTopo;
     104            0 :         inputAddr_ = inputAddr;
     105            0 :         outputAddr_ = outputAddr;
     106            0 :         bigDataSliceNum_ = bigDataSliceNum;
     107            0 :         bigDataSliceSize_ = bigDataSliceSize;
     108            0 :         smallDataSliceNum_ = smallDataSliceNum;
     109            0 :         smallDataSliceSize_ = smallDataSliceSize;
     110            0 :         inputRepeatStride_ = inputRepeatStride;
     111            0 :         outputRepeatStride_ = outputRepeatStride;
     112            0 :         normalSliceSize_ = normalSliceSize;
     113            0 :         lastSliceSize_ = lastSliceSize;
     114            0 :         repeatNumVar_ = repeatNumVar;
     115            0 :         token_ = token;
     116            0 :         return;
     117              :     }
     118              : 
     119            0 :     CcuInstType GetInstType() const override
     120              :     {
     121            0 :         HCCL_INFO("CcuInstructionReduceMeshMem2Mem1D instype is CCU_REDUCE_MESH_1D_MEM2MEM.");
     122            0 :         return instType_;
     123              :     }
     124              : 
     125            0 :     std::unique_ptr<CcuCtxArg> GetCtxArg() const override
     126              :     {
     127            0 :         HCCL_INFO("[CcuInstructionReduceMeshMem2Mem1D] GetCtxArg begin");
     128            0 :         return std::make_unique<CcuCtxArgReduceMeshMem2Mem1D>(dimSize_, rankId_, rootId_, op_, tempVTopo_);
     129              :     }
     130              : 
     131              :     void SetInstType(CcuInstType instType) { instType_ = instType; }
     132              : 
     133            0 :     std::string Describe() const override
     134              :     {
     135            0 :         return StringFormat("CcuInstructionReduceMeshMem2Mem1D rankId [%u], instType[%d]", rankId_, instType_);
     136              :     }
     137              : 
     138            0 :     std::unique_ptr<CcuTaskArg> GetTaskArg() const override
     139              :     {
     140            0 :         HCCL_INFO("[CcuInstructionReduceMeshMem2Mem1D] GetTaskArg begin");
     141            0 :         return std::make_unique<CcuTaskArgReduceMeshMem2Mem1D>(
     142            0 :             inputAddr_, outputAddr_, token_, bigDataSliceNum_, bigDataSliceSize_, smallDataSliceNum_,
     143            0 :             smallDataSliceSize_, inputRepeatStride_, outputRepeatStride_, normalSliceSize_, lastSliceSize_,
     144            0 :             repeatNumVar_);
     145              :     }
     146              : 
     147              : private:
     148              :     CcuInstType instType_ = CcuInstType::CCU_REDUCE_MESH_1D_MEM2MEM;
     149              :     std::vector<uint64_t> dimSize_;
     150              :     uint32_t rootId_{0};
     151              :     uint32_t rankId_{0};
     152              :     CollAlgOperator op_;
     153              :     std::vector<std::vector<RankId>> tempVTopo_;
     154              :     uint64_t inputAddr_{0};
     155              :     uint64_t outputAddr_{0};
     156              :     uint64_t token_{0};
     157              :     uint64_t bigDataSliceSize_{0};
     158              :     uint64_t bigDataSliceNum_{0};
     159              :     uint64_t smallDataSliceSize_{0};
     160              :     uint64_t smallDataSliceNum_{0};
     161              :     uint64_t inputRepeatStride_{0};
     162              :     uint64_t outputRepeatStride_{0};
     163              :     uint64_t repeatNumVar_{0};
     164              :     uint64_t normalSliceSize_{0};
     165              :     uint64_t lastSliceSize_{0};
     166              : };
     167              : 
     168              : } // namespace Hccl
     169              : #endif // HCCLV2_CCU_INSTRUCTION_REDUCE_MESH_1D_MEM2MEM_H_
        

Generated by: LCOV version 2.0-1