LCOV - code coverage report
Current view: top level - aicpu_schedule/core/operator_kernel/control_flow - operator_kernel_end_graph.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 20 20
Test Date: 2026-08-12 11:05:02 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              : 
      11              : #include "operator_kernel_end_graph.h"
      12              : 
      13              : #include "aicpusd_info.h"
      14              : #include "aicpusd_status.h"
      15              : #include "aicpusd_resource_manager.h"
      16              : #include "operator_kernel_common.h"
      17              : 
      18              : namespace AicpuSchedule {
      19              : namespace {
      20              : const std::string KERNEL_END_GRAPH = "endGraph";
      21              : } // namespace
      22              : 
      23            3 : int32_t OperatorKernelEndGraph::Compute(const AicpuTaskInfo& kernelTaskInfo, const RunContext& taskContext)
      24              : {
      25            3 :     const auto modelIdPtr = PtrToPtr<void, uint32_t>(ValueToPtr(static_cast<uintptr_t>(kernelTaskInfo.paraBase)));
      26            3 :     if (modelIdPtr == nullptr) {
      27            1 :         aicpusd_err(
      28              :             "ModelEndGraph kernelTaskInfo paramBase is null, modelId[%u], streamId[%u], taskId[%u]",
      29              :             taskContext.modelId, taskContext.streamId, kernelTaskInfo.taskID);
      30            1 :         return AICPU_SCHEDULE_ERROR_PARAMETER_NOT_VALID;
      31              :     }
      32              : 
      33            2 :     const uint32_t modelId = *modelIdPtr;
      34            2 :     if (modelId != taskContext.modelId) {
      35            1 :         aicpusd_warn(
      36              :             "ModelEndGraph kernelTaskInfo modelId[%u] is diff with context, "
      37              :             "modelId[%u], streamId[%u], taskId[%u]",
      38              :             modelId, taskContext.modelId, taskContext.streamId, kernelTaskInfo.taskID);
      39              :     }
      40              : 
      41            2 :     aicpusd_info("Begin to execute EndGraph. modelId[%u].", modelId);
      42            2 :     bool hasWait = false;
      43            2 :     uint32_t waitStreamId = 0U;
      44            2 :     EventWaitManager::EndGraphWaitManager().Event(static_cast<size_t>(modelId), hasWait, waitStreamId);
      45            2 :     if (hasWait) {
      46            1 :         AICPUSubEventInfo subEventInfo = {};
      47            1 :         subEventInfo.modelId = modelId;
      48            1 :         subEventInfo.para.streamInfo.streamId = waitStreamId;
      49            1 :         const int32_t ret = OperatorKernelCommon::SendAICPUSubEvent(
      50              :             PtrToPtr<AICPUSubEventInfo, char_t>(&subEventInfo), static_cast<uint32_t>(sizeof(AICPUSubEventInfo)),
      51              :             AICPU_SUB_EVENT_RECOVERY_STREAM);
      52            1 :         return ret;
      53              :     }
      54              : 
      55            1 :     return AICPU_SCHEDULE_OK;
      56              : }
      57              : 
      58            6 : REGISTER_OPERATOR_KERNEL(KERNEL_END_GRAPH, OperatorKernelEndGraph);
      59              : } // namespace AicpuSchedule
        

Generated by: LCOV version 2.0-1