Line data Source code
1 : /**
2 : * Copyright (c) 2026 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 "hwts_kernel_close_monitor.h"
12 :
13 : #include "aicpusd_monitor.h"
14 :
15 : namespace AicpuSchedule {
16 : namespace {
17 : const std::string CLOSE_AICPU_MONITOR = "CloseAicpuMonitor";
18 : struct CloseAicpuMonitorArgs {
19 : uint8_t monitorEn; /* 1=close aicpu self monitor, 0=open */
20 : uint8_t retcode; /* set to 0 on success; errors are returned by Compute */
21 : uint8_t rsv[2];
22 : };
23 : } // namespace
24 :
25 3 : int32_t CloseAicpuMonitorTsKernel::Compute(const aicpu::HwtsTsKernel& tsKernelInfo)
26 : {
27 3 : aicpusd_info("Begin to process ts kernel CloseAicpuMonitor event.");
28 3 : const auto args = PtrToPtr<void, CloseAicpuMonitorArgs>(ValueToPtr(tsKernelInfo.kernelBase.cceKernel.paramBase));
29 3 : if (args == nullptr) {
30 1 : aicpusd_err("param base for CloseAicpuMonitor is null.");
31 1 : return AICPU_SCHEDULE_ERROR_PARAMETER_NOT_VALID;
32 : }
33 2 : const bool closeFlag = (args->monitorEn == 1U);
34 2 : AicpuMonitor::GetInstance().SetCloseMonitorFlag(closeFlag);
35 2 : args->retcode = 0U;
36 2 : aicpusd_info(
37 : "Process CloseAicpuMonitor, monitorEn[%u], closeFlag[%d].", args->monitorEn, static_cast<int32_t>(closeFlag));
38 2 : return AICPU_SCHEDULE_OK;
39 : }
40 :
41 : REGISTER_HWTS_KERNEL(CLOSE_AICPU_MONITOR, CloseAicpuMonitorTsKernel);
42 : } // namespace AicpuSchedule
|