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.1 % 34 33
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 8 8

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2026 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              : #include "ccu_rep_v1.h"
      12              : #include "ccu_ins_generator_base.h"
      13              : #include "string_util.h"
      14              : #include "ccu_kernel.h"
      15              : 
      16              : namespace hcomm {
      17              : namespace CcuRep {
      18              : 
      19          529 :     CcuRepBlock::CcuRepBlock(CcuInsGeneratorBase* insGenPtr, const std::string& label)
      20          529 :         : insGeneratorPtr_(insGenPtr),
      21          529 :           label(label)
      22              :     {
      23          529 :         type = CcuRepType::BLOCK;
      24          529 :         instrCount = 0;
      25          529 :     }
      26              : 
      27          686 :     std::vector<std::shared_ptr<CcuRepBase>>& CcuRepBlock::GetReps() { return repVec; }
      28              : 
      29         1500 :     void CcuRepBlock::Append(std::shared_ptr<CcuRepBase> rep) { repVec.push_back(rep); }
      30              : 
      31          279 :     const std::string& CcuRepBlock::GetLabel() const { return label; }
      32              : 
      33          619 :     uint16_t CcuRepBlock::InstrCount()
      34              :     {
      35          619 :         instrCount = 0;
      36         1374 :         for (const auto& repInBlock : repVec) {
      37          755 :             instrCount += repInBlock->InstrCount();
      38              :         }
      39          619 :         return instrCount;
      40              :     }
      41              : 
      42          189 :     bool CcuRepBlock::Translate(CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, const TransDep& dep)
      43              :     {
      44          189 :         this->instrId = instrId;
      45          189 :         translated = true;
      46              : 
      47          189 :         constexpr uint16_t numberTwo = 2; // 暂定repBlock中的rep遍历2次,后续优化
      48          567 :         for (uint16_t i = 0; i < numberTwo; i++) {
      49          812 :             for (const auto& repInBlock : GetReps()) {
      50          434 :                 if (!repInBlock->Translated()) {
      51          217 :                     repInBlock->Translate(ccuKernel, instr, instrId, dep);
      52              :                 }
      53              :             }
      54              :         }
      55              : 
      56          189 :         return translated;
      57              :     }
      58              : 
      59            1 :     std::string CcuRepBlock::Describe() { return Hccl::StringFormat("RepBlock"); }
      60              : 
      61            2 :     std::shared_ptr<CcuRepBase> CcuRepBlock::GetRepByInstrId(uint16_t instrId)
      62              :     {
      63            3 :         for (const auto& rep : GetReps()) {
      64            2 :             const uint16_t repCount = rep->InstrCount();
      65            2 :             if (repCount == 0) {
      66            0 :                 continue;
      67              :             }
      68            2 :             const uint16_t startId = rep->StartInstrId();
      69            2 :             const uint16_t endId = startId + repCount - 1;
      70            2 :             if (instrId >= startId && instrId <= endId) {
      71            1 :                 return rep;
      72              :             }
      73              :         }
      74            1 :         return nullptr;
      75              :     }
      76              : 
      77              : }; // namespace CcuRep
      78              : }; // namespace hcomm
        

Generated by: LCOV version 2.0-1