LCOV - code coverage report
Current view: top level - aicpu_schedule/core/hwts_kernel - hwts_kernel_dfx.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 74.2 % 31 23
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              : 
      11              : #include "hwts_kernel_dfx.h"
      12              : 
      13              : #include "aicpu_prof.h"
      14              : #include "aicpusd_profiler.h"
      15              : #include "profiling_adp.h"
      16              : #include "aicpusd_monitor.h"
      17              : #include "aicpusd_threads_process.h"
      18              : #include "aicpusd_hal_interface_ref.h"
      19              : #include "tsd.h"
      20              : #include "aicpusd_drv_manager.h"
      21              : #include "aicpusd_model_err_process.h"
      22              : #include "dump_task.h"
      23              : #include "hwts_kernel_common.h"
      24              : 
      25              : namespace AicpuSchedule {
      26              : namespace {
      27              : const std::string CFG_LOG_ADDR = "CfgLogAddr";
      28              : const std::string DUMP_DATA_INFO = "DumpDataInfo";
      29              : }  // namespace
      30              : 
      31            1 : int32_t CfgLogAddrTsKernel::Compute(const aicpu::HwtsTsKernel &tsKernelInfo)
      32              : {
      33            1 :     aicpusd_info("Begin to process ts kernel CfgLogAddr event.");
      34              :     const auto cfgMsg =
      35            1 :         PtrToPtr<void, aicpu::AicpuConfigMsg>(ValueToPtr(tsKernelInfo.kernelBase.cceKernel.paramBase));
      36            1 :     if (cfgMsg == nullptr) {
      37            0 :         aicpusd_err("param base for config log is null.");
      38            0 :         return AICPU_SCHEDULE_ERROR_PARAMETER_NOT_VALID;
      39              :     }
      40              : 
      41            1 :     AicpuModelErrProc::GetInstance().ProcessLogBuffCfgMsg(*cfgMsg);
      42            1 :     return AICPU_SCHEDULE_OK;
      43              : }
      44              : 
      45            8 : int32_t DumpDataInfoTsKernel::Compute(const aicpu::HwtsTsKernel &tsKernelInfo)
      46              : {
      47            8 :     aicpusd_info("Begin to process ts kernel dump data event");
      48            8 :     const aicpu::HwtsCceKernel &kernel = tsKernelInfo.kernelBase.cceKernel;
      49              :     // dump op has two param, one is protobuf addr
      50            8 :     constexpr uint32_t singleOpDumpParamNum = 2U;
      51            8 :     constexpr size_t len =  sizeof(aicpu::AicpuParamHead) + (singleOpDumpParamNum * sizeof(uint64_t));
      52              :     const aicpu::AicpuParamHead * const paramHead =
      53            8 :         PtrToPtr<void, aicpu::AicpuParamHead>(ValueToPtr(kernel.paramBase));
      54            8 :     if (paramHead == nullptr) {
      55            0 :         aicpusd_err("paramHead for DumpDataKernel is nullptr");
      56            0 :         return AICPU_SCHEDULE_ERROR_PARAMETER_NOT_VALID;
      57              :     }
      58              : 
      59            8 :     if (static_cast<size_t>(paramHead->length) != len) {
      60            0 :         aicpusd_err("data dump param length[%u] shoulf be [%zu]", paramHead->length, len);
      61            0 :         return AICPU_SCHEDULE_ERROR_PARAMETER_NOT_VALID;
      62              :     }
      63              : 
      64              :     const auto ioAddrBase = 
      65            8 :         PtrToPtr<void, uint64_t>(ValueToPtr(kernel.paramBase + sizeof(aicpu::AicpuParamHead)));
      66            8 :     const uint64_t opMappingInfoAddr = ioAddrBase[0];
      67              :     const uint64_t * const lenAddr = 
      68            8 :         PtrToPtr<void, uint64_t>(ValueToPtr(ioAddrBase[1]));
      69            8 :     if (lenAddr == nullptr) {
      70            0 :         aicpusd_err("data dump proto length address is null");
      71            0 :         return AICPU_SCHEDULE_ERROR_PARAMETER_NOT_VALID;
      72              :     }
      73              : 
      74            8 :     aicpusd_info("Get proto len from address[%llu]", ioAddrBase[1]);
      75            8 :     const uint64_t opMappingInfoLen = *lenAddr;
      76            8 :     aicpusd_info("Proto len[%llu] from address[%llu]", opMappingInfoLen, opMappingInfoAddr);
      77              : 
      78            8 :     const AicpuSchedule::OpDumpTaskManager &dumpTaskMgr = AicpuSchedule::OpDumpTaskManager::GetInstance();
      79            8 :     return dumpTaskMgr.DumpOpInfoForUnknowShape(opMappingInfoAddr, opMappingInfoLen);
      80              : }
      81              : 
      82              : REGISTER_HWTS_KERNEL(CFG_LOG_ADDR, CfgLogAddrTsKernel);
      83              : REGISTER_HWTS_KERNEL(DUMP_DATA_INFO, DumpDataInfoTsKernel);
      84              : }  // namespace AicpuSchedule
        

Generated by: LCOV version 2.0-1