LCOV - code coverage report
Current view: top level - src/api_check - kernel_check_params.h (source / functions) Coverage Total Hit
Test: coverage.info_filtered Lines: 100.0 % 5 5
Test Date: 2026-07-27 14:41:20 Functions: 100.0 % 3 3

            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              : /*!
      12              :  * \file kernel_check_params.h
      13              :  * \brief
      14              :  */
      15              : 
      16              : #ifndef ASCENDC_CHECK_PARAMS_H
      17              : #define ASCENDC_CHECK_PARAMS_H
      18              : #include <map>
      19              : #include "dlog_pub.h"
      20              : #include "kernel_utils.h"
      21              : #ifdef __DAV_M200__
      22              : #include "ascend610_ini.h"
      23              : #elif defined __DAV_C100__
      24              : #include "ascend910_ini.h"
      25              : #elif defined __DAV_C220__
      26              : #include "ascend910B1_ini.h"
      27              : #elif defined __DAV_M300__ || (defined(__NPU_ARCH__) && (__NPU_ARCH__ == 3003))
      28              : #include "ascend310B1_ini.h"
      29              : #elif defined(__NPU_ARCH__) && (__NPU_ARCH__ == 3102 || __NPU_ARCH__ == 3103 || __NPU_ARCH__ == 3113)
      30              : #include "ascend610Lite_ini.h"
      31              : #elif defined(__NPU_ARCH__) && (__NPU_ARCH__ == 3510)
      32              : #include "ascend950pr_9599_ini.h"
      33              : #elif defined(__NPU_ARCH__) && (__NPU_ARCH__ == 5102)
      34              : #include "mc62cm12aa_ini.h"
      35              : #endif
      36              : 
      37              : namespace AscendC {
      38              : namespace check {
      39              : #define ASCENDC_CHECK(x)  \
      40              :     do {                  \
      41              :         if (!(x)) {       \
      42              :             return false; \
      43              :         }                 \
      44              :     } while (0)
      45              : 
      46              : #define ASCENDC_CHECK_AND_LOG(cond, behavior) \
      47              :     do {                                      \
      48              :         if (!(cond)) {                        \
      49              :             behavior;                         \
      50              :             return false;                     \
      51              :         }                                     \
      52              :     } while (0)
      53              : 
      54              : #define ASCENDC_MODULE_NAME static_cast<int32_t>(ASCENDCKERNEL)
      55              : 
      56              : #define CHECK_LOG_DEBUG(format, ...)                                 \
      57              :     do {                                                             \
      58              :         dlog_debug(ASCENDC_MODULE_NAME, format "\n", ##__VA_ARGS__); \
      59              :     } while (0)
      60              : 
      61              : #define CHECK_LOG_INFO(format, ...)                                 \
      62              :     do {                                                            \
      63              :         dlog_info(ASCENDC_MODULE_NAME, format "\n", ##__VA_ARGS__); \
      64              :     } while (0)
      65              : 
      66              : #define CHECK_LOG_WARNING(format, ...)                              \
      67              :     do {                                                            \
      68              :         dlog_warn(ASCENDC_MODULE_NAME, format "\n", ##__VA_ARGS__); \
      69              :     } while (0)
      70              : 
      71              : #define CHECK_LOG_ERROR(format, ...)                                 \
      72              :     do {                                                             \
      73              :         printf("[ERROR]" format "\n", ##__VA_ARGS__);                \
      74              :         dlog_error(ASCENDC_MODULE_NAME, format "\n", ##__VA_ARGS__); \
      75              :     } while (0)
      76              : 
      77              : enum class HardWareIndex { GM = 0, UB, L1, L0A, L0B, L0C, BIAS, FIXBUF, MAX };
      78              : 
      79              : class GlobalParams {
      80              : public:
      81         1712 :     static GlobalParams& Instance()
      82              :     {
      83         1712 :         static GlobalParams instance;
      84         1712 :         return instance;
      85              :     }
      86              : 
      87              :     const std::map<uint8_t, std::string> hardwareNameMap{
      88              :         {static_cast<uint8_t>(HardWareIndex::GM), "GM"},     {static_cast<uint8_t>(HardWareIndex::UB), "UB"},
      89              :         {static_cast<uint8_t>(HardWareIndex::L1), "L1"},     {static_cast<uint8_t>(HardWareIndex::L0A), "L0A"},
      90              :         {static_cast<uint8_t>(HardWareIndex::L0B), "L0B"},   {static_cast<uint8_t>(HardWareIndex::L0C), "L0C"},
      91              :         {static_cast<uint8_t>(HardWareIndex::BIAS), "BIAS"}, {static_cast<uint8_t>(HardWareIndex::FIXBUF), "FIXBUF"},
      92              :     };
      93              : 
      94              :     const std::map<uint8_t, uint64_t> bufferSizeMap{
      95              :         {static_cast<uint8_t>(HardWareIndex::UB), static_cast<uint64_t>(PlatFormParams::UB_SIZE)},
      96              :         {static_cast<uint8_t>(HardWareIndex::L1), static_cast<uint64_t>(PlatFormParams::L1_SIZE)},
      97              :         {static_cast<uint8_t>(HardWareIndex::L0A), static_cast<uint64_t>(PlatFormParams::L0A_SIZE)},
      98              :         {static_cast<uint8_t>(HardWareIndex::L0B), static_cast<uint64_t>(PlatFormParams::L0B_SIZE)},
      99              :         {static_cast<uint8_t>(HardWareIndex::L0C), static_cast<uint64_t>(PlatFormParams::L0C_SIZE)},
     100              :     };
     101              : 
     102              : private:
     103           78 :     GlobalParams() = default;
     104            6 :     ~GlobalParams() = default;
     105              : };
     106              : 
     107              : enum class TypeBitLen {
     108              :     K_B1_BITS = 1,
     109              :     K_B4_BITS = 4,
     110              :     K_B8_BITS = 8,
     111              :     K_B16_BITS = 16,
     112              :     K_B24_BITS = 24,
     113              :     K_B32_BITS = 32,
     114              :     K_B48_BITS = 48,
     115              :     K_B54_BITS = 54,
     116              :     K_B64_BITS = 64,
     117              : };
     118              : 
     119              : enum class TypeByteLen {
     120              :     K_B1_BYTE = 1,
     121              :     K_B2_BYTE = 2,
     122              :     K_B4_BYTE = 4,
     123              :     K_B8_BYTE = 8,
     124              : };
     125              : 
     126              : enum class CommonParams {
     127              :     MASK_MAX_ELE_LEN = 64,
     128              :     MASK_HIGH_IDX = 0,
     129              :     MASK_LOW_IDX = 1,
     130              : };
     131              : 
     132              : enum class ReduceCheckExtParams {
     133              :     VREDUCE_PER_REP_OUTPUT = 2,
     134              :     VREDUCE_CALL_INDEX_COUNT = 2,
     135              :     VREDUCE_BLK_DST_COUNT_MIN = 8,
     136              : };
     137              : 
     138              : enum class MaddCheckExtParams {
     139              :     MMAD_RANGE_MAX = 4095,
     140              : };
     141              : } // namespace check
     142              : } // namespace AscendC
     143              : #endif
        

Generated by: LCOV version 2.0-1