LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/ccu/ccu_representation/reps/sync - ccu_rep_locwaitsem.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 82.1 % 28 23
Test Date: 2026-08-04 10:52:23 Functions: 83.3 % 6 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.h"
      12              : #include <climits>
      13              : 
      14              : #include "string_util.h"
      15              : 
      16              : namespace Hccl {
      17              : namespace CcuRep {
      18              : 
      19          119 : CcuRepLocWaitSem::CcuRepLocWaitSem(const MaskSignal &sem, uint16_t mask, bool isProfiling) : sem(sem), mask(mask), isProfiling(isProfiling)
      20              : {
      21          119 :     type       = CcuRepType::LOC_WAIT_SEM;
      22          119 :     instrCount = 1;
      23          119 : }
      24              : 
      25           32 : uint16_t CcuRepLocWaitSem::GetSemId() const
      26              : {
      27           32 :     return sem.Id();
      28              : }
      29              : 
      30           45 : void CcuRepLocWaitSem::SetDependencyInfo(const std::unordered_map<uint32_t, std::vector<std::shared_ptr<CcuRepBase>>>& depInfo) {
      31           45 :     depInfo_ = depInfo;
      32           45 : }
      33              : 
      34            0 : std::vector<std::shared_ptr<CcuRepBase>> CcuRepLocWaitSem::GetDependencyInfo(uint32_t bit) {
      35              :     // 查找给定 bit 是否存在于 depInfo_ 中
      36            0 :     auto it = depInfo_.find(bit);
      37              :     // 如果找到 bit,返回与之关联的 vector
      38            0 :     if (it != depInfo_.end()) {
      39            0 :         return it->second;
      40              :     }
      41              :     // 如果未找到 bit,返回一个空的 vector
      42            0 :     return std::vector<std::shared_ptr<CcuRepBase>>();
      43              : }
      44              : 
      45           27 : bool CcuRepLocWaitSem::Translate(CcuInstr *&instr, uint16_t &instrId, const TransDep &dep)
      46              : {
      47           27 :     this->instrId = instrId;
      48           27 :     translated    = true;
      49              : 
      50              :     // 需要profiling的使用SetCKEInstr, 否则使用ClearCKEInstr
      51           27 :     if (isProfiling) {
      52           15 :         SetCKEInstr(instr++, 0, 0, sem.Id(), mask, 1);
      53              :     } else {
      54           12 :         ClearCKEInstr(instr++, 0, 0, sem.Id(), mask, 1);
      55              :     }
      56              : 
      57           27 :     if (instrId > USHRT_MAX - instrCount) {
      58            2 :         THROW<InternalException>(StringFormat("[CcuRepLocWaitSem][Translate] instrId[%u] + instrCount[%u] exceeds the "
      59            1 :             "maximum value of unsigned short int.", instrId, instrCount));
      60              :     }
      61           26 :     CHK_PRT_THROW((instrId > UINT16_MAX - instrCount),
      62              :                         HCCL_ERROR("[CcuRepLocWaitSem::Translate]uint16 integer overflow occurs, instrId = [%hu], instrCount = [%hu]", instrId, instrCount),
      63              :                           InternalException, "integer overflow");
      64           26 :     instrId += instrCount;
      65              : 
      66           26 :     return translated;
      67              : }
      68              : 
      69           30 : std::string CcuRepLocWaitSem::Describe()
      70              : {
      71           30 :     return StringFormat("Wait Sem[%u], mask[%04x]", sem.Id(), mask);
      72              : }
      73              : 
      74              : }; // namespace CcuRep
      75              : }; // namespace Hccl
        

Generated by: LCOV version 2.0-1