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

Generated by: LCOV version 2.0-1