LCOV - code coverage report
Current view: top level - base_comm/resources/ccu/ccu_representation/reps/sync - ccu_rep_loc_wait_event.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 22 22
Test Date: 2026-08-04 10:52:23 Functions: 100.0 % 5 5

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 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_loc_wait_event.h"
      12              : #include <climits>
      13              : #include "ccu_rep_v1.h"
      14              : #include "string_util.h"
      15              : #include "exception_util.h"
      16              : #include "ccu_api_exception.h"
      17              : #include "ccu_ins_generator_v1.h"
      18              : #include "ccu_kernel.h"
      19              : namespace hcomm {
      20              : namespace CcuRep {
      21              : 
      22           39 : CcuRepLocWaitEvent::CcuRepLocWaitEvent(CcuInsGeneratorBase* insGenPtr, const CompletedEvent &event, uint32_t mask, bool isProfiling)
      23           39 :     : insGenPtr(insGenPtr), event_(event), mask_(mask), isProfiling_(isProfiling)
      24              : {
      25           39 :     type       = CcuRepType::LOC_WAIT_EVENT;
      26           39 :     instrCount = insGenPtr->GetInstrCount(type);
      27           39 : }
      28              : 
      29           33 : void CcuRepLocWaitEvent::SetDependencyInfo(const std::unordered_map<uint32_t, std::vector<std::shared_ptr<CcuRepBase>>>& depInfo)
      30              : {
      31           33 :     depInfo_ = depInfo;
      32           33 : }
      33              : 
      34            2 : std::vector<std::shared_ptr<CcuRepBase>> CcuRepLocWaitEvent::GetDependencyInfo(uint32_t bit) {
      35              :     // 查找给定 bit 是否存在于 depInfo_ 中
      36            2 :     auto it = depInfo_.find(bit);
      37              :     // 如果找到 bit,返回与之关联的 vector
      38            2 :     if (it != depInfo_.end()) {
      39            1 :         return it->second;
      40              :     }
      41              :     // 如果未找到 bit,返回一个空的 vector
      42            1 :     return std::vector<std::shared_ptr<CcuRepBase>>();
      43              : }
      44              : 
      45           30 : bool CcuRepLocWaitEvent::Translate(CcuKernel* ccuKernel, CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
      46              : {
      47           30 :     this->instrId = instrId;
      48           30 :     translated    = true;
      49              : 
      50           30 :     insGenPtr->CcuRepLocWaitEventTranslate(ccuKernel, instr, this);
      51              :     
      52           30 :     CHK_PRT_THROW((instrId > UINT16_MAX - instrCount),
      53              :         HCCL_ERROR("[CcuRepLocWaitEvent::Translate]uint16 integer overflow occurs, "
      54              :             "instrId = [%hu], instrCount = [%hu]", instrId, instrCount),
      55              :         Hccl::CcuApiException, "integer overflow");
      56           30 :     instrId += instrCount;
      57           30 :     return translated;
      58              : }
      59              : 
      60           29 : std::string CcuRepLocWaitEvent::Describe()
      61              : {
      62           29 :     return Hccl::StringFormat("CcuRepLocWaitEvent=id[%u], mask[%04x]", event_.Id(), mask_);
      63              : }
      64              : 
      65              : }; // namespace CcuRep
      66              : }; // namespace hcomm
        

Generated by: LCOV version 2.0-1