LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_ccu_context/reduce - ccu_instruction_reduce_mesh1d_two_shot_mem2mem.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 48 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 13 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_TWO_SHOT_MEM2MEM_H_
      12              : #define HCCLV2_CCU_INSTRUCTION_REDUCE_MESH_1D_TWO_SHOT_MEM2MEM_H_
      13              : 
      14              : #include <memory>
      15              : #include <map>
      16              : #include <vector>
      17              : #include <queue>
      18              : #include <string>
      19              : 
      20              : #include <sstream>
      21              : #include <ios>
      22              : #include <iostream>
      23              : 
      24              : #include "template_utils.h"
      25              : #include "instruction.h"
      26              : #include "ins_queue.h"
      27              : #include "ccu_context_utils.h"
      28              : #include "ccu_ctx_signature.h"
      29              : #include "ccu_ins.h"
      30              : #include "ccu_rank_group.h"
      31              : 
      32              : namespace Hccl {
      33              : 
      34              : // 为ReduceMeshTwoShot1D实现的CCUIns、CCUCtxArg与CCUTaskArg
      35              : class CcuCtxArgReduceMeshTwoShotMem2Mem1D : public CcuCtxArg {
      36              : public:
      37            0 :     explicit CcuCtxArgReduceMeshTwoShotMem2Mem1D(
      38              :         const std::vector<uint64_t>& dimSize, uint32_t rankId, uint32_t rootId, const CollAlgOperator& op,
      39              :         const std::vector<std::vector<RankId>>& tempVTopo)
      40            0 :         : dimSize_(dimSize),
      41            0 :           rankId_(rankId),
      42            0 :           rootId_(rootId),
      43            0 :           op_(op),
      44            0 :           tempVTopo_(tempVTopo)
      45            0 :     {}
      46            0 :     CcuCtxSignature GetCtxSignature() const override
      47              :     {
      48            0 :         CcuCtxSignature signature;
      49            0 :         GenerateCcuCtxSignature(signature, CcuInstType::CCU_REDUCE_MESH_1D_TWO_SHOT_MEM2MEM, op_, tempVTopo_);
      50            0 :         return signature;
      51            0 :     }
      52              :     std::vector<uint64_t> dimSize_;
      53              :     uint32_t rankId_;
      54              :     uint32_t rootId_;
      55              :     CollAlgOperator op_;
      56              :     std::vector<std::vector<RankId>> tempVTopo_;
      57              : };
      58              : 
      59              : class CcuTaskArgReduceMeshTwoShotMem2Mem1D : public CcuTaskArg {
      60              : public:
      61            0 :     explicit CcuTaskArgReduceMeshTwoShotMem2Mem1D(
      62              :         uint64_t inputAddr, uint64_t outputAddr, uint64_t token, uint64_t scratchAddr, uint64_t normalSliceSize,
      63              :         uint64_t lastSliceSize, uint64_t mySliceSize)
      64            0 :         : inputAddr_(inputAddr),
      65            0 :           outputAddr_(outputAddr),
      66            0 :           token_(token),
      67            0 :           scratchAddr_(scratchAddr),
      68            0 :           normalSliceSize_(normalSliceSize),
      69            0 :           lastSliceSize_(lastSliceSize),
      70            0 :           mySliceSize_(mySliceSize)
      71            0 :     {}
      72              :     uint64_t inputAddr_;
      73              :     uint64_t outputAddr_;
      74              :     uint64_t token_;
      75              :     uint64_t scratchAddr_;
      76              :     uint64_t normalSliceSize_;
      77              :     uint64_t lastSliceSize_;
      78              :     uint64_t mySliceSize_;
      79              : };
      80              : 
      81              : class CcuInstructionReduceMeshTwoShotMem2Mem1D : public CcuInstruction {
      82              : public:
      83            0 :     CcuInstructionReduceMeshTwoShotMem2Mem1D() : CcuInstruction() {}
      84              : 
      85            0 :     void Init(
      86              :         uint32_t rankId, uint32_t rootId, const CollAlgOperator& op, const std::vector<std::vector<RankId>>& tempVTopo,
      87              :         uint64_t inputAddr, uint64_t outputAddr, uint64_t scratchAddr, uint64_t token, uint64_t normalSliceSize,
      88              :         uint64_t lastSliceSize, uint64_t mySliceSize)
      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 :         scratchAddr_ = scratchAddr;
      98            0 :         token_ = token;
      99            0 :         normalSliceSize_ = normalSliceSize;
     100            0 :         lastSliceSize_ = lastSliceSize;
     101            0 :         mySliceSize_ = mySliceSize;
     102              : 
     103            0 :         return;
     104              :     }
     105              : 
     106            0 :     std::string Describe() const override
     107              :     {
     108              :         return StringFormat(
     109            0 :             "CcuInstructionReduceMeshTwoShot1D rankId [%u], instType[%s]", rankId_, instType_.Describe().c_str());
     110              :     }
     111              : 
     112            0 :     CcuInstType GetInstType() const override { return instType_; }
     113              : 
     114              :     void SetInstType(CcuInstType instType) { instType_ = instType; }
     115              : 
     116            0 :     std::unique_ptr<CcuCtxArg> GetCtxArg() const override
     117              :     {
     118            0 :         return std::make_unique<CcuCtxArgReduceMeshTwoShotMem2Mem1D>(dimSize_, rankId_, rootId_, op_, tempVTopo_);
     119              :     }
     120              : 
     121            0 :     std::unique_ptr<CcuTaskArg> GetTaskArg() const override
     122              :     {
     123            0 :         return std::make_unique<CcuTaskArgReduceMeshTwoShotMem2Mem1D>(
     124            0 :             inputAddr_, outputAddr_, token_, scratchAddr_, normalSliceSize_, lastSliceSize_, mySliceSize_);
     125              :     }
     126              : 
     127            0 :     std::vector<LinkData> GetLinks() const override { return links_; }
     128              : 
     129            0 :     void SetLinks(std::vector<LinkData>& links) override { links_ = links; }
     130              : 
     131            0 :     RankGroup GetRankGroup() const override { return rankGroup_; }
     132              : 
     133            0 :     void SetRankGroup(RankGroup& rankGroup) override { rankGroup_ = rankGroup; }
     134              : 
     135              : private:
     136              :     CcuInstType instType_ = CcuInstType::CCU_REDUCE_MESH_1D_TWO_SHOT_MEM2MEM;
     137              :     std::vector<uint64_t> dimSize_;
     138              :     uint32_t rankId_{0};
     139              :     uint32_t rootId_{0};
     140              :     CollAlgOperator op_;
     141              :     std::vector<std::vector<RankId>> tempVTopo_;
     142              :     uint64_t inputAddr_{0};
     143              :     uint64_t outputAddr_{0};
     144              :     uint64_t token_{0};
     145              :     uint64_t scratchAddr_{0};
     146              :     uint64_t normalSliceSize_{0};
     147              :     uint64_t lastSliceSize_{0};
     148              :     uint64_t mySliceSize_{0};
     149              :     RankGroup rankGroup_;
     150              :     std::vector<LinkData> links_;
     151              : };
     152              : 
     153              : } // namespace Hccl
     154              : #endif // HCCLV2_CCU_INSTRUCTION_REDUCE_MESH_1D_TWO_SHOT_MEM2MEM_H_
        

Generated by: LCOV version 2.0-1