LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_ccu_context/all_reduce - ccu_instruction_all_reduce_mesh2d_two_shot.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 41 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_ALL_REDUCE_MESH_2D_TWO_SHOT_H_
      12              : #define HCCLV2_CCU_INSTRUCTION_ALL_REDUCE_MESH_2D_TWO_SHOT_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              : // 为AllReduceMesh2DTwoShot实现的CCUIns、CCUCtxArg与CCUTaskArg
      25              : class CcuCtxArgAllReduceMesh2DTwoShot : public CcuCtxArg {
      26              : public:
      27            0 :     explicit CcuCtxArgAllReduceMesh2DTwoShot(const std::vector<uint64_t> &dSize, uint32_t rId, uint32_t axisId,
      28              :                                              const CollAlgOperator                  &op,
      29              :                                              const std::vector<std::vector<RankId>> &tempVTopo)
      30            0 :         : dimSize_(dSize), rankId_(rId), axisId_(axisId), op_(op), tempVTopo_(tempVTopo)
      31              :     {
      32            0 :     }
      33            0 :     CcuCtxSignature GetCtxSignature() const override
      34              :     {
      35            0 :         CcuCtxSignature signature;
      36            0 :         GenerateCcuCtxSignature(signature, CcuInstType::CCU_ALL_REDUCE_MESH_2D_TWO_SHOT_DIRECT, op_, tempVTopo_);
      37            0 :         return signature;
      38            0 :     }
      39              : 
      40              :     std::vector<uint64_t>            dimSize_;
      41              :     uint32_t                         rankId_;
      42              :     uint32_t                         axisId_;
      43              :     CollAlgOperator                  op_;
      44              :     std::vector<std::vector<RankId>> tempVTopo_;
      45              : };
      46              : 
      47              : class CcuTaskArgAllReduceMesh2DTwoShot : public CcuTaskArg {
      48              : public:
      49            0 :     explicit CcuTaskArgAllReduceMesh2DTwoShot(uint64_t inputAddr, uint64_t outputAddr, uint64_t normalRankXSliceSize,
      50              :                                               uint64_t normalRankYSliceSize, uint64_t lastRankXSliceSize,
      51              :                                               uint64_t lastRankYSliceSize, uint64_t token)
      52            0 :         : inputAddr_(inputAddr), outputAddr_(outputAddr), normalRankXSliceSize_(normalRankXSliceSize),
      53            0 :           normalRankYSliceSize_(normalRankYSliceSize), lastRankXSliceSize_(lastRankXSliceSize),
      54            0 :           lastRankYSliceSize_(lastRankYSliceSize), token_(token)
      55              :     {
      56            0 :     }
      57              :     uint64_t inputAddr_;
      58              :     uint64_t outputAddr_;
      59              :     uint64_t normalRankXSliceSize_;
      60              :     uint64_t normalRankYSliceSize_;
      61              :     uint64_t lastRankXSliceSize_;
      62              :     uint64_t lastRankYSliceSize_;
      63              :     uint64_t token_;
      64              : };
      65              : 
      66              : class CcuInstructionAllReduceMesh2DTwoShot : public CcuInstruction {
      67              : public:
      68            0 :     CcuInstructionAllReduceMesh2DTwoShot() : CcuInstruction()
      69              :     {
      70            0 :     }
      71              : 
      72            0 :     void Init(std::vector<uint64_t> &dimSize, uint32_t rankId, uint64_t inputAddr, uint64_t outputAddr, uint32_t axisId,
      73              :               uint64_t normalRankXSliceSize, uint64_t normalRankYSliceSize, uint64_t lastRankXSliceSize,
      74              :               uint64_t lastRankYSliceSize, uint64_t token, CollAlgOperator &op,
      75              :               std::vector<std::vector<RankId>> &tempVTopo)
      76              :     {
      77            0 :         dimSize_    = dimSize;
      78            0 :         rankId_     = rankId;
      79            0 :         outputAddr_ = outputAddr;
      80            0 :         inputAddr_  = inputAddr;
      81            0 :         normalRankXSliceSize_ = normalRankXSliceSize;
      82            0 :         normalRankYSliceSize_ = normalRankYSliceSize;
      83            0 :         lastRankXSliceSize_   = lastRankXSliceSize;
      84            0 :         lastRankYSliceSize_   = lastRankYSliceSize;
      85            0 :         axisId_ = axisId;
      86            0 :         token_     = token;
      87            0 :         tempVTopo_ = tempVTopo;
      88            0 :         op_        = op;
      89            0 :         return;
      90              :     }
      91              : 
      92            0 :     CcuInstType GetInstType() const override
      93              :     {
      94            0 :         HCCL_INFO("CcuInstructionAllReduceMesh2DTwoShot instype is CCU_ALL_REDUCE_MESH_2D_TWO_SHOT_DIRECT.");
      95            0 :         return instType_;
      96              :     }
      97              : 
      98            0 :     std::string Describe() const override
      99              :     {
     100            0 :         return StringFormat("CcuInstructionAllReduceMesh2DTwoShot rankId [%u], instType[%s]", rankId_,
     101            0 :             instType_.Describe().c_str());
     102              :     }
     103              : 
     104            0 :     std::unique_ptr<CcuCtxArg> GetCtxArg() const override
     105              :     {
     106            0 :         return std::make_unique<CcuCtxArgAllReduceMesh2DTwoShot>(dimSize_, rankId_, axisId_, op_, tempVTopo_);
     107              :     }
     108              : 
     109              :     void SetInstType(CcuInstType instType) 
     110              :     { 
     111              :         instType_ = instType; 
     112              :     }
     113              : 
     114            0 :     std::unique_ptr<CcuTaskArg> GetTaskArg() const override
     115              :     {
     116            0 :         return std::make_unique<CcuTaskArgAllReduceMesh2DTwoShot>(inputAddr_, outputAddr_,
     117            0 :                                                                   normalRankXSliceSize_, normalRankYSliceSize_,
     118            0 :                                                                   lastRankXSliceSize_, lastRankYSliceSize_, token_);
     119              :     }
     120              : 
     121              : private:
     122              :     CcuInstType           instType_ = CcuInstType::CCU_ALL_REDUCE_MESH_2D_TWO_SHOT_DIRECT;
     123              :     std::vector<uint64_t> dimSize_;
     124              :     uint32_t rankId_{0};
     125              :     uint64_t inputAddr_{0};
     126              :     uint64_t outputAddr_{0};
     127              :     uint32_t axisId_{0};
     128              :     uint64_t normalRankXSliceSize_{0};
     129              :     uint64_t normalRankYSliceSize_{0};
     130              :     uint64_t lastRankXSliceSize_{0};
     131              :     uint64_t lastRankYSliceSize_{0};
     132              : 
     133              :     uint64_t                         token_{0};
     134              :     CollAlgOperator                  op_;
     135              :     std::vector<std::vector<RankId>> tempVTopo_;
     136              : };
     137              : 
     138              : } // namespace Hccl
     139              : #endif // HCCLV2_CCU_INSTRUCTION_ALL_REDUCE_MESH_2D_TWO_SHOT_H_
        

Generated by: LCOV version 2.0-1