LCOV - code coverage report
Current view: top level - aicpu_prof - prof_so_manager.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 1 1
Test Date: 2026-08-12 11:05:02 Functions: 100.0 % 1 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              : #ifndef PROF_SO_MANAGER_H
      11              : #define PROF_SO_MANAGER_H
      12              : 
      13              : #include <mutex>
      14              : #include <vector>
      15              : #include <string>
      16              : #include <unordered_map>
      17              : #include "prof_dev_api.h"
      18              : 
      19              : namespace aicpu {
      20              : using ProfAicpuStartRegisterFunc = int32_t (*)(AicpuStartFunc aicpuStartCallback, const struct AicpuStartPara* para);
      21              : using ProfReportDataFunc = int32_t (*)(VOID_PTR data, uint32_t len);
      22              : using ProfReportAdditionalInfoFunc = int32_t (*)(uint32_t agingFlag, const VOID_PTR data, uint32_t length);
      23              : using ProfAdprofAicpuStopFunc = int32_t (*)();
      24              : 
      25              : using ProfMsprofInitFunc = int32_t (*)(uint32_t dataType, VOID_PTR data, uint32_t dataLen);
      26              : using ProfMsprofReportAdditionalInfoFunc =
      27              :     int32_t (*)(uint32_t nonPersistantFlag, const VOID_PTR data, uint32_t length);
      28              : 
      29              : int32_t AdprofAicpuStartRegisterFunc(AicpuStartFunc aicpuStartCallback, const struct AicpuStartPara* para);
      30              : 
      31              : int32_t AdprofReportDataFunc(VOID_PTR data, uint32_t len);
      32              : 
      33              : int32_t AdprofReportAdditionalInfoFunc(uint32_t agingFlag, const VOID_PTR data, uint32_t length);
      34              : 
      35              : int32_t AdprofAicpuStopFunc();
      36              : 
      37              : int32_t MsprofInitFunc(uint32_t dataType, VOID_PTR data, uint32_t dataLen);
      38              : 
      39              : int32_t MsprofReportAdditionalInfoFunc(uint32_t nonPersistantFlag, const VOID_PTR data, uint32_t length);
      40              : 
      41              : class ProfSoManager {
      42              : public:
      43              :     static ProfSoManager* GetInstance();
      44              : 
      45              :     virtual ~ProfSoManager();
      46              : 
      47              :     /**
      48              :      * load msprof so
      49              :      */
      50              :     void LoadSo();
      51              : 
      52              :     /**
      53              :      * unload msprof so
      54              :      */
      55              :     void UnloadSo();
      56              : 
      57              :     /**
      58              :      * get function
      59              :      * @param name msprof function name
      60              :      * @return void *
      61              :      */
      62              :     void* GetFunc(const std::string& name) const;
      63              : 
      64              : private:
      65              :     /**
      66              :      * Init Function Map
      67              :      */
      68              :     void InitFunctionMap(const std::vector<std::string>& funcName);
      69            1 :     ProfSoManager() = default;
      70              : 
      71              :     std::unordered_map<std::string, void*> funcMap_;
      72              : 
      73              :     void* soHandle_ = nullptr;
      74              :     std::mutex profMtx_;
      75              : };
      76              : 
      77              : } // namespace aicpu
      78              : #endif // PROF_SO_MANAGER_H
        

Generated by: LCOV version 2.0-1