LCOV - code coverage report
Current view: top level - aicpu_schedule/core/operator_kernel/control_flow - operator_kernel_unlock_table.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 22 22
Test Date: 2026-07-28 10:54:05 Functions: 100.0 % 2 2

            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              : #include "operator_kernel_unlock_table.h"
      11              : 
      12              : #include "aicpusd_status.h"
      13              : #include "aicpusd_model_execute.h"
      14              : #include "aicpusd_event_process.h"
      15              : #include "aicpusd_msg_send.h"
      16              : #include "aicpusd_resource_manager.h"
      17              : 
      18              : 
      19              : namespace AicpuSchedule {
      20              : namespace {
      21              : const std::string KERNEL_UNLOCK_TABLE = "unlockTable";
      22              : }  // namespace
      23              : 
      24            4 : int32_t OperatorKernelUnlockTable::Compute(const AicpuTaskInfo &kernelTaskInfo, const RunContext &taskContext)
      25              : {
      26            4 :     aicpusd_info("Start ModelUnlockTable. modelId=%u, streamId=%u, taskId=%u.",
      27              :                  taskContext.modelId, kernelTaskInfo.streamID, kernelTaskInfo.taskID);
      28            4 :     if (kernelTaskInfo.paraBase == 0UL) {
      29            1 :         aicpusd_err("kernelTaskInfo.paraBase is null");
      30            1 :         return AICPU_SCHEDULE_ERROR_PARAMETER_NOT_VALID;
      31              :     }
      32              : 
      33              :     const UnlockTableTaskParam * const unlockParam =
      34            3 :         PtrToPtr<void, UnlockTableTaskParam>(ValueToPtr(kernelTaskInfo.paraBase));
      35            3 :     const uint32_t tableId = unlockParam->tableId;
      36              : 
      37            3 :     const auto model = AicpuModelManager::GetInstance().GetModel(taskContext.modelId);
      38            3 :     if (model == nullptr) {
      39            1 :         aicpusd_err("Cannot get model by modelId:[%u], streamId[%u], taskId[%u].",
      40              :             taskContext.modelId, taskContext.streamId, kernelTaskInfo.taskID);
      41            1 :         return AICPU_SCHEDULE_ERROR_INNER_ERROR;
      42              :     }
      43            2 :     if (!model->IsTableLocked(tableId)) {
      44            1 :         aicpusd_warn("table[%u] has not been locked before", tableId);
      45            1 :         return AICPU_SCHEDULE_OK;
      46              :     }
      47              : 
      48            1 :     TableLockManager::GetInstance().UnLockTable(tableId);
      49            1 :     model->ClearLockedTable(tableId);
      50              : 
      51              :     // send unlock event
      52            1 :     AICPUSubEventInfo subEventInfo = {};
      53            1 :     subEventInfo.modelId = model->GetId();
      54            1 :     subEventInfo.para.unlockTableInfo.tableId = tableId;
      55            1 :     return AicpuMsgSend::SendAICPUSubEvent(PtrToPtr<AICPUSubEventInfo, const char_t>(&subEventInfo),
      56              :         static_cast<uint32_t>(sizeof(AICPUSubEventInfo)),
      57              :         AICPU_SUB_EVENT_TABLE_UNLOCK,
      58              :         CP_DEFAULT_GROUP_ID,
      59            1 :         true);
      60              : }
      61              : 
      62              : 
      63            6 : REGISTER_OPERATOR_KERNEL(KERNEL_UNLOCK_TABLE, OperatorKernelUnlockTable);
      64              : }  // namespace AicpuSchedule
        

Generated by: LCOV version 2.0-1