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-07-28 10:54:05 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("ModelRecord 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            1 :     return DoCompute(info->notify_id, taskContext);
      33              : }
      34              : 
      35            1 : int32_t OperatorKernelRecordNotify::DoCompute(const uint32_t notifyId, const RunContext &taskContext) const
      36              : {
      37              :     // now only support notify aicpusd, when and tsid in TsAicpuNotify, it can notify hwts.
      38            1 :     bool hasWait = false;
      39            1 :     uint32_t waitStreamId = INVALID_NUMBER;
      40              :     // if has wait, set hasWait true and set waitStreamId, or else save notify come.
      41            1 :     EventWaitManager::NotifyWaitManager().Event(static_cast<size_t>(notifyId), hasWait, waitStreamId);
      42            1 :     if (!hasWait) {
      43            0 :         return AICPU_SCHEDULE_OK;
      44              :     }
      45            1 :     AICPUSubEventInfo subEventInfo = {};
      46            1 :     subEventInfo.modelId = taskContext.modelId;
      47            1 :     subEventInfo.para.streamInfo.streamId = waitStreamId;
      48            1 :     return OperatorKernelCommon::SendAICPUSubEvent(PtrToPtr<AICPUSubEventInfo, char_t>(&subEventInfo),
      49            1 :         static_cast<uint32_t>(sizeof(AICPUSubEventInfo)), AICPU_SUB_EVENT_RECOVERY_STREAM);
      50              : }
      51              : 
      52            6 : REGISTER_OPERATOR_KERNEL(KERNEL_RECORD_NOTIFY, OperatorKernelRecordNotify);
      53              : }  // namespace AicpuSchedule
        

Generated by: LCOV version 2.0-1