LCOV - code coverage report
Current view: top level - acl/aclrt_impl/toolchain - profiling_manager.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 51 53 96.2 %
Date: 2026-08-27 13:24:42 Functions: 7 8 87.5 %

          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 "profiling_manager.h"
      12             : #include "mmpa/mmpa_api.h"
      13             : #include "common/log_inner.h"
      14             : #include "common/prof_reporter.h"
      15             : 
      16             : 
      17             : namespace acl {
      18             :     const std::map<AclProfType, std::string> PROF_TYPE_TO_NAMES = {
      19             :         {AclProfType::AclmdlRIExecuteAsync,                     "aclmdlRIExecuteAsync"},
      20             :         {AclProfType::AclmdlRIDestroy,                          "aclmdlRIDestroy"},
      21             :         {AclProfType::AclmdlRICaptureBegin,                     "aclmdlRICaptureBegin"},
      22             :         {AclProfType::AclmdlRICaptureGetInfo,                   "aclmdlRICaptureGetInfo"},
      23             :         {AclProfType::AclmdlRICaptureEnd,                       "aclmdlRICaptureEnd"},
      24             :         {AclProfType::AclmdlRIDebugPrint,                       "aclmdlRIDebugPrint"},
      25             :         {AclProfType::AclmdlRIDebugJsonPrint,                   "aclmdlRIDebugJsonPrint"},
      26             :         {AclProfType::AclmdlRICaptureThreadExchangeMode,        "aclmdlRICaptureThreadExchangeMode"},
      27             :         {AclProfType::AclmdlRICaptureTaskGrpBegin,              "aclmdlRICaptureTaskGrpBegin"},
      28             :         {AclProfType::AclmdlRICaptureTaskGrpEnd,                "aclmdlRICaptureTaskGrpEnd"},
      29             :         {AclProfType::AclmdlRICaptureTaskUpdateBegin,           "aclmdlRICaptureTaskUpdateBegin"},
      30             :         {AclProfType::AclmdlRICaptureTaskUpdateEnd,             "aclmdlRICaptureTaskUpdateEnd"},
      31             :         {AclProfType::AclCreateDataBuffer,                      "aclCreateDataBuffer"},
      32             :         {AclProfType::AclrtLaunchCallback,                      "aclrtLaunchCallback"},
      33             :         {AclProfType::AclrtProcessReport,                       "aclrtProcessReport"},
      34             :         {AclProfType::AclrtCreateContext,                       "aclrtCreateContext"},
      35             :         {AclProfType::AclrtDestroyContext,                      "aclrtDestroyContext"},
      36             :         {AclProfType::AclrtSetCurrentContext,                   "aclrtSetCurrentContext"},
      37             :         {AclProfType::AclrtGetCurrentContext,                   "aclrtGetCurrentContext"},
      38             :         {AclProfType::AclrtSetDevice,                           "aclrtSetDevice"},
      39             :         {AclProfType::AclrtSetDeviceWithoutTsdVXX,              "aclrtSetDeviceWithoutTsdVXX"},
      40             :         {AclProfType::AclrtResetDevice,                         "aclrtResetDevice"},
      41             :         {AclProfType::AclrtResetDeviceForce,                    "aclrtResetDeviceForce"},
      42             :         {AclProfType::AclrtResetDeviceWithoutTsdVXX,            "aclrtResetDeviceWithoutTsdVXX"},
      43             :         {AclProfType::AclrtSynchronizeDevice,                   "aclrtSynchronizeDevice"},
      44             :         {AclProfType::AclrtSynchronizeDeviceWithTimeout,        "aclrtSynchronizeDeviceWithTimeout"},
      45             :         {AclProfType::AclrtSetTsDevice,                         "aclrtSetTsDevice"},
      46             :         {AclProfType::AclrtCreateEvent,                         "aclrtCreateEvent"},
      47             :         {AclProfType::AclrtCreateEventWithFlag,                 "aclrtCreateEventWithFlag"},
      48             :         {AclProfType::AclrtCreateEventExWithFlag,               "aclrtCreateEventExWithFlag"},
      49             :         {AclProfType::AclrtDestroyEvent,                        "aclrtDestroyEvent"},
      50             :         {AclProfType::AclrtRecordEvent,                         "aclrtRecordEvent"},
      51             :         {AclProfType::AclrtResetEvent,                          "aclrtResetEvent"},
      52             :         {AclProfType::AclrtQueryEvent,                          "aclrtQueryEvent"},
      53             :         {AclProfType::AclrtQueryEventStatus,                    "aclrtQueryEventStatus"},
      54             :         {AclProfType::AclrtQueryEventWaitStatus,                "aclrtQueryEventWaitStatus"},
      55             :         {AclProfType::AclrtSynchronizeEvent,                    "aclrtSynchronizeEvent"},
      56             :         {AclProfType::AclrtSetOpWaitTimeout,                    "aclrtSetOpWaitTimeout"},
      57             :         {AclProfType::AclrtSetOpExecuteTimeOut,                 "aclrtSetOpExecuteTimeOut"},
      58             :         {AclProfType::AclrtSetOpExecuteTimeOutWithMs,           "aclrtSetOpExecuteTimeOutWithMs"},
      59             :         {AclProfType::AclrtSetGroup,                            "aclrtSetGroup"},
      60             :         {AclProfType::AclrtGetGroupCount,                       "aclrtGetGroupCount"},
      61             :         {AclProfType::AclrtGetAllGroupInfo,                     "aclrtGetAllGroupInfo"},
      62             :         {AclProfType::AclrtGetGroupInfoDetail,                  "aclrtGetGroupInfoDetail"},
      63             :         {AclProfType::AclMallocMemInner,                        "aclMallocMemInner"},
      64             :         {AclProfType::AclrtMallocCached,                        "aclrtMallocCached"},
      65             :         {AclProfType::AclrtMemFlush,                            "aclrtMemFlush"},
      66             :         {AclProfType::AclrtMemInvalidate,                       "aclrtMemInvalidate"},
      67             :         {AclProfType::AclrtFree,                                "aclrtFree"},
      68             :         {AclProfType::AclrtMallocHost,                          "aclrtMallocHost"},
      69             :         {AclProfType::AclrtFreeHost,                            "aclrtFreeHost"},
      70             :         {AclProfType::AclrtMemcpy,                              "aclrtMemcpy"},
      71             :         {AclProfType::AclrtMemset,                              "aclrtMemset"},
      72             :         {AclProfType::AclrtMemcpyAsync,                         "aclrtMemcpyAsync"},
      73             :         {AclProfType::AclrtMemcpyAsyncWithCondition,            "aclrtMemcpyAsyncWithCondition"},
      74             :         {AclProfType::AclrtMemsetAsync,                         "aclrtMemsetAsync"},
      75             :         {AclProfType::AclrtDeviceCanAccessPeer,                 "aclrtDeviceCanAccessPeer"},
      76             :         {AclProfType::AclrtDeviceEnablePeerAccess,              "aclrtDeviceEnablePeerAccess"},
      77             :         {AclProfType::AclrtDeviceDisablePeerAccess,             "aclrtDeviceDisablePeerAccess"},
      78             :         {AclProfType::AclrtGetMemInfo,                          "aclrtGetMemInfo"},
      79             :         {AclProfType::AclrtMemcpy2d,                            "aclrtMemcpy2d"},
      80             :         {AclProfType::AclrtMemcpy2dAsync,                       "aclrtMemcpy2dAsync"},
      81             :         {AclProfType::AclrtCreateStream,                        "aclrtCreateStream"},
      82             :         {AclProfType::AclrtCreateStreamWithConfig,              "aclrtCreateStreamWithConfig"},
      83             :         {AclProfType::AclrtDestroyStream,                       "aclrtDestroyStream"},
      84             :         {AclProfType::AclrtDestroyStreamForce,                  "aclrtDestroyStreamForce"},
      85             :         {AclProfType::AclrtSynchronizeStream,                   "aclrtSynchronizeStream"},
      86             :         {AclProfType::AclrtSynchronizeStreamWithTimeout,        "aclrtSynchronizeStreamWithTimeout"},
      87             :         {AclProfType::AclrtStreamQuery,                         "aclrtStreamQuery"},
      88             :         {AclProfType::AclrtStreamGetPriority,                   "aclrtStreamGetPriority"},
      89             :         {AclProfType::AclrtStreamGetFlags,                      "aclrtStreamGetFlags"},
      90             :         {AclProfType::AclrtStreamWaitEvent,                     "aclrtStreamWaitEvent"},
      91             :         {AclProfType::AclrtStreamWaitEventWithTimeout,          "aclrtStreamWaitEventWithTimeout"},
      92             :         {AclProfType::AclrtAllocatorCreateDesc,                 "aclrtAllocatorCreateDesc"},
      93             :         {AclProfType::AclrtAllocatorDestroyDesc,                "aclrtAllocatorDestroyDesc"},
      94             :         {AclProfType::AclrtCtxGetSysParamOpt,                   "aclrtCtxGetSysParamOpt"},
      95             :         {AclProfType::AclrtCtxSetSysParamOpt,                   "aclrtCtxSetSysParamOpt"},
      96             :         {AclProfType::AclrtGetOverflowStatus,                   "aclrtGetOverflowStatus"},
      97             :         {AclProfType::AclrtResetOverflowStatus,                 "aclrtResetOverflowStatus"},
      98             :         {AclProfType::AclrtGetDeviceCount,                      "aclrtGetDeviceCount"},
      99             :         {AclProfType::AclrtGetDevice,                           "aclrtGetDevice"},
     100             :         {AclProfType::AclrtMalloc,                              "aclrtMalloc"},
     101             :         {AclProfType::AclrtSetStreamFailureMode,                "aclrtSetStreamFailureMode"},
     102             :         {AclProfType::AclrtQueryDeviceStatus,                   "aclrtQueryDeviceStatus"},
     103             :         {AclProfType::AclrtReserveMemAddress,                   "aclrtReserveMemAddress"},
     104             :         {AclProfType::AclrtReleaseMemAddress,                   "aclrtReleaseMemAddress"},
     105             :         {AclProfType::AclrtMallocPhysical,                      "aclrtMallocPhysical"},
     106             :         {AclProfType::AclrtFreePhysical,                        "aclrtFreePhysical"},
     107             :         {AclProfType::AclrtMapMem,                              "aclrtMapMem"},
     108             :         {AclProfType::AclrtUnmapMem,                            "aclrtUnmapMem"},
     109             :         {AclProfType::AclrtLaunchKernel,                        "aclrtLaunchKernel"},
     110             :         {AclProfType::AclrtMemGetAccess,                        "aclrtMemGetAccess"},
     111             :         {AclProfType::AclrtMemExportToShareableHandle,          "aclrtMemExportToShareableHandle"},
     112             :         {AclProfType::AclrtMemExportToShareableHandleV2,          "aclrtMemExportToShareableHandleV2"},
     113             :         {AclProfType::AclrtMemImportFromShareableHandle,        "aclrtMemImportFromShareableHandle"},
     114             :         {AclProfType::AclrtMemImportFromShareableHandleV2,      "aclrtMemImportFromShareableHandleV2"},
     115             :         {AclProfType::AclrtMemGetAllocationGranularity,         "aclrtMemGetAllocationGranularity"},
     116             :         {AclProfType::AclrtMemSetPidToShareableHandle,          "aclrtMemSetPidToShareableHandle"},
     117             :         {AclProfType::AclrtMemSetPidToShareableHandleV2,        "aclrtMemSetPidToShareableHandleV2"},
     118             :         {AclProfType::AclrtDeviceGetBareTgid,                   "aclrtDeviceGetBareTgid"},
     119             :         {AclProfType::AclrtGetMemUceInfo,                       "aclrtGetMemUceInfo"},
     120             :         {AclProfType::AclrtDeviceTaskAbort,                     "aclrtDeviceTaskAbort"},
     121             :         {AclProfType::AclrtMemUceRepair,                        "aclrtMemUceRepair"},
     122             :         {AclProfType::AclrtCmoAsync,                            "aclrtCmoAsync"},
     123             :         {AclProfType::AclrtStreamAbort,                         "aclrtStreamAbort"},
     124             :         {AclProfType::AclrtMemcpyAsyncWithDesc,                 "aclrtMemcpyAsyncWithDesc"},
     125             :         {AclProfType::AclrtBinaryLoadFromFile,                  "aclrtBinaryLoadFromFile"},
     126             :         {AclProfType::AclrtBinaryGetDevAddress,                 "aclrtBinaryGetDevAddress"},
     127             :         {AclProfType::AclrtLaunchKernelWithConfig,              "aclrtLaunchKernelWithConfig"},
     128             :         {AclProfType::AclrtKernelArgsAppend,                    "aclrtKernelArgsAppend"},
     129             :         {AclProfType::AclrtKernelArgsAppendPlaceHolder,         "aclrtKernelArgsAppendPlaceHolder"},
     130             :         {AclProfType::AclrtKernelArgsParaUpdate,                "aclrtKernelArgsParaUpdate"},
     131             :         {AclProfType::AclrtKernelArgsGetMemSize,                "aclrtKernelArgsGetMemSize"},
     132             :         {AclProfType::AclrtKernelArgsGetHandleMemSize,          "aclrtKernelArgsGetHandleMemSize"},
     133             :         {AclProfType::AclrtKernelArgsGetPlaceHolderBuffer,      "aclrtKernelArgsGetPlaceHolderBuffer"},
     134             :         {AclProfType::AclrtMallocWithCfg,                       "aclrtMallocWithCfg"},
     135             :         {AclProfType::AclrtMallocForTaskScheduler,              "aclrtMallocForTaskScheduler"},
     136             :         {AclProfType::AclrtMallocHostWithCfg,                   "aclrtMallocHostWithCfg"},
     137             :         {AclProfType::AclrtGetThreadLastTaskId,                 "aclrtGetThreadLastTaskId"},
     138             :         {AclProfType::AclrtStreamGetId,                         "aclrtStreamGetId"},
     139             :         {AclProfType::AclrtPointerGetAttributes,                "aclrtPointerGetAttributes"},
     140             :         {AclProfType::AclrtHostRegister,                        "aclrtHostRegister"},
     141             :         {AclProfType::AclrtHostRegisterV2,                      "aclrtHostRegisterV2"},
     142             :         {AclProfType::AclrtHostGetDevicePointer,                "aclrtHostGetDevicePointer"},
     143             :         {AclProfType::AclrtHostUnregister,                      "aclrtHostUnregister"},
     144             :         {AclProfType::AclrtValueWrite,                          "aclrtValueWrite"},
     145             :         {AclProfType::AclrtValueWait,                           "aclrtValueWait"},
     146             :         {AclProfType::AclrtGetStreamAvailableNum,               "aclrtGetStreamAvailableNum"},
     147             :         {AclProfType::AclrtSetStreamAttribute,                  "aclrtSetStreamAttribute"},
     148             :         {AclProfType::AclrtGetStreamAttribute,                  "aclrtGetStreamAttribute"},
     149             :         {AclProfType::AclrtCreateNotify,                        "aclrtCreateNotify"},
     150             :         {AclProfType::AclrtDestroyNotify,                       "aclrtDestroyNotify"},
     151             :         {AclProfType::AclrtRecordNotify,                        "aclrtRecordNotify"},
     152             :         {AclProfType::AclrtWaitAndResetNotify,                  "aclrtWaitAndResetNotify"},
     153             :         {AclProfType::AclrtGetNotifyId,                         "aclrtGetNotifyId"},
     154             :         {AclProfType::AclrtGetEventId,                          "aclrtGetEventId"},
     155             :         {AclProfType::AclrtGetEventAvailNum,                    "aclrtGetEventAvailNum"},
     156             :         {AclProfType::AclrtGetDeviceInfo,                       "aclrtGetDeviceInfo"},
     157             :         {AclProfType::AclrtDeviceGetUuid,                       "aclrtDeviceGetUuid"},
     158             :         {AclProfType::AclrtDeviceGetStreamPriorityRange,        "aclrtDeviceGetStreamPriorityRange"},
     159             :         {AclProfType::AclrtGetDeviceCapability,                 "aclrtGetDeviceCapability"},
     160             :         {AclProfType::AclrtCtxGetCurrentDefaultStream,          "aclrtCtxGetCurrentDefaultStream"},
     161             :         {AclProfType::AclmdlRIBuildBegin,                       "aclmdlRIBuildBegin"},
     162             :         {AclProfType::AclmdlRIBindStream,                       "aclmdlRIBindStream"},
     163             :         {AclProfType::AclmdlRIEndTask,                          "aclmdlRIEndTask"},
     164             :         {AclProfType::AclmdlRIBuildEnd,                         "aclmdlRIBuildEnd"},
     165             :         {AclProfType::AclmdlRIUnbindStream,                     "aclmdlRIUnbindStream"},
     166             :         {AclProfType::AclmdlRIExecute,                          "aclmdlRIExecute"},
     167             :         {AclProfType::AclrtReduceAsync,                         "aclrtReduceAsync"},
     168             :         {AclProfType::AclrtGetDeviceResLimit,                   "aclrtGetDeviceResLimit"},
     169             :         {AclProfType::AclrtSetDeviceResLimit,                   "aclrtSetDeviceResLimit"},
     170             :         {AclProfType::AclrtResetDeviceResLimit,                 "aclrtResetDeviceResLimit"},
     171             :         {AclProfType::AclrtCreateLabel,                         "aclrtCreateLabel"},
     172             :         {AclProfType::AclrtSetLabel,                            "aclrtSetLabel"},
     173             :         {AclProfType::AclrtDestroyLabel,                        "aclrtDestroyLabel"},
     174             :         {AclProfType::AclrtCreateLabelList,                     "aclrtCreateLabelList"},
     175             :         {AclProfType::AclrtDestroyLabelList,                    "aclrtDestroyLabelList"},
     176             :         {AclProfType::AclrtSwitchLabelByIndex,                  "aclrtSwitchLabelByIndex"},
     177             :         {AclProfType::AclrtActiveStream,                        "aclrtActiveStream"},
     178             :         {AclProfType::AclrtSwitchStream,                        "aclrtSwitchStream"},
     179             :         {AclProfType::AclrtGetFunctionName,                     "aclrtGetFunctionName"},
     180             :         {AclProfType::AclmdlRISetName,                          "aclmdlRISetName"},
     181             :         {AclProfType::AclmdlRIGetName,                          "aclmdlRIGetName"},
     182             :         {AclProfType::AclrtGetBufFromChain,                     "aclrtGetBufFromChain"},
     183             :         {AclProfType::AclrtGetBufChainNum,                      "aclrtGetBufChainNum"},
     184             :         {AclProfType::AclrtAppendBufChain,                      "aclrtAppendBufChain"},
     185             :         {AclProfType::AclrtCopyBufRef,                          "aclrtCopyBufRef"},
     186             :         {AclProfType::AclrtGetBufUserData,                      "aclrtGetBufUserData"},
     187             :         {AclProfType::AclrtSetBufUserData,                      "aclrtSetBufUserData"},
     188             :         {AclProfType::AclrtGetBufData,                          "aclrtGetBufData"},
     189             :         {AclProfType::AclrtGetBufDataLen,                       "aclrtGetBufDataLen"},
     190             :         {AclProfType::AclrtSetBufDataLen,                       "aclrtSetBufDataLen"},
     191             :         {AclProfType::AclrtFreeBuf,                             "aclrtFreeBuf"},
     192             :         {AclProfType::AclrtAllocBuf,                            "aclrtAllocBuf"},
     193             :         {AclProfType::AclrtBinaryLoadFromData,                  "aclrtBinaryLoadFromData"},
     194             :         {AclProfType::AclrtRegisterCpuFunc,                     "aclrtRegisterCpuFunc"},
     195             :         {AclProfType::AclrtCmoAsyncWithBarrier,                 "aclrtCmoAsyncWithBarrier"},
     196             :         {AclProfType::AclrtCmoWaitBarrier,                      "aclrtCmoWaitBarrier"},
     197             :         {AclProfType::AclrtGetDevicesTopo,                      "aclrtGetDevicesTopo"},
     198             :         {AclProfType::AclrtMemcpyBatch,                         "aclrtMemcpyBatch"},
     199             :         {AclProfType::AclrtMemcpyBatchAsync,                    "aclrtMemcpyBatchAsync"},
     200             :         {AclProfType::AclrtIpcMemGetExportKey,                  "aclrtIpcMemGetExportKey"},
     201             :         {AclProfType::AclrtIpcMemClose,                         "aclrtIpcMemClose"},
     202             :         {AclProfType::AclrtIpcMemImportByKey,                   "aclrtIpcMemImportByKey"},
     203             :         {AclProfType::AclrtIpcMemSetImportPid,                  "aclrtIpcMemSetImportPid"},
     204             :         {AclProfType::AclrtNotifyBatchReset,                    "aclrtNotifyBatchReset"},
     205             :         {AclProfType::AclrtNotifyGetExportKey,                  "aclrtNotifyGetExportKey"},
     206             :         {AclProfType::AclrtNotifyImportByKey,                   "aclrtNotifyImportByKey"},
     207             :         {AclProfType::AclrtNotifySetImportPid,                  "aclrtNotifySetImportPid"},
     208             :         {AclProfType::AclrtGetStreamResLimit,                   "aclrtGetStreamResLimit"},
     209             :         {AclProfType::AclrtSetStreamResLimit,                   "aclrtSetStreamResLimit"},
     210             :         {AclProfType::AclrtResetStreamResLimit,                 "aclrtResetStreamResLimit"},
     211             :         {AclProfType::AclrtUseStreamResInCurrentThread,         "aclrtUseStreamResInCurrentThread"},
     212             :         {AclProfType::AclrtUnuseStreamResInCurrentThread,       "aclrtUnuseStreamResInCurrentThread"},
     213             :         {AclProfType::AclrtGetResInCurrentThread,               "aclrtGetResInCurrentThread"},
     214             :         {AclProfType::AclrtCheckMemType,                        "aclrtCheckMemType"},
     215             :         {AclProfType::AclrtGetLogicDevIdByUserDevId,            "aclrtGetLogicDevIdByUserDevId"},
     216             :         {AclProfType::AclrtGetUserDevIdByLogicDevId,            "aclrtGetUserDevIdByLogicDevId"},
     217             :         {AclProfType::AclrtGetLogicDevIdByPhyDevId,             "aclrtGetLogicDevIdByPhyDevId"},
     218             :         {AclProfType::AclrtGetPhyDevIdByLogicDevId,             "aclrtGetPhyDevIdByLogicDevId"},
     219             :         {AclProfType::AclrtProfTrace,                           "aclrtProfTrace"},
     220             :         {AclProfType::AclrtLaunchKernelV2,                      "aclrtLaunchKernelV2"},
     221             :         {AclProfType::AclrtLaunchKernelWithHostArgs,            "aclrtLaunchKernelWithHostArgs"},
     222             :         {AclProfType::AclrtCtxGetFloatOverflowAddr,             "aclrtCtxGetFloatOverflowAddr"},
     223             :         {AclProfType::AclrtGetFloatOverflowStatus,              "aclrtGetFloatOverflowStatus"},
     224             :         {AclProfType::AclrtResetFloatOverflowStatus,            "aclrtResetFloatOverflowStatus"},
     225             :         {AclProfType::AclrtNpuGetFloatOverFlowStatus,           "aclrtNpuGetFloatOverFlowStatus"},
     226             :         {AclProfType::AclrtNpuClearFloatOverFlowStatus,         "aclrtNpuClearFloatOverFlowStatus"},
     227             :         {AclProfType::AclrtLaunchHostFunc,                      "aclrtLaunchHostFunc"},
     228             :         {AclProfType::AclrtGetHardwareSyncAddr,                 "aclrtGetHardwareSyncAddr"},
     229             :         {AclProfType::AclrtRandomNumAsync,                      "aclrtRandomNumAsync"},
     230             :         {AclProfType::AclrtRegStreamStateCallback,              "aclrtRegStreamStateCallback"},
     231             :         {AclProfType::AclrtRegDeviceStateCallback,              "aclrtRegDeviceStateCallback"},
     232             :         {AclProfType::AclrtSetDeviceTaskAbortCallback,          "aclrtSetDeviceTaskAbortCallback"},
     233             :         {AclProfType::AclrtGetOpExecuteTimeout,                 "aclrtGetOpExecuteTimeout"},
     234             :         {AclProfType::AclrtDevicePeerAccessStatus,              "aclrtDevicePeerAccessStatus"},
     235             :         {AclProfType::AclrtStreamStop,                          "aclrtStreamStop"},
     236             :         {AclProfType::AclrtTaskUpdateAsync,                     "aclrtTaskUpdateAsync"},
     237             :         {AclProfType::AclrtCntNotifyCreate,                     "aclrtCntNotifyCreate"},
     238             :         {AclProfType::AclrtCntNotifyDestroy,                    "aclrtCntNotifyDestroy"},
     239             :         {AclProfType::AclrtIpcMemSetAttr,                       "aclrtIpcMemSetAttr"},
     240             :         {AclProfType::AclrtIpcMemImportPidInterServer,          "aclrtIpcMemIpmportPidInterServer"},
     241             :         {AclProfType::AclrtNotifySetImportPidInterServer,       "aclrtNotifySetImportPidInterServer"},
     242             :         {AclProfType::AclrtMemcpyAsyncWithOffset,               "aclrtMemcpyAsyncWithOffset"},
     243             :         {AclProfType::AclrtGetOpExecuteTimeOut,                 "aclrtGetOpExecuteTimeOut"},
     244             :         {AclProfType::AclrtCheckArchCompatibility,              "aclrtCheckArchCompatibility"},
     245             :         {AclProfType::AclrtCmoGetDescSize,                      "aclrtCmoGetDescSize"},
     246             :         {AclProfType::AclrtCmoSetDesc,                          "aclrtCmoSetDesc"},
     247             :         {AclProfType::AclrtCmoAsyncWithDesc,                    "aclrtCmoAsyncWithDesc"},
     248             :         {AclProfType::AclmdlRIAbort,                            "aclmdlRIAbort"},
     249             :         {AclProfType::AclrtCntNotifyRecord,                     "aclrtCntNotifyRecord"},
     250             :         {AclProfType::AclrtCntNotifyWaitWithTimeout,            "aclrtCntNotifyWaitWithTimeout"},
     251             :         {AclProfType::AclrtCntNotifyReset,                      "aclrtCntNotifyReset"},
     252             :         {AclProfType::AclrtCntNotifyGetId,                      "aclrtCntNotifyGetId"},
     253             :         {AclProfType::AclrtPersistentTaskClean,                 "aclrtPersistentTaskClean"},
     254             :         {AclProfType::AclrtGetErrorVerbose,                     "aclrtGetErrorVerbose"},
     255             :         {AclProfType::AclrtRepairError,                         "aclrtRepairError"},
     256             :         {AclProfType::AclrtMemSetAccess,                        "aclrtMemSetAccess"},
     257             :         {AclProfType::AclrtSetOpExecuteTimeOutV2,               "aclrtSetOpExecuteTimeOutV2"},
     258             :         {AclProfType::AclrtGetOpTimeOutInterval,                "aclrtGetOpTimeOutInterval"},
     259             :         {AclProfType::AclrtSnapShotProcessLock,                 "aclrtSnapShotProcessLock"},
     260             :         {AclProfType::AclrtSnapShotProcessUnlock,               "aclrtSnapShotProcessUnlock"},
     261             :         {AclProfType::AclrtSnapShotProcessBackup,               "aclrtSnapShotProcessBackup"},
     262             :         {AclProfType::AclrtSnapShotProcessRestore,              "aclrtSnapShotProcessRestore"},
     263             :         {AclProfType::AclrtFreeWithDevSync,                     "aclrtFreeWithDevSync"},
     264             :         {AclProfType::AclrtFreeHostWithDevSync,                 "aclrtFreeHostWithDevSync"},
     265             :         {AclProfType::AclrtCacheLastTaskOpInfo,                 "aclrtCacheLastTaskOpInfo"},
     266             :         {AclProfType::AclrtGetFunctionAttribute,                "aclrtGetFunctionAttribute"},
     267             :         {AclProfType::AclrtIpcGetEventHandle,                   "aclrtIpcGetEventHandle"},
     268             :         {AclProfType::AclrtIpcOpenEventHandle,                  "aclrtIpcOpenEventHandle"},
     269             :         {AclProfType::AclrtMemRetainAllocationHandle,           "aclrtMemRetainAllocationHandle"},
     270             :         {AclProfType::AclrtMemGetAllocationPropertiesFromHandle,"aclrtMemGetAllocationPropertiesFromHandle"},
     271             :         {AclProfType::AclrtHostMemMapCapabilities,              "aclrtHostMemMapCapabilities"},
     272             :         {AclProfType::AclrtGetMemUsageInfo,                     "aclrtGetMemUsageInfo"},
     273             :         {AclProfType::AclrtReserveMemAddressNoUCMemory,         "aclrtReserveMemAddressNoUCMemory"},
     274             :         {AclProfType::AclrtMemGetAddressRange,                  "aclrtMemGetAddressRange"},
     275             :         {AclProfType::aclrtMemP2PMap,                           "aclrtMemP2PMap"},
     276             :         {AclProfType::AclrtMemAllocManaged,                     "aclrtMemAllocManaged"},
     277             :         {AclProfType::AclrtMemPoolCreate,                       "aclrtMemPoolCreate"},
     278             :         {AclProfType::AclrtMemPoolDestroy,                      "aclrtMemPoolDestroy"},
     279             :         {AclProfType::AclrtMemPoolSetAttr,                      "aclrtMemPoolSetAttr"},
     280             :         {AclProfType::AclrtMemPoolGetAttr,                      "aclrtMemPoolGetAttr"},
     281             :         {AclProfType::AclmdlRIDestroyRegisterCallback,          "aclmdlRIDestroyRegisterCallback"},
     282             :         {AclProfType::AclmdlRIDestroyUnregisterCallback,        "aclmdlRIDestroyUnregisterCallback"},
     283             : };
     284             : 
     285         533 : aclError RegisterType(const uint32_t index) {
     286         533 :     const AclProfType type = static_cast<AclProfType>(index);
     287         533 :     const auto iter = PROF_TYPE_TO_NAMES.find(type);
     288         533 :     if (iter != PROF_TYPE_TO_NAMES.cend()) {
     289         533 :         const auto ret = MsprofRegTypeInfo(MSPROF_REPORT_ACL_LEVEL, index, iter->second.c_str());
     290         533 :         if (ret != MSPROF_ERROR_NONE) {
     291           5 :             ACL_LOG_CALL_ERROR("Registered api type [%u] failed = %d", index, ret);
     292           5 :             return ACL_ERROR_PROFILING_FAILURE;
     293             :         }
     294             :     }
     295         528 :     return ACL_SUCCESS;
     296             : }
     297          26 : AclProfilingManager &AclProfilingManager::GetInstance()
     298             : {
     299          26 :     static AclProfilingManager profilingManager;
     300          26 :     return profilingManager;
     301             : }
     302             : 
     303           6 : aclError AclProfilingManager::Init()
     304             : {
     305          12 :     const std::lock_guard<std::mutex> lk(mutex_);
     306           6 :     const aclError reg_ret = RegisterProfilingType();
     307           6 :     if (reg_ret != 0) {
     308           5 :         ACL_LOG_INNER_ERROR("[Init][ProfEngine]init acl profiling reg failed, errorCode = %d", reg_ret);
     309           5 :         return reg_ret;
     310             :     }
     311           1 :     isProfiling_ = true;
     312           1 :     AclProfilingReporter::profRun = true;
     313           1 :     return ACL_SUCCESS;
     314             : }
     315             : 
     316           1 : aclError AclProfilingManager::UnInit()
     317             : {
     318           1 :     const std::lock_guard<std::mutex> lk(mutex_);
     319           1 :     isProfiling_ = false;
     320           1 :     AclProfilingReporter::profRun = false;
     321           2 :     return ACL_SUCCESS;
     322             : }
     323             : 
     324           0 : bool AclProfilingManager::IsDeviceListEmpty() const
     325             : {
     326           0 :     return deviceList_.empty();
     327             : }
     328             : 
     329           2 : aclError AclProfilingManager::AddDeviceList(const uint32_t *const deviceIdList, const uint32_t deviceNums)
     330             : {
     331           2 :     if (deviceNums == 0U) {
     332           1 :         return ACL_SUCCESS;
     333             :     }
     334           1 :     ACL_REQUIRES_NOT_NULL(deviceIdList);
     335           4 :     for (size_t devId = 0U; devId < deviceNums; devId++) {
     336           3 :         if (deviceList_.count(*(deviceIdList + devId)) == 0U) {
     337           3 :             (void)deviceList_.insert(*(deviceIdList + devId));
     338           3 :             ACL_LOG_INFO("device id %u is successfully added in acl profiling", *(deviceIdList + devId));
     339             :         }
     340             :     }
     341           1 :     return ACL_SUCCESS;
     342             : }
     343             : 
     344           2 : aclError AclProfilingManager::RemoveDeviceList(const uint32_t *const deviceIdList, const uint32_t deviceNums)
     345             : {
     346           2 :     if (deviceNums == 0U) {
     347           1 :         return ACL_SUCCESS;
     348             :     }
     349           1 :     ACL_REQUIRES_NOT_NULL(deviceIdList);
     350           4 :     for (size_t devId = 0U; devId < deviceNums; devId++) {
     351           3 :         const auto iter = deviceList_.find(*(deviceIdList + devId));
     352           3 :         if (iter != deviceList_.end()) {
     353           3 :             (void)deviceList_.erase(iter);
     354             :         }
     355             :     }
     356           1 :     return ACL_SUCCESS;
     357             : }
     358             : 
     359           7 : aclError AclProfilingManager::RegisterProfilingType() const
     360             : {
     361         535 :     for (uint32_t i = static_cast<uint32_t>(AclProfType::AclRtProfTypeStart) + 1U;
     362         535 :          i < static_cast<uint32_t>(AclProfType::AclRtProfTypeEnd); ++i) {
     363         533 :         const auto ret = RegisterType(i);
     364         533 :         if (ret != ACL_SUCCESS) {
     365           5 :             return ret;
     366             :         }
     367             :     }
     368           2 :     return ACL_SUCCESS;
     369             : }
     370             : }  // namespace acl

Generated by: LCOV version 1.14