LCOV - code coverage report
Current view: top level - legacy/ascend910/framework/device/inc - profiling_manager_device.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 75.0 % 4 3
Test Date: 2026-08-04 10:52:23 Functions: 50.0 % 2 1

            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              : #ifndef ASCEND_ACE_COMOP_HCCL_HCCL_AI_CPU_KERNEL_DFX_PROFILING_PROFILING_MANAGER_H_
      12              : #define ASCEND_ACE_COMOP_HCCL_HCCL_AI_CPU_KERNEL_DFX_PROFILING_PROFILING_MANAGER_H_
      13              : #include "hccl_types.h"
      14              : #include "stream_pub.h"
      15              : #include "hccl_common.h"
      16              : #include "common/aicpu_hccl_def.h"
      17              : #include "prof_common.h"
      18              : 
      19              : extern "C" {
      20              : __attribute__((weak)) int32_t AdprofReportBatchAdditionalInfo(uint32_t nonPersistantFlag, const void *data, uint32_t length);
      21              : __attribute__((weak)) int32_t MsprofReportBatchAdditionalInfo(uint32_t nonPersistantFlag, const VOID_PTR data, uint32_t length);
      22              : __attribute__((weak)) int32_t AdprofReportAdditionalInfo(uint32_t nonPersistantFlag, const void *data, uint32_t length);
      23              : __attribute__((weak)) int32_t MsprofReportAdditionalInfo(uint32_t nonPersistantFlag, const VOID_PTR data, uint32_t length);
      24              : __attribute__((weak)) int32_t AdprofCheckFeatureIsOn(uint64_t feature);
      25              : __attribute__((weak)) int32_t MsprofRegisterCallback(uint32_t moduleId, ProfCommandHandle handle);
      26              : __attribute__((weak)) uint64_t AdprofGetHashId(const char *hashInfo, size_t length);
      27              : __attribute__((weak)) uint64_t MsprofStr2Id(const char *hashInfo, size_t length);
      28              : };
      29              : namespace dfx {
      30              : 
      31              : struct ProfCommInfo {
      32              :     uint64_t groupNameHashId{0};
      33              :     u32 rankNum{0};
      34              :     u32 rankId{0};
      35              : 
      36            0 :     ProfCommInfo() {};
      37              : 
      38           11 :     ProfCommInfo(uint64_t groupNameHashId, u32 rankNum, u32 rankId)
      39           11 :         : groupNameHashId(groupNameHashId), rankNum(rankNum), rankId(rankId)
      40           11 :     {};
      41              : };
      42              : 
      43              : class ProfilingManager {
      44              : public:
      45              :     static HcclResult CallMsprofReportAdditionInfo(uint32_t type, uint64_t timeStamp, const void *data, int len);
      46              :     static void SqeInfo2MsprofAicpuMC2HcclInfo(const SqeInfo &sqeInfo, MsprofAicpuHcclTaskInfo &msprofAicpuMC2HcclInfo);
      47              :     static bool IsProfOn(uint64_t feature);
      48              : 
      49              :     /* AICPU profiling*/
      50              :     static bool IsProfL1On();
      51              :     static bool IsProfL0On();
      52              :     static void SetProL0On(bool val);
      53              :     static void SetProL1On(bool val);
      54              :     static bool IsL1fromOffToOn();
      55              :     static HcclResult ReportTaskInfo(s32 streamId, void* ctxPtr);
      56              :     static HcclResult ReportHcclOpInfo(MsprofAicpuHCCLOPInfo& hcclOpInfo, std::string &algTypeStr);
      57              :     static uint64_t GetProfHashId(const char *name, uint32_t len);
      58              :     static HcclResult GetProfInfoByStreamId(s32 streamId, ProfCommInfo& profInfo);
      59              :     static HcclResult AddProfInfoByStreamId(s32 streamId, const std::string &tag, const ProfCommInfo& profInfo);
      60              :     static HcclResult UpdateStartReportSqeIdx(s32 streamId, u32 newSqeTailIdx);
      61              :     static uint32_t GetStartReportSqeIdx(s32 streamId);
      62              :     static bool GetProfL0State();
      63              :     static bool GetProfL1State();
      64              :     static HcclResult ReportMainStreamTask(hccl::Stream& stream, uint16_t taskId, uint16_t type);
      65              :     static HcclResult ReportFilpTask(s32 streamId,  uint16_t taskId, uint32_t flipNum);
      66              :     static uint64_t TransferAlgType(AlgType algType);
      67              :     static void DumpHcclInfo(const MsprofAicpuHcclTaskInfo& taskInfo, u32 batchId, u32 idx);
      68              :     static void CommInfo2HcclInfo(const dfx::ProfCommInfo &profInfo, MsprofAicpuHcclTaskInfo &taskInfo);
      69              :     static HcclResult TaskInfo2Addition(const void *data, int len, MsprofAdditionalInfo& reporterData);
      70              : 
      71              : private:
      72              :     static std::mutex streamMutex_;
      73              :     static std::unordered_map<std::string, ProfCommInfo> tagOpInfoMap_;
      74              :     static std::unordered_map<s32, std::string> streamToTagMap_;
      75              : 
      76              :     static std::mutex startReportSqeIdxMutex_;
      77              :     static std::unordered_map<s32, u32> streamToSqeIdxMap_;
      78              :     static bool isL0Open_;
      79              :     static bool isL1Open_;
      80              : };
      81              : void TaskProfilingCallBack(void *userPtr, void *param, u32 length);
      82              : }  // namespace dfx
      83              : #endif  // ASCEND_ACE_COMOP_HCCL_HCCL_AI_CPU_KERNEL_DFX_PROFILING_PROFILING_MANAGER_H_
        

Generated by: LCOV version 2.0-1