LCOV - code coverage report
Current view: top level - aicpu_schedule/core/operator_kernel/control_flow - operator_kernel_record_notify.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 94.4 % 18 17
Test Date: 2026-08-12 11:05:02 Functions: 100.0 % 3 3

            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_record_notify.h"
      12              : 
      13              : #include "aicpusd_status.h"
      14              : #include "aicpusd_info.h"
      15              : #include "aicpusd_resource_manager.h"
      16              : #include "aicpusd_event_process.h"
      17              : #include "operator_kernel_common.h"
      18              : 
      19              : namespace AicpuSchedule {
      20              : namespace {
      21              : const std::string KERNEL_RECORD_NOTIFY = "recordNotify";
      22              : } // namespace
      23              : 
      24            2 : int32_t OperatorKernelRecordNotify::Compute(const AicpuTaskInfo& kernelTaskInfo, const RunContext& taskContext)
      25              : {
      26            2 :     const auto info = PtrToPtr<void, TsAicpuNotify>(ValueToPtr(static_cast<uintptr_t>(kernelTaskInfo.paraBase)));
      27            2 :     if (info == nullptr) {
      28            1 :         aicpusd_err(
      29              :             "ModelRecord kernelTaskInfo paramBase is null, modelId[%u], streamId[%u], taskId[%u]", taskContext.modelId,
      30              :             taskContext.streamId, kernelTaskInfo.taskID);
      31            1 :         return AICPU_SCHEDULE_ERROR_PARAMETER_NOT_VALID;
      32              :     }
      33            1 :     return DoCompute(info->notify_id, taskContext);
      34              : }
      35              : 
      36            1 : int32_t OperatorKernelRecordNotify::DoCompute(const uint32_t notifyId, const RunContext& taskContext) const
      37              : {
      38              :     // now only support notify aicpusd, when and tsid in TsAicpuNotify, it can notify hwts.
      39            1 :     bool hasWait = false;
      40            1 :     uint32_t waitStreamId = INVALID_NUMBER;
      41              :     // if has wait, set hasWait true and set waitStreamId, or else save notify come.
      42            1 :     EventWaitManager::NotifyWaitManager().Event(static_cast<size_t>(notifyId), hasWait, waitStreamId);
      43            1 :     if (!hasWait) {
      44            0 :         return AICPU_SCHEDULE_OK;
      45              :     }
      46            1 :     AICPUSubEventInfo subEventInfo = {};
      47            1 :     subEventInfo.modelId = taskContext.modelId;
      48            1 :     subEventInfo.para.streamInfo.streamId = waitStreamId;
      49            1 :     return OperatorKernelCommon::SendAICPUSubEvent(
      50              :         PtrToPtr<AICPUSubEventInfo, char_t>(&subEventInfo), static_cast<uint32_t>(sizeof(AICPUSubEventInfo)),
      51            1 :         AICPU_SUB_EVENT_RECOVERY_STREAM);
      52              : }
      53              : 
      54            6 : REGISTER_OPERATOR_KERNEL(KERNEL_RECORD_NOTIFY, OperatorKernelRecordNotify);
      55              : } // namespace AicpuSchedule
        

Generated by: LCOV version 2.0-1