LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_representation/reps/loop - ccu_rep_loopcall.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 98.4 % 62 61
Test Date: 2026-08-04 10:52:23 Functions: 100.0 % 14 14

            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              : 
      10              : #include "string_util.h"
      11              : #include "exception_util.h"
      12              : #include "ccu_api_exception.h"
      13              : #include "ccu_ins_generator_base.h"
      14              : #include "ccu_kernel.h"
      15              : 
      16              : namespace hcomm {
      17              : namespace CcuRep {
      18              : 
      19              : using namespace Hccl;
      20              : 
      21           12 : CcuRepLoopCall::CcuRepLoopCall(CcuInsGeneratorBase* insGeneratorPtr, const std::string &label) :
      22           12 :     insGeneratorPtr_(insGeneratorPtr), label(label)
      23              : {
      24           12 :     type = CcuRepType::LOOP_CALL;
      25           12 : }
      26              : 
      27            2 : const std::string &CcuRepLoopCall::GetLabel() const
      28              : {
      29            2 :     return label;
      30              : }
      31              : 
      32            2 : void CcuRepLoopCall::Reference(std::shared_ptr<CcuRepLoopBlock> refRep)
      33              : {
      34            2 :     loopBlock = refRep;
      35            2 : }
      36              : 
      37            2 : void CcuRepLoopCall::SetInArg(const Variable &var)
      38              : {
      39            2 :     inArgCount++;
      40            2 :     inArgInstrCount++;
      41            2 :     inArgs.push_back(CcuRepArg(var));
      42            2 : }
      43              : 
      44            1 : void CcuRepLoopCall::SetInArg(const std::vector<Variable> &varList)
      45              : {
      46            1 :     inArgCount += varList.size();
      47            1 :     inArgInstrCount += varList.size();
      48            1 :     inArgs.push_back(CcuRepArg(varList));
      49            1 : }
      50              : 
      51            1 : void CcuRepLoopCall::SetInArg(const Memory &mem)
      52              : {
      53            1 :     inArgCount++;
      54            1 :     inArgInstrCount += 2; // 传递Memory需要2条指令
      55            1 :     inArgs.push_back(CcuRepArg(mem));
      56            1 : }
      57              : 
      58            1 : void CcuRepLoopCall::SetInArg(const std::vector<Memory> &memList)
      59              : {
      60            1 :     inArgCount += memList.size();
      61            1 :     inArgInstrCount += memList.size() * 2; // 传递Memory需要2条指令
      62            1 :     inArgs.push_back(CcuRepArg(memList));
      63            1 : }
      64              : 
      65              : /*【新增】*/
      66            2 : void CcuRepLoopCall::SetInArg(const LocalAddr &addr)
      67              : {
      68            2 :     inArgCount++;
      69            2 :     inArgInstrCount += 2; // 传递LocalAddr需要2条指令
      70            2 :     inArgs.push_back(CcuRepArg(addr));
      71            2 : }
      72              : 
      73            1 : void CcuRepLoopCall::SetInArg(const std::vector<LocalAddr> &addrList)
      74              : {
      75            1 :     inArgCount += addrList.size();
      76            1 :     inArgInstrCount += addrList.size() * 2; // 传递LocalAddr需要2条指令
      77            1 :     inArgs.push_back(CcuRepArg(addrList));
      78            1 : }
      79              : 
      80            1 : void CcuRepLoopCall::SetInArg(const RemoteAddr &addr)
      81              : {
      82            1 :     inArgCount++;
      83            1 :     inArgInstrCount += 2; // 传递RemoteAddr需要2条指令
      84            1 :     inArgs.push_back(CcuRepArg(addr));
      85            1 : }
      86              : 
      87            1 : void CcuRepLoopCall::SetInArg(const std::vector<RemoteAddr> &addrList)
      88              : {
      89            1 :     inArgCount += addrList.size();
      90            1 :     inArgInstrCount += addrList.size() * 2; // 传递RemoteAddr需要2条指令
      91            1 :     inArgs.push_back(CcuRepArg(addrList));
      92            1 : }
      93              : 
      94            9 : uint16_t CcuRepLoopCall::InstrCount()
      95              : {
      96            9 :     instrCount = inArgInstrCount;
      97            9 :     return instrCount;
      98              : }
      99              : 
     100            1 : bool CcuRepLoopCall::Translate(CcuKernel* ccuKernel, CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
     101              : {
     102            1 :     this->instrId = instrId;
     103            1 :     translated    = true;
     104              : 
     105            1 :     Hccl::CHECK_NULLPTR(loopBlock, "[CcuRepLoopCall::Translate] LoopBlock is nullptr!");
     106              : 
     107            1 :     if (!loopBlock->Translated()) {
     108            0 :         Hccl::THROW<Hccl::CcuApiException>("Reference To Invalid LoopBlock");
     109              :     }
     110              : 
     111            1 :     instrId += InstrCount();
     112              : 
     113            1 :     return translated;
     114              : }
     115              : 
     116            1 : std::string CcuRepLoopCall::Describe()
     117              : {
     118            1 :     return Hccl::StringFormat("LoopCall[%s]", label.c_str());
     119              : }
     120              : 
     121              : }; // namespace CcuRep
     122              : }; // namespace hcomm
        

Generated by: LCOV version 2.0-1