LCOV - code coverage report
Current view: top level - coll_communicator_mgr/dfx/profiling/aicpu - dfx_profiling_command_handle_lite.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 95.8 % 24 23
Test Date: 2026-08-18 17:47:01 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 "dfx_profiling_command_handle_lite.h"
      12              : #include "log.h"
      13              : #include "prof_common.h"
      14              : #include "dfx_profiling_handler_lite.h"
      15              : 
      16              : namespace Hccl {
      17              : 
      18            3 : HcclResult DfxRegisterProfCallBack()
      19              : {
      20            3 :     if (MsprofRegisterCallback != nullptr) {
      21            3 :         HCCL_INFO("RegisterProfCallBack not null");
      22            3 :         int32_t ret = MsprofRegisterCallback(AICPU, &DfxDeviceCommandHandle);
      23            3 :         CHK_PRT_RET((ret != 0), HCCL_ERROR("[%s] failed. ret = [%d]", __func__, ret), HCCL_E_PARA);
      24              :     } else {
      25            0 :         HCCL_INFO("RegisterProfCallBack is null");
      26              :     }
      27            3 :     return HCCL_SUCCESS;
      28              : }
      29              : 
      30            4 : int32_t DfxDeviceCommandHandle([[maybe_unused]] uint32_t profType, void* data, uint32_t len)
      31              : {
      32            4 :     HCCL_INFO("[%s] start", __func__);
      33              :     (void)len;
      34            4 :     if (data == nullptr) {
      35            1 :         HCCL_ERROR("[%s] CommandHandle's data is NULL.", __func__);
      36            1 :         return PROF_FAILED;
      37              :     }
      38            3 :     MsprofCommandHandle* command = reinterpret_cast<MsprofCommandHandle*>(data);
      39            3 :     auto type = command->type;
      40            3 :     HCCL_INFO("[%s] type = [%u]. CommandHandle_switch = [%llu]", __func__, type, command->profSwitch);
      41            3 :     if (type == PROF_COMMANDHANDLE_TYPE_START) {
      42            2 :         if ((ADPROF_TASK_TIME_L0 & command->profSwitch) != 0) {
      43            1 :             DfxProfilingHandlerLite::GetInstance().SetProL0On(true);
      44              :         }
      45            2 :         if ((ADPROF_TASK_TIME_L1 & command->profSwitch) != 0) {
      46            1 :             DfxProfilingHandlerLite::GetInstance().SetProL1On(true);
      47              :         }
      48            1 :     } else if (type == PROF_COMMANDHANDLE_TYPE_STOP) {
      49            1 :         DfxProfilingHandlerLite::GetInstance().SetProL0On(false);
      50            1 :         DfxProfilingHandlerLite::GetInstance().SetProL1On(false);
      51              :     }
      52            3 :     return PROF_SUCCESS;
      53              : }
      54              : 
      55              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1