LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_representation/reps/common - ccu_rep_block.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 97.4 % 38 37
Test Date: 2026-07-28 12:11:00 Functions: 100.0 % 8 8

            Line data    Source code
       1              : /*
       2              :  * Copyright (c) Huawei Technologies Co., Ltd. 2024-2024. All rights reserved.
       3              :  * Description: ccu representation implementation file
       4              :  * Author: sunzhepeng
       5              :  * Create: 2024-06-17
       6              :  */
       7              : 
       8              : #include "ccu_rep_v1.h"
       9              : #include "ccu_ins_generater_base.h"
      10              : #include "string_util.h"
      11              : #include "ccu_kernel.h"
      12              : 
      13              : namespace hcomm{
      14              : namespace CcuRep {
      15              : 
      16          269 : CcuRepBlock::CcuRepBlock(CcuInsGeneraterBase* insGenPtr, const std::string &label) :
      17          269 :     insGeneratorPtr_(insGenPtr), label(label)
      18              : {
      19          269 :     type = CcuRepType::BLOCK;
      20          269 :     instrCount = 0;
      21          269 : }
      22              : 
      23          270 : std::vector<std::shared_ptr<CcuRepBase>> &CcuRepBlock::GetReps()
      24              : {
      25          270 :     return repVec;
      26              : }
      27              : 
      28          555 : void CcuRepBlock::Append(std::shared_ptr<CcuRepBase> rep)
      29              : {
      30          555 :     repVec.push_back(rep);
      31          555 : }
      32              : 
      33          114 : const std::string &CcuRepBlock::GetLabel() const
      34              : {
      35          114 :     return label;
      36              : }
      37              : 
      38          204 : uint16_t CcuRepBlock::InstrCount()
      39              : {   
      40          204 :     instrCount = 0;
      41          490 :     for (const auto &repInBlock : repVec) {
      42          286 :         instrCount += repInBlock->InstrCount();
      43              :     }
      44          204 :     return instrCount;
      45              : }
      46              : 
      47           60 : bool CcuRepBlock::Translate(CcuKernel* ccuKernel, CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
      48              : {
      49           60 :     this->instrId = instrId;
      50           60 :     translated    = true;
      51              : 
      52           60 :     constexpr uint16_t numberTwo = 2;  // 暂定repBlock中的rep遍历2次,后续优化
      53          180 :     for (uint16_t i = 0; i < numberTwo; i++) {
      54          272 :         for (const auto &repInBlock : GetReps()) {
      55          152 :             if (!repInBlock->Translated()) {
      56           76 :                 repInBlock->Translate(ccuKernel, instr, instrId, dep);
      57              :             }
      58              :         }
      59              :     }
      60              : 
      61           60 :     return translated;
      62              : }
      63              : 
      64            1 : std::string CcuRepBlock::Describe()
      65              : {
      66            1 :     return Hccl::StringFormat("RepBlock");
      67              : }
      68              : 
      69            2 : std::shared_ptr<CcuRepBase> CcuRepBlock::GetRepByInstrId(uint16_t instrId)
      70              : {
      71            3 :     for (const auto& rep : GetReps()) {
      72            2 :         const uint16_t repCount = rep->InstrCount();
      73            2 :         if (repCount == 0) {
      74            0 :             continue;
      75              :         }
      76            2 :         const uint16_t startId = rep->StartInstrId();
      77            2 :         const uint16_t endId = startId + repCount - 1;
      78            2 :         if (instrId >= startId && instrId <= endId) {
      79            1 :             return rep;
      80              :         }
      81              :     }
      82            1 :     return nullptr;
      83              : }
      84              : 
      85              : }; // namespace CcuRep
      86              : }; // namespace hcomm
        

Generated by: LCOV version 2.0-1