LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_ccu_context/reduce - ccu_instruction_reduce_mesh1d.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 61 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_H_
      12              : #define HCCLV2_CCU_INSTRUCTION_REDUCE_MESH_1D_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              : // 为ReduceMesh1D实现的CCUIns、CCUCtxArg与CCUTaskArg
      25              : class CcuCtxArgReduceMesh1D : public CcuCtxArg {
      26              : public:
      27            0 :     explicit CcuCtxArgReduceMesh1D(
      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_DIRECT, 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 CcuTaskArgReduceMesh1D : public CcuTaskArg {
      51              : public:
      52            0 :     explicit CcuTaskArgReduceMesh1D(
      53              :         uint64_t inputAddr, uint64_t outputAddr, uint64_t token, uint64_t inputSliceStride, uint64_t outputSliceStride,
      54              :         uint64_t repeatNum, uint64_t inputRepeatStride, uint64_t outputRepeatStride, uint64_t normalSliceSize,
      55              :         uint64_t lastSliceSize, uint64_t repeatNumVar)
      56            0 :         : inputAddr_(inputAddr),
      57            0 :           outputAddr_(outputAddr),
      58            0 :           token_(token),
      59            0 :           inputSliceStride_(inputSliceStride),
      60            0 :           outputSliceStride_(outputSliceStride),
      61            0 :           repeatNum_(repeatNum),
      62            0 :           inputRepeatStride_(inputRepeatStride),
      63            0 :           outputRepeatStride_(outputRepeatStride),
      64            0 :           normalSliceSize_(normalSliceSize),
      65            0 :           lastSliceSize_(lastSliceSize),
      66            0 :           repeatNumVar_(repeatNumVar)
      67            0 :     {}
      68              : 
      69              :     uint64_t inputAddr_;
      70              :     uint64_t outputAddr_;
      71              :     uint64_t token_;
      72              :     uint64_t inputSliceStride_;
      73              :     uint64_t outputSliceStride_;
      74              :     uint64_t repeatNum_;
      75              :     uint64_t inputRepeatStride_;
      76              :     uint64_t outputRepeatStride_;
      77              :     uint64_t normalSliceSize_;
      78              :     uint64_t lastSliceSize_;
      79              :     uint64_t repeatNumVar_;
      80              : };
      81              : 
      82              : class CcuInstructionReduceMesh1D : public CcuInstruction {
      83              : public:
      84            0 :     CcuInstructionReduceMesh1D() : CcuInstruction() {}
      85              : 
      86            0 :     void Init(
      87              :         uint32_t rankId, uint32_t rootId, const CollAlgOperator& op, const std::vector<std::vector<RankId>>& tempVTopo,
      88              :         uint64_t inputAddr, uint64_t outputAddr, uint64_t token, uint64_t inputSliceStride, uint64_t outputSliceStride,
      89              :         uint64_t repeatNum, uint64_t inputRepeatStride, uint64_t outputRepeatStride, uint64_t normalSliceSize,
      90              :         uint64_t lastSliceSize, uint64_t repeatNumVar)
      91              :     {
      92            0 :         u32 maxDimNum = 1;
      93            0 :         if (tempVTopo.size() != maxDimNum) {
      94            0 :             THROW<InvalidParamsException>(
      95            0 :                 StringFormat("[CcuInstructionReduceMesh1D] tempVTopo size is not 1, size is [%zu].", tempVTopo.size()));
      96              :         }
      97            0 :         dimSize_.push_back(tempVTopo[0].size());
      98            0 :         rankId_ = rankId;
      99            0 :         rootId_ = rootId;
     100            0 :         repeatNum_ = repeatNum;
     101            0 :         op_ = op;
     102            0 :         tempVTopo_ = tempVTopo;
     103            0 :         inputAddr_ = inputAddr;
     104            0 :         outputAddr_ = outputAddr;
     105            0 :         inputSliceStride_ = inputSliceStride;
     106            0 :         outputSliceStride_ = outputSliceStride;
     107            0 :         inputRepeatStride_ = inputRepeatStride;
     108            0 :         outputRepeatStride_ = outputRepeatStride;
     109            0 :         normalSliceSize_ = normalSliceSize;
     110            0 :         lastSliceSize_ = lastSliceSize;
     111            0 :         repeatNumVar_ = repeatNumVar;
     112            0 :         token_ = token;
     113            0 :         return;
     114              :     }
     115              : 
     116            0 :     CcuInstType GetInstType() const override
     117              :     {
     118            0 :         HCCL_INFO("CcuInstructionReduceMesh1D instype is CCU_REDUCE_MESH_1D_DIRECT.");
     119            0 :         return instType_;
     120              :     }
     121              : 
     122            0 :     std::string Describe() const override
     123              :     {
     124            0 :         return StringFormat("CcuInstructionReduceMesh1D rankId [%u], instType[%d]", rankId_, instType_);
     125              :     }
     126              : 
     127              :     void SetInstType(CcuInstType instType) { instType_ = instType; }
     128              : 
     129            0 :     std::unique_ptr<CcuCtxArg> GetCtxArg() const override
     130              :     {
     131            0 :         HCCL_INFO("[CcuInstructionReduceMesh1D] GetCtxArg begin");
     132            0 :         return std::make_unique<CcuCtxArgReduceMesh1D>(dimSize_, rankId_, rootId_, op_, tempVTopo_);
     133              :     }
     134              : 
     135            0 :     std::unique_ptr<CcuTaskArg> GetTaskArg() const override
     136              :     {
     137            0 :         HCCL_INFO("[CcuInstructionReduceMesh1D] GetTaskArg begin");
     138            0 :         return std::make_unique<CcuTaskArgReduceMesh1D>(
     139            0 :             inputAddr_, outputAddr_, token_, inputSliceStride_, outputSliceStride_, repeatNum_, inputRepeatStride_,
     140            0 :             outputRepeatStride_, normalSliceSize_, lastSliceSize_, repeatNumVar_);
     141              :     }
     142              : 
     143              : private:
     144              :     CcuInstType instType_ = CcuInstType::CCU_REDUCE_MESH_1D_DIRECT;
     145              :     std::vector<uint64_t> dimSize_;
     146              :     uint32_t rankId_{0};
     147              :     uint32_t rootId_{0};
     148              :     CollAlgOperator op_;
     149              :     uint64_t token_{0};
     150              :     std::vector<std::vector<RankId>> tempVTopo_;
     151              :     uint64_t repeatNum_{0};
     152              :     uint64_t inputAddr_{0};
     153              :     uint64_t outputAddr_{0};
     154              :     uint64_t normalSliceSize_{0};
     155              :     uint64_t inputSliceStride_{0};
     156              :     uint64_t outputSliceStride_{0};
     157              :     uint64_t inputRepeatStride_{0};
     158              :     uint64_t outputRepeatStride_{0};
     159              :     uint64_t lastSliceSize_{0};
     160              :     uint64_t repeatNumVar_{0};
     161              : };
     162              : 
     163              : } // namespace Hccl
     164              : #endif // HCCLV2_CCU_INSTRUCTION_REDUCE_MESH_1D_H_
        

Generated by: LCOV version 2.0-1