LCOV - code coverage report
Current view: top level - aicpu_processer - aicpu_processer.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 35 35
Test Date: 2026-07-28 10:54:05 Functions: 100.0 % 6 6

            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 "aicpu_engine.h"
      12              : #include "ae_def.hpp"
      13              : #include "ae_kernel_lib_manager.hpp"
      14              : #include "aicpu_event_struct.h"
      15              : #include "aicpu_context.h"
      16              : 
      17              : /**
      18              :  * @ingroup aicpu engine
      19              :  * @brief aeCallInterface: a interface to call  a function in a op kernfel lib
      20              :  * @param [in] addr: void *, should be HwtsTsKernel * format
      21              :  * @return int32_t
      22              : */
      23          126 : __attribute__((visibility("default"))) int32_t aeCallInterface(const void * const addr)
      24              : {
      25          126 :     if (addr == nullptr) {
      26            1 :         AE_ERR_LOG(AE_MODULE_ID, "Input param addr is NULL");
      27            1 :         return AE_STATUS_BAD_PARAM;
      28              :     }
      29          125 :     const auto strKernel = static_cast<const aicpu::HwtsTsKernel *>(addr);
      30          125 :     AE_INFO_LOG(AE_MODULE_ID, "Begin to CallKernelApi, kernelType=%u.", strKernel->kernelType);
      31              :     FUNC_PROFILE_START
      32              :     // step1. Get the Ai Kernel Lib
      33          125 :     const aicpu::KernelType kernelType = static_cast<const aicpu::KernelType>(strKernel->kernelType);
      34          125 :     cce::AIKernelsLibBase *targetKernelLib = nullptr;
      35          125 :     int32_t ret = cce::AIKernelsLibManger::GetKernelLib(kernelType, targetKernelLib);
      36          125 :     if ((ret == AE_STATUS_SUCCESS) && (targetKernelLib != nullptr)) {
      37              :         // step2. Call the Ai Kernel Lib unify abstract interface
      38          124 :         ret = targetKernelLib->CallKernelApi(kernelType, static_cast<const void *>(&strKernel->kernelBase));
      39              :     }
      40              :     FUNC_PROFILE_END
      41          124 :     return ret;
      42              : }
      43              : 
      44              : /**
      45              :  * @ingroup aicpu engine
      46              :  * @brief aeClear: a interface to clear all ai kernel lib
      47              :  * @return aeStatus_t
      48              : */
      49            2 : __attribute__((visibility("default"))) void aeClear()
      50              : {
      51           26 :     for (int32_t kernelType = aicpu::KERNEL_TYPE_CCE; kernelType <= aicpu::KERNEL_TYPE_RESERVED; kernelType++) {
      52           24 :         cce::AIKernelsLibManger::ClearKernelLib(static_cast<aicpu::KernelType>(kernelType));
      53              :     }
      54            2 : }
      55              : 
      56              : /**
      57              :  * @ingroup aicpu engine
      58              :  * @brief aeBatchLoadKernelSo: a interface to load kernel so
      59              :  * @param [in] kernelType: uint32_t, kernel type
      60              :  * @param [in] loadSoNum: uint32_t, so number
      61              :  * @param [in] soNames: const char_t*[], so name
      62              :  * @return aeStatus_t
      63              : */
      64            6 : __attribute__((visibility("default"))) aeStatus_t aeBatchLoadKernelSo(const uint32_t kernelType,
      65              :                                                                       const uint32_t loadSoNum,
      66              :                                                                       const char_t * const * const soNames)
      67              : {
      68            6 :     return cce::AIKernelsLibManger::BatchLoadKernelSo(static_cast<aicpu::KernelType>(kernelType), loadSoNum, soNames);
      69              : }
      70              : 
      71              : /**
      72              :  * @ingroup aicpu engine
      73              :  * @brief aeClear: a interface to close a so
      74              :  * @param [in]soName: so name
      75              :  * @return aeStatus_t
      76              : */
      77            3 : __attribute__((visibility("default"))) aeStatus_t aeCloseSo(const uint32_t kernelType, const char_t * const soName)
      78              : {
      79            3 :     cce::AIKernelsLibBase *targetKernelLib = nullptr;
      80            3 :     const aeStatus_t ret = cce::AIKernelsLibManger::GetKernelLib(static_cast<const aicpu::KernelType>(kernelType),
      81              :                                                                  targetKernelLib);
      82            3 :     if ((ret != AE_STATUS_SUCCESS)) {
      83            1 :         AE_ERR_LOG(AE_MODULE_ID, "aeCloseSo get kernel lib failed, kernelType[%u], ret[%u].", kernelType, ret);
      84            1 :         return ret;
      85              :     }
      86            2 :     return targetKernelLib->CloseSo(soName);
      87              : }
      88              : 
      89            2 : __attribute__((visibility("default"))) aeStatus_t AeAddSoInWhiteList(const char_t * const soName)
      90              : {
      91            2 :     if (soName == nullptr) {
      92            1 :         AE_ERR_LOG(AE_MODULE_ID, "Input param addr is NULL");
      93            1 :         return AE_STATUS_BAD_PARAM;
      94              :     }
      95            1 :     return cce::AIKernelsLibManger::AddSoInWhiteList(soName);
      96              : }
      97              : 
      98            2 : __attribute__((visibility("default"))) void AeDeleteSoInWhiteList(const char_t * const soName)
      99              : {
     100            2 :     if (soName == nullptr) {
     101            1 :         AE_ERR_LOG(AE_MODULE_ID, "Input param addr is NULL");
     102            1 :         return;
     103              :     }
     104            1 :     cce::AIKernelsLibManger::DelteSoInWhiteList(soName);
     105              : }
        

Generated by: LCOV version 2.0-1