LCOV - code coverage report
Current view: top level - legacy/ascend910/common/debug/profiling - command_handle.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 93.7 % 63 59
Test Date: 2026-07-28 12:11:00 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 "command_handle.h"
      12              : #include "profiling_manager.h"
      13              : #include "prof_common.h"
      14              : 
      15              : namespace hccl {
      16            8 : rtError_t CommandHandle(uint32_t rtType, void *data, uint32_t len)
      17              : {
      18              :     (void)len;
      19            8 :     if (data == nullptr) {
      20            0 :         HCCL_ERROR("[Profiling][CommandHandle] CommandHandle's data is NULL.");
      21            0 :         return FAILED;
      22              :     }
      23            8 :     auto &profilingManager = hccl::ProfilingManager::Instance();
      24            8 :     if (rtType == RT_PROF_CTRL_REPORTER) { // 创建 reporter
      25            1 :         HCCL_INFO("[Profiling][CommandHandle] CommandHandle's rtType is %u.", rtType);
      26            1 :         profilingManager.SetMsprofReporterCallback(reinterpret_cast<MsprofReporterCallback>(data));
      27            7 :     } else if (rtType == RT_PROF_CTRL_SWITCH) {
      28            7 :         rtProfCommandHandle_t *profConfigParam = reinterpret_cast<rtProfCommandHandle_t *>(data);
      29            7 :         auto type = profConfigParam->type;
      30            7 :         auto profconfig = profConfigParam->profSwitch;
      31            7 :         HCCL_RUN_INFO("[Profiling][CommandHandle] CommandHandle's rtType is %u. CommandHandle_switch type[%u], " \
      32              :             "profconfig[%u], deviceLogicId[%u]", rtType, type, profconfig, profConfigParam->devIdList[0]);
      33            7 :         switch (type) {
      34            1 :             case PROF_COMMANDHANDLE_TYPE_INIT:
      35            1 :                 profilingManager.PluginInit();
      36            1 :                 break;
      37            1 :             case PROF_COMMANDHANDLE_TYPE_START:
      38            1 :                 profilingManager.PluginInit();
      39            1 :                 profilingManager.StartSubscribe(profconfig);
      40            1 :                 break;
      41            1 :             case PROF_COMMANDHANDLE_TYPE_STOP:
      42            1 :                 profilingManager.StopSubscribe(profconfig);
      43            1 :                 break;
      44            1 :             case PROF_COMMANDHANDLE_TYPE_FINALIZE:
      45            1 :                 profilingManager.PluginUnInit();
      46            1 :                 break;
      47            1 :             case PROF_COMMANDHANDLE_TYPE_MODEL_SUBSCRIBE:
      48            1 :                 profilingManager.PluginInit();
      49            1 :                 profilingManager.StartSubscribe(profconfig);
      50            1 :                 break;
      51            1 :             case PROF_COMMANDHANDLE_TYPE_MODEL_UNSUBSCRIBE:
      52            1 :                 profilingManager.StopSubscribe(profconfig);
      53            1 :                 profilingManager.PluginUnInit();
      54            1 :                 break;
      55            1 :             default:
      56            1 :                 HCCL_RUN_INFO("[Profiling][CommandHandle] Unexpected behaviour.");
      57              :         }
      58              :     }
      59              : 
      60            8 :     return SUCCESS;
      61              : }
      62              : 
      63            7 : rtError_t EsCommandHandle(uint32_t rtType, void *data, uint32_t len)
      64              : {
      65              :     (void)len;
      66            7 :     if (data == nullptr) {
      67            0 :         HCCL_ERROR("[Profiling][EsCommandHandle] EsCommandHandle's data is NULL.");
      68            0 :         return FAILED;
      69              :     }
      70              : 
      71            7 :     HCCL_INFO("[Profiling][EsCommandHandle] EsCommandHandle's rtType is %u.", rtType);
      72            7 :     if (rtType == RT_PROF_CTRL_REPORTER) { // 创建 reporter
      73            1 :         HCCL_INFO("rtType[%u] == RT_PROF_CTRL_REPORTER", rtType);
      74            1 :         return SUCCESS;
      75              :     }
      76              : 
      77            6 :     auto &profilingManager = hccl::ProfilingManager::Instance();
      78            6 :     rtProfCommandHandle_t *profConfigParam = static_cast<rtProfCommandHandle_t *>(data);
      79            6 :     auto type = profConfigParam->type;
      80            6 :     auto profconfig = profConfigParam->profSwitch;
      81              : 
      82            6 :     HCCL_INFO("[Profiling][EsCommandHandle] EsCommandHandle_switch type[%u], profconfig[%u]", type, profconfig);
      83            6 :     switch (type) {
      84            2 :         case PROF_COMMANDHANDLE_TYPE_START:
      85              :         case PROF_COMMANDHANDLE_TYPE_MODEL_SUBSCRIBE:
      86            2 :             profilingManager.EsStartSubscribe(profconfig);
      87            2 :             break;
      88            2 :         case PROF_COMMANDHANDLE_TYPE_STOP:
      89              :         case PROF_COMMANDHANDLE_TYPE_MODEL_UNSUBSCRIBE:
      90            2 :             profilingManager.EsStopSubscribe(profconfig);
      91            2 :             break;
      92            1 :         case PROF_COMMANDHANDLE_TYPE_INIT:
      93              :         case PROF_COMMANDHANDLE_TYPE_FINALIZE:
      94            1 :             break;
      95            1 :         default:
      96            1 :             HCCL_ERROR("[Profiling][EsCommandHandle] Unexpected behaviour.");
      97              :     }
      98              : 
      99            6 :     return SUCCESS;
     100              : }
     101              : 
     102              : } // namespace hccl
        

Generated by: LCOV version 2.0-1