LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_representation/reps/data - ccu_rep_loccpy.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 65.9 % 41 27
Test Date: 2026-07-28 12:11:00 Functions: 62.5 % 8 5

            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 "string_util.h"
      10              : #include "ccu_ins_generater_v1.h"
      11              : #include "ccu_ins_generater_base.h"
      12              : #include "ccu_kernel.h"
      13              : 
      14              : #include "ccu_api_exception.h"
      15              : 
      16              : namespace hcomm {
      17              : namespace CcuRep {
      18              : 
      19            3 : CcuRepLocCpy::CcuRepLocCpy(CcuInsGeneraterBase* insGenPtr, LocalAddr dst, LocalAddr src, Variable len, CompletedEvent sem, uint16_t mask)
      20            3 :     : insGenPtr(insGenPtr), dst(dst), src(src), len(len), sem(sem), mask(mask)
      21              : {
      22            3 :     type       = CcuRepType::LOCAL_CPY;
      23            3 :     instrCount = insGenPtr->GetInstrCount(type);
      24            3 :     useCcuBuffer = false;
      25            3 : }
      26              : 
      27            2 : CcuRepLocCpy::CcuRepLocCpy(CcuInsGeneraterBase* insGenPtr, LocalAddr dst, LocalAddr src, Variable len, uint16_t dataType, uint16_t opType, CompletedEvent sem,
      28            2 :                            uint16_t mask)
      29            2 :     : insGenPtr(insGenPtr), dst(dst), src(src), len(len), sem(sem), mask(mask), dataType(dataType), opType(opType) 
      30              : {
      31            2 :     type       = CcuRepType::LOCAL_REDUCE;
      32            2 :     instrCount = insGenPtr->GetInstrCount(type);
      33            2 :     reduceFlag = 1;
      34              :     // A5和A6都走环回
      35            2 :     useCcuBuffer = false;
      36            2 : }
      37              : 
      38            0 : CcuRepLocCpy::CcuRepLocCpy(CcuInsGeneraterBase* insGenPtr, LocalAddr dst, LocalAddr src, Variable len,
      39            0 :                            const std::vector<CcuBuf> &bufs, CompletedEvent sem, uint16_t mask)
      40            0 :     : insGenPtr(insGenPtr), dst(dst), src(src), len(len), bufs(bufs), sem(sem), mask(mask)
      41              : {
      42            0 :     type       = CcuRepType::LOCAL_CPY;
      43            0 :     instrCount = insGenPtr->GetInstrCount(type);
      44            0 :     useCcuBuffer = true;
      45            0 : }
      46              : 
      47            2 : void CcuRepLocCpy::ValidateInsGeneratorForLocCpy()
      48              : {
      49            2 :     CcuInsGeneraterV1* tmpPtrV1 = dynamic_cast<CcuInsGeneraterV1*>(insGenPtr);
      50            2 :     if (tmpPtrV1 && useCcuBuffer) {
      51              :         // 使用了A6场景的ms中转搬运
      52            0 :         Hccl::THROW<Hccl::CcuApiException>("Cannot translate CcuRepLocCpy for A5 when useCcuBuffer is true!");
      53              :     }
      54            2 : }
      55              : 
      56            0 : uint16_t CcuRepLocCpy::GetFirstBufId()
      57              : {
      58            0 :     if (bufs.size() == 0) {
      59            0 :         Hccl::THROW<Hccl::CcuApiException>("The length of CcuBuffer is 0!");
      60              :     }
      61            0 :     return bufs[0].Id();
      62              : }
      63              :     
      64            0 : uint16_t CcuRepLocCpy::GetUsedBufNum()
      65              : {
      66            0 :     return bufs.size();
      67              : }
      68              : 
      69            2 : bool CcuRepLocCpy::Translate(CcuKernel* ccuKernel, CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
      70              : {
      71            2 :     ValidateInsGeneratorForLocCpy();
      72              : 
      73            2 :     this->instrId = instrId;
      74            2 :     translated    = true;
      75              : 
      76            2 :     insGenPtr->CcuRepLocCpyTranslate(ccuKernel, instr, this, dep);
      77            2 :     instrId += instrCount;
      78              : 
      79            2 :     return translated;
      80              : }
      81              : 
      82            1 : std::string CcuRepLocCpy::Describe()
      83              : {
      84              :     return Hccl::StringFormat(
      85              :         "Read LocalAddr[%u] to LocalAddr[%u], length[%u], set sem[%u] with mask[%04x], dataType[%u], opType[%u]",
      86            1 :         src.addr.Id(), dst.addr.Id(), len.Id(), sem.Id(), mask, dataType, opType);
      87              : }
      88              : 
      89              : }; // namespace CcuRep
      90              : }; // namespace hcomm
        

Generated by: LCOV version 2.0-1