LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/ccu/ccu_manager - ccu_respack_mgr.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 85.0 % 20 17
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 4 4

            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_respack_mgr.h"
      12              : #include "internal_exception.h"
      13              : 
      14              : namespace Hccl {
      15              : 
      16              : // 新增空的CcuResPack,同时内部做标记,用于回退
      17            8 : void CcuResPackMgr::PrepareAlloc(u32 size)
      18              : {
      19            8 :     if (resPacks.size() < size) {
      20            8 :         unConfirmedNum = size - resPacks.size();
      21            8 :         resPacks.resize(size);
      22              :     }
      23              : 
      24           24 :     HCCL_INFO(
      25              :         "[CcuResPackMgr][PrepareAlloc] CcuResPack need size[%u], current resPacks size[%zu], unConfirmedNum[%u]", size,
      26              :         resPacks.size(), unConfirmedNum);
      27            8 : }
      28              : 
      29              : // 确认新增的资源,未来不可回退(对之前调用PrepareXxx()新增的资源,取消标记)
      30            3 : void CcuResPackMgr::Confirm() { unConfirmedNum = 0; }
      31              : 
      32              : // 对新增的资源进行回退
      33            4 : void CcuResPackMgr::Fallback()
      34              : {
      35            9 :     for (u32 idx = 0; idx < unConfirmedNum; ++idx) {
      36            5 :         if (resPacks[idx].handles.size() != 0) {
      37            0 :             HCCL_WARNING(
      38              :                 "[CcuResPackMgr][Fallback]resPacks idx[%u] has handles size[%u], not empty", idx,
      39              :                 resPacks[idx].handles.size());
      40              :         }
      41            5 :         resPacks.pop_back();
      42              :     }
      43            4 :     unConfirmedNum = 0;
      44            4 : }
      45              : 
      46              : // 获取idx对应的CcuResPack
      47            1 : CcuResPack& CcuResPackMgr::GetCcuResPack(u32 idx)
      48              : {
      49            1 :     u32 size = resPacks.size();
      50            1 :     if (size <= idx) {
      51            0 :         THROW<InternalException>(
      52            0 :             StringFormat("[CcuResPackMgr][GetCcuResPack] idx[%u] is bigger than resPacks size[%u]", idx, size));
      53              :     }
      54            1 :     return resPacks[idx];
      55              : }
      56              : 
      57              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1