LCOV - code coverage report
Current view: top level - aicpu_schedule/core/hwts_kernel - hwts_kernel.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 5 5
Test Date: 2026-07-28 10:54:05 Functions: 97.5 % 40 39

            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 HWTS_KERNEL_H
      12              : #define HWTS_KERNEL_H
      13              : 
      14              : #include <functional>
      15              : #include <memory>
      16              : #include <sstream>
      17              : #include <string>
      18              : 
      19              : #include "aicpusd_common.h"
      20              : #include "aicpusd_info.h"
      21              : #include "aicpusd_status.h"
      22              : 
      23              : #include "aicpu_event_struct.h"
      24              : 
      25              : namespace AicpuSchedule {
      26              : class AICPU_VISIBILITY HwTsKernelHandler {
      27              : public:
      28              :     virtual int32_t Compute(const aicpu::HwtsTsKernel &tsKernelInfo) = 0;
      29          167 :     virtual ~HwTsKernelHandler() = default;
      30              : };
      31              : 
      32              : using HwTsKernelCreatorFunc = std::function<std::shared_ptr<HwTsKernelHandler>(void)>;
      33              : 
      34              : AICPU_VISIBILITY bool RegisterHwTsKernel(const std::string &kernelType, const HwTsKernelCreatorFunc &func);
      35              : 
      36              : template <typename T, typename... Args>
      37           57 : inline std::shared_ptr<T> MakeHwTsKernelShared(Args &&...args)
      38              : {
      39              :     using T_NC = typename std::remove_const<T>::type;
      40           57 :     return std::make_shared<T_NC>(std::forward<Args>(args)...);
      41              : }
      42              : 
      43              : template<typename T>
      44              : class CreatorFunction {
      45              : public:
      46           57 :     std::shared_ptr<HwTsKernelHandler> operator()() const {
      47           57 :         return MakeHwTsKernelShared<T>();
      48              :     }
      49              : };
      50              : 
      51              : #define REGISTER_HWTS_KERNEL(kernelType, clazz)                      \
      52              :     bool g_##kernelType##_TsKernel_Creator __attribute__((unused)) = \
      53              :         RegisterHwTsKernel((kernelType), (CreatorFunction<clazz>()))
      54              : 
      55              : }  // namespace AicpuSchedule
      56              : 
      57              : #endif  // HWTS_KERNEL_H
        

Generated by: LCOV version 2.0-1