LCOV - code coverage report
Current view: top level - aicpu_processer - ae_kernel_lib_aicpu_kfc.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 6 6
Test Date: 2026-07-28 10:54:05 Functions: 100.0 % 5 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              : #ifndef __AE_KERNEL_LIB_AICPU_KFC_H_
      12              : #define __AE_KERNEL_LIB_AICPU_KFC_H_
      13              : 
      14              : #include <string>
      15              : #include <mutex>
      16              : #include <vector>
      17              : #include "aicpu_context.h"
      18              : #include "aicpu_engine.h"
      19              : #include "ae_def.hpp"
      20              : #include "ae_kernel_lib_base.hpp"
      21              : #include "ae_so_manager.hpp"
      22              : 
      23              : namespace cce {
      24              :     using AicpuKFCOpFuncPtr = uint32_t(*)(void *);
      25              :     class AIKernelsLibAiCpuKFC : public cce::AIKernelsLibBase {
      26              :     public:
      27            2 :         ~AIKernelsLibAiCpuKFC()  override = default;
      28              :         /**
      29              :          * SINGLETON object get interface
      30              :          */
      31              :         static AIKernelsLibAiCpuKFC *GetInstance();
      32              :         /**
      33              :          * SINGLETON object destroy interface
      34              :          */
      35              :         static void DestroyInstance();
      36              :         /**
      37              :          * Implement get kernelName and kernelSoName
      38              :          */
      39              :         aeStatus_t GetKernelName(char_t *&kernelName, const aicpu::HwtsCceKernel *cceKernelBase) const;
      40              :         /**
      41              :          * Implement call a aicpu op kernel interface
      42              :          */
      43              :         int32_t CallKernelApi(const aicpu::KernelType kernelType, const void * const kernelBase) override;
      44              :         aeStatus_t Init() override;
      45            1 :         aeStatus_t BatchLoadKernelSo(const aicpu::KernelType kernelType,
      46              :                                      std::vector<std::string> &soVec) override
      47              :         {
      48              :             (void)kernelType;
      49              :             (void)soVec;
      50            1 :             return AE_STATUS_SUCCESS;
      51              :         }
      52            1 :         aeStatus_t CloseSo(const char_t * const soName) override
      53              :         {
      54              :             (void)soName;
      55            1 :             return AE_STATUS_SUCCESS;
      56              :         }
      57              :     private:
      58            1 :         AIKernelsLibAiCpuKFC() = default;
      59              :         /**
      60              :          * Run aicpu profiling
      61              :          */
      62              :         uint32_t RunAicpuFunc(const void* const kernelBase,
      63              :                               AicpuKFCOpFuncPtr &opFuncPtr) const;
      64              : 
      65              :         int32_t TransformKernelErrorCode(const uint32_t errCode, const char_t * const kernelName) const;
      66              : 
      67              :         int32_t GetApiGlobal(AicpuKFCOpFuncPtr &opFuncPtr, const char_t *kernelName) const;
      68              : 
      69              :         int32_t GetApiWhenSonameNotEmpty(const aicpu::KernelType kernelType, const uint32_t soNameLen,
      70              :             const char_t *kernelSoName, const char_t *kernelName, void* &funcAddr);
      71              : 
      72              :         int32_t GetApiBySoname(const aicpu::KernelType kernelType, const char_t *kernelSoName,
      73              :                                AicpuKFCOpFuncPtr &opFuncPtr, const char_t *kernelName);
      74              : 
      75              :     private:
      76              :         static AIKernelsLibAiCpuKFC *instance_;     // SINGLETON object
      77              :         // api cacher
      78              :         std::unordered_map<std::string, AicpuKFCOpFuncPtr> apiCacher_;
      79              :         // A Read Write lock to protect apiCacher_
      80              :         tAERwLock rwLock_ = PTHREAD_RWLOCK_INITIALIZER;
      81              :     };
      82              : }
      83              : #endif
        

Generated by: LCOV version 2.0-1