LCOV - code coverage report
Current view: top level - utils/include/utils - kernel_check_vec_reduce_util.h (source / functions) Coverage Total Hit
Test: coverage.info_filtered Lines: 84.0 % 131 110
Test Date: 2026-07-27 14:41:20 Functions: 85.7 % 7 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              : /*!
      12              :  * \file kernel_check_vec_reduce_util.h
      13              :  * \brief
      14              :  */
      15              : 
      16              : #ifndef ASCENDC_CHECK_VEC_REDUCE_UTIL_H
      17              : #define ASCENDC_CHECK_VEC_REDUCE_UTIL_H
      18              : #if ASCENDC_CPU_DEBUG
      19              : #include <string>
      20              : #include "kernel_utils.h"
      21              : namespace AscendC {
      22              : namespace check {
      23              : struct VecReduceApiParams {
      24              :     VecReduceApiParams() {}
      25           72 :     VecReduceApiParams(
      26              :         uint64_t dstAddrIn, uint64_t src0AddrIn, uint32_t dstDtypeBytesIn, uint32_t src0DtypeBytesIn, int32_t repeatIn,
      27              :         uint16_t dstRepStrideIn, uint16_t srcBlkStrideIn, uint16_t srcRepStrideIn, uint64_t dstSizeIn,
      28              :         uint64_t src0SizeIn, uint8_t dstPosIn, uint8_t src0PosIn)
      29           72 :     {
      30           72 :         dstAddr = dstAddrIn;
      31           72 :         src0Addr = src0AddrIn;
      32           72 :         dstDtypeBytes = dstDtypeBytesIn;
      33           72 :         src0DtypeBytes = src0DtypeBytesIn;
      34           72 :         repeatTimes = repeatIn;
      35           72 :         dstRepeatStride = dstRepStrideIn;
      36           72 :         src0BlockStride = srcBlkStrideIn;
      37           72 :         src0RepeatStride = srcRepStrideIn;
      38           72 :         dstSize = dstSizeIn;
      39           72 :         src0Size = src0SizeIn;
      40           72 :         dstLogicPos = dstPosIn;
      41           72 :         src0LogicPos = src0PosIn;
      42           72 :         dstPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(dstPosIn)));
      43           72 :         src0Pos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(src0PosIn)));
      44           72 :     }
      45           28 :     VecReduceApiParams(
      46              :         uint64_t dstAddrIn, uint64_t src0AddrIn, uint64_t src1AddrIn, uint32_t dstDtypeBytesIn,
      47              :         uint32_t src0DtypeBytesIn, uint32_t src1DtypeBytesIn, int32_t repeatIn, uint32_t calCountIn, bool calIndexIn,
      48              :         uint64_t dstSizeIn, uint64_t src0SizeIn, uint64_t src1SizeIn, uint8_t dstPosIn, uint8_t src0PosIn,
      49              :         uint8_t src1PosIn)
      50           28 :     {
      51           28 :         dstAddr = dstAddrIn;
      52           28 :         src0Addr = src0AddrIn;
      53           28 :         src1Addr = src1AddrIn;
      54           28 :         dstDtypeBytes = dstDtypeBytesIn;
      55           28 :         src0DtypeBytes = src0DtypeBytesIn;
      56           28 :         src1DtypeBytes = src1DtypeBytesIn;
      57           28 :         repeatTimes = repeatIn;
      58           28 :         calCount = calCountIn;
      59           28 :         calIndex = calIndexIn;
      60           28 :         dstSize = dstSizeIn;
      61           28 :         src0Size = src0SizeIn;
      62           28 :         src1Size = src1SizeIn;
      63           28 :         dstLogicPos = dstPosIn;
      64           28 :         src0LogicPos = src0PosIn;
      65           28 :         src1LogicPos = src1PosIn;
      66           28 :         dstPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(dstPosIn)));
      67           28 :         src0Pos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(src0PosIn)));
      68           28 :         src1Pos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(src1PosIn)));
      69           28 :     }
      70              : 
      71            4 :     VecReduceApiParams(
      72              :         uint64_t dstAddrIn, uint64_t src0AddrIn, uint64_t src1AddrIn, uint32_t dstDtypeBytesIn,
      73              :         uint32_t src0DtypeBytesIn, uint32_t src1DtypeBytesIn, int32_t repeatIn, uint32_t calCountIn, uint64_t dstSizeIn,
      74              :         uint64_t src0SizeIn, uint64_t src1SizeIn, uint8_t dstPosIn, uint8_t src0PosIn, uint8_t src1PosIn)
      75            4 :     {
      76            4 :         dstAddr = dstAddrIn;
      77            4 :         src0Addr = src0AddrIn;
      78            4 :         src1Addr = src1AddrIn;
      79            4 :         dstDtypeBytes = dstDtypeBytesIn;
      80            4 :         src0DtypeBytes = src0DtypeBytesIn;
      81            4 :         src1DtypeBytes = src1DtypeBytesIn;
      82            4 :         repeatTimes = repeatIn;
      83            4 :         calCount = calCountIn;
      84            4 :         dstSize = dstSizeIn;
      85            4 :         src0Size = src0SizeIn;
      86            4 :         src1Size = src1SizeIn;
      87            4 :         dstLogicPos = dstPosIn;
      88            4 :         src0LogicPos = src0PosIn;
      89            4 :         src1LogicPos = src1PosIn;
      90            4 :         dstPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(dstPosIn)));
      91            4 :         src0Pos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(src0PosIn)));
      92            4 :         src1Pos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(src1PosIn)));
      93            4 :     }
      94              : 
      95            4 :     VecReduceApiParams(
      96              :         uint64_t dstAddrIn, uint64_t src0AddrIn, uint32_t dstDtypeBytesIn, uint32_t src0DtypeBytesIn,
      97              :         uint32_t calCountIn, uint64_t dstSizeIn, uint64_t src0SizeIn, uint8_t dstPosIn, uint8_t src0PosIn)
      98            4 :     {
      99            4 :         dstAddr = dstAddrIn;
     100            4 :         src0Addr = src0AddrIn;
     101            4 :         dstDtypeBytes = dstDtypeBytesIn;
     102            4 :         src0DtypeBytes = src0DtypeBytesIn;
     103            4 :         calCount = calCountIn;
     104            4 :         dstSize = dstSizeIn;
     105            4 :         src0Size = src0SizeIn;
     106            4 :         dstLogicPos = dstPosIn;
     107            4 :         src0LogicPos = src0PosIn;
     108            4 :         dstPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(dstPosIn)));
     109            4 :         src0Pos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(src0PosIn)));
     110            4 :     }
     111              : 
     112            0 :     VecReduceApiParams(
     113              :         uint64_t dstAddrIn, uint64_t src0AddrIn, uint64_t src1AddrIn, uint32_t dstDtypeBytesIn,
     114              :         uint32_t src0DtypeBytesIn, uint32_t src1DtypeBytesIn, int32_t repeatIn, bool calIndexIn, uint64_t dstSizeIn,
     115              :         uint64_t src0SizeIn, uint64_t src1SizeIn, uint8_t dstPosIn, uint8_t src0PosIn, uint8_t src1PosIn,
     116              :         uint16_t src0RepeatStrideIn)
     117            0 :     {
     118            0 :         dstAddr = dstAddrIn;
     119            0 :         src0Addr = src0AddrIn;
     120            0 :         src1Addr = src1AddrIn;
     121            0 :         dstDtypeBytes = dstDtypeBytesIn;
     122            0 :         src0DtypeBytes = src0DtypeBytesIn;
     123            0 :         src1DtypeBytes = src1DtypeBytesIn;
     124            0 :         repeatTimes = repeatIn;
     125            0 :         calIndex = calIndexIn;
     126            0 :         dstSize = dstSizeIn;
     127            0 :         src0Size = src0SizeIn;
     128            0 :         src1Size = src1SizeIn;
     129            0 :         dstLogicPos = dstPosIn;
     130            0 :         src0LogicPos = src0PosIn;
     131            0 :         src1LogicPos = src1PosIn;
     132            0 :         dstPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(dstPosIn)));
     133            0 :         src0Pos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(src0PosIn)));
     134            0 :         src1Pos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(src1PosIn)));
     135            0 :         src0RepeatStride = src0RepeatStrideIn;
     136            0 :     }
     137              : 
     138            8 :     VecReduceApiParams(
     139              :         uint64_t dstAddrIn, uint64_t src0AddrIn, uint64_t src1AddrIn, uint32_t dstDtypeBytesIn,
     140              :         uint32_t src0DtypeBytesIn, uint32_t src1DtypeBytesIn, int32_t repeatIn, uint64_t dstSizeIn, uint64_t src0SizeIn,
     141              :         uint64_t src1SizeIn, uint8_t dstPosIn, uint8_t src0PosIn, uint8_t src1PosIn, uint16_t src0RepeatStrideIn)
     142            8 :     {
     143            8 :         dstAddr = dstAddrIn;
     144            8 :         src0Addr = src0AddrIn;
     145            8 :         src1Addr = src1AddrIn;
     146            8 :         dstDtypeBytes = dstDtypeBytesIn;
     147            8 :         src0DtypeBytes = src0DtypeBytesIn;
     148            8 :         src1DtypeBytes = src1DtypeBytesIn;
     149            8 :         repeatTimes = repeatIn;
     150            8 :         dstSize = dstSizeIn;
     151            8 :         src0Size = src0SizeIn;
     152            8 :         src1Size = src1SizeIn;
     153            8 :         dstLogicPos = dstPosIn;
     154            8 :         src0LogicPos = src0PosIn;
     155            8 :         src1LogicPos = src1PosIn;
     156            8 :         dstPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(dstPosIn)));
     157            8 :         src0Pos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(src0PosIn)));
     158            8 :         src1Pos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(src1PosIn)));
     159            8 :         src0RepeatStride = src0RepeatStrideIn;
     160            8 :     }
     161              : 
     162              :     uint64_t dstAddr = 0;
     163              :     uint64_t src0Addr = 0;
     164              :     uint64_t src1Addr = 0;
     165              :     uint8_t repeatTimes = 0;
     166              :     uint16_t dstBlockStride = 0;
     167              :     uint16_t src0BlockStride = 0;
     168              :     uint16_t src1BlockStride = 0;
     169              :     uint16_t dstRepeatStride = 0;
     170              :     uint16_t src0RepeatStride = 0;
     171              :     uint16_t src1RepeatStride = 0;
     172              :     uint32_t dstDtypeBytes = 0;
     173              :     uint32_t src0DtypeBytes = 0;
     174              :     uint32_t src1DtypeBytes = 0;
     175              :     uint64_t dstSize = 0;
     176              :     uint64_t src0Size = 0;
     177              :     uint64_t src1Size = 0;
     178              :     uint8_t dstLogicPos = 0;
     179              :     uint8_t src0LogicPos = 0;
     180              :     uint8_t src1LogicPos = 0;
     181              :     uint8_t dstPos = 0;
     182              :     uint8_t src0Pos = 0;
     183              :     uint8_t src1Pos = 0;
     184              :     uint32_t calCount = 0;
     185              :     bool calIndex = 0;
     186              : };
     187              : 
     188              : struct VecReduceWhlApiParams {
     189              :     VecReduceWhlApiParams() {}
     190           36 :     VecReduceWhlApiParams(
     191              :         uint64_t dstAddrIn, uint64_t src0AddrIn, uint32_t dstDtypeBytesIn, uint32_t src0DtypeBytesIn, int32_t repeatIn,
     192              :         uint16_t dstRepStrideIn, uint16_t srcBlkStrideIn, uint16_t srcRepStrideIn, ReduceOrder orderIn,
     193              :         uint64_t dstSizeIn, uint64_t src0SizeIn, uint8_t dstPosIn, uint8_t src0PosIn)
     194           36 :     {
     195           36 :         dstAddr = dstAddrIn;
     196           36 :         src0Addr = src0AddrIn;
     197           36 :         dstDtypeBytes = dstDtypeBytesIn;
     198           36 :         src0DtypeBytes = src0DtypeBytesIn;
     199           36 :         repeatTimes = repeatIn;
     200           36 :         dstRepeatStride = dstRepStrideIn;
     201           36 :         src0BlockStride = srcBlkStrideIn;
     202           36 :         src0RepeatStride = srcRepStrideIn;
     203           36 :         order = orderIn;
     204           36 :         dstSize = dstSizeIn;
     205           36 :         src0Size = src0SizeIn;
     206           36 :         dstLogicPos = dstPosIn;
     207           36 :         src0LogicPos = src0PosIn;
     208           36 :         dstPos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(dstPosIn)));
     209           36 :         src0Pos = static_cast<uint8_t>(GetPhyType(static_cast<TPosition>(src0PosIn)));
     210           36 :     }
     211              : 
     212              :     uint64_t dstAddr = 0;
     213              :     uint64_t src0Addr = 0;
     214              :     uint8_t repeatTimes = 0;
     215              :     uint16_t src0BlockStride = 0;
     216              :     uint16_t dstRepeatStride = 0;
     217              :     uint16_t src0RepeatStride = 0;
     218              :     uint32_t dstDtypeBytes = 0;
     219              :     uint32_t src0DtypeBytes = 0;
     220              :     ReduceOrder order = ReduceOrder::ORDER_VALUE_INDEX;
     221              :     uint64_t dstSize = 0;
     222              :     uint64_t src0Size = 0;
     223              :     uint8_t dstLogicPos = 0;
     224              :     uint8_t src0LogicPos = 0;
     225              :     uint8_t dstPos = 0;
     226              :     uint8_t src0Pos = 0;
     227              : };
     228              : 
     229              : bool CheckFunReduceImplForMaskArray(VecReduceApiParams& chkParams, const uint64_t mask[], const char* intriName);
     230              : bool CheckFunReduceImpl(VecReduceApiParams& chkParams, const uint64_t mask, const char* intriName);
     231              : bool CheckFunReduceImpl(VecReduceApiParams& chkParams, const char* intriName);
     232              : 
     233              : bool CheckFunReduceOtherImplForMaskArray(VecReduceApiParams& chkParams, const uint64_t mask[], const char* intriName);
     234              : bool CheckFunReduceOtherImpl(VecReduceApiParams& chkParams, const uint64_t mask, const char* intriName);
     235              : 
     236              : bool CheckFunReduceOtherWhlImplForMaskArray(
     237              :     VecReduceWhlApiParams& chkParams, const uint64_t mask[], const char* intriName);
     238              : bool CheckFunReduceOtherWhlImpl(VecReduceWhlApiParams& chkParams, const uint64_t mask, const char* intriName);
     239              : bool CheckFunReduceImplMode2(VecReduceApiParams& chkParams, const char* intriName);
     240              : 
     241              : } // namespace check
     242              : } // namespace AscendC
     243              : #endif
     244              : #endif
        

Generated by: LCOV version 2.0-1