LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_representation/reps/data - ccu_rep_write.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 35 35
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 4 4

            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              : 
      13              : #include "string_util.h"
      14              : #include "exception_util.h"
      15              : #include "hcomm_c_adpt.h"
      16              : #include "ccu_api_exception.h"
      17              : #include "ccu_ins_generator_v1.h"
      18              : #include "../../../../endpoint_pairs/channels/ccu/ccu_urma_channel.h"
      19              : #include "ccu_kernel.h"
      20              : #include "ccu_ins_generator_base.h"
      21              : 
      22              : namespace hcomm {
      23              : namespace CcuRep {
      24              : 
      25            7 :     CcuRepWrite::CcuRepWrite(
      26              :         CcuInsGeneratorBase* insGenPtr, const ChannelHandle channel, RemoteAddr rem, LocalAddr loc, Variable len,
      27            7 :         CompletedEvent sem, uint16_t mask)
      28            7 :         : insGenPtr(insGenPtr),
      29            7 :           channel(channel),
      30            7 :           rem(rem),
      31            7 :           loc(loc),
      32            7 :           len(len),
      33            7 :           sem(sem),
      34            7 :           mask(mask)
      35              :     {
      36            7 :         type = CcuRepType::WRITE;
      37            7 :         instrCount = insGenPtr->GetInstrCount(type);
      38            7 :     }
      39              : 
      40            3 :     CcuRepWrite::CcuRepWrite(
      41              :         CcuInsGeneratorBase* insGenPtr, const ChannelHandle channel, RemoteAddr rem, LocalAddr loc, Variable len,
      42            3 :         uint16_t dataType, uint16_t opType, CompletedEvent sem, uint16_t mask)
      43            3 :         : insGenPtr(insGenPtr),
      44            3 :           channel(channel),
      45            3 :           rem(rem),
      46            3 :           loc(loc),
      47            3 :           len(len),
      48            3 :           sem(sem),
      49            3 :           mask(mask),
      50            3 :           dataType(dataType),
      51            3 :           opType(opType),
      52            3 :           reduceFlag(1)
      53              :     {
      54            3 :         type = CcuRepType::WRITE;
      55            3 :         instrCount = insGenPtr->GetInstrCount(type);
      56            3 :     }
      57              : 
      58            3 :     bool CcuRepWrite::Translate(
      59              :         CcuKernel* ccuKernel, CcuInstr*& instr, uint16_t& instrId, [[maybe_unused]] const TransDep& dep)
      60              :     {
      61            3 :         this->instrId = instrId;
      62            3 :         translated = true;
      63              : 
      64            3 :         CHK_PRT_THROW(
      65              :             insGenPtr->CcuRepWriteTranslate(ccuKernel, instr, this) != HcclResult::HCCL_SUCCESS,
      66              :             HCCL_ERROR("[CcuRepWrite][Translate] failed to translate for instrId[%u]", instrId), Hccl::CcuApiException,
      67              :             "CcuRepWrite translate failed");
      68            3 :         instrId += instrCount;
      69              : 
      70            3 :         return translated;
      71              :     }
      72              : 
      73            4 :     std::string CcuRepWrite::Describe()
      74              :     {
      75              :         return Hccl::StringFormat(
      76              :             "Write RemoteAddr[%u] to LocalAddr[%u], length[%u], set sem[%u] with mask[%04x], dataType[%u], opType[%u]",
      77            4 :             loc.addr.Id(), rem.addr.Id(), len.Id(), sem.Id(), mask, dataType, opType);
      78              :     }
      79              : 
      80              : }; // namespace CcuRep
      81              : }; // namespace hcomm
        

Generated by: LCOV version 2.0-1