LCOV - code coverage report
Current view: top level - src/api_check - kernel_data_copy_check.cpp (source / functions) Coverage Total Hit
Test: coverage.info_filtered Lines: 75.0 % 20 15
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_data_copy_check.cpp
      13              :  * \brief
      14              :  */
      15              : 
      16              : #include "kernel_check_params.h"
      17              : #include "kernel_data_copy_check.h"
      18              : 
      19              : namespace AscendC {
      20              : namespace check {
      21            4 : bool TikcppDataCopyCheck::CheckAllHighLevel()
      22              : {
      23            4 :     ASCENDC_CHECK(CheckAddrAlign());
      24            0 :     return true;
      25              : }
      26              : 
      27            8 : bool TikcppDataCopyCheck::CheckDataCopyAlign(uint64_t addr, uint8_t pos, bool isSrc)
      28              : {
      29              :     // gm is 1 Byte aligned, so do not need to check aligned
      30            8 :     uint32_t dataType = (isSrc ? param_.srcDtypeBytes : param_.dstDtypeBytes);
      31              :     std::map<Hardware, uint32_t> alignSizeMap = {
      32              :         {Hardware::GM, 1},
      33              :         {Hardware::L1, 32},
      34              :         {Hardware::UB, 32},
      35            0 :         {Hardware::L0A, 512 * ((dataType + 1) / sizeof(uint16_t))},
      36            0 :         {Hardware::L0B, 512 * ((dataType + 1) / sizeof(uint16_t))},
      37            0 :         {Hardware::L0C, 512 * ((dataType + 1) / sizeof(uint16_t))},
      38              :         {Hardware::BIAS, 64},
      39           16 :     };
      40              : 
      41            8 :     if (pos != static_cast<uint8_t>(Hardware::GM)) {
      42            4 :         uint32_t alignBytes = alignSizeMap[static_cast<Hardware>(pos)];
      43            4 :         if (isSrc) {
      44           12 :             ASCENDC_CHECK(CheckTensorAddrAlign(addr, pos, alignBytes, "src"));
      45              :         } else {
      46            0 :             ASCENDC_CHECK(CheckTensorAddrAlign(addr, pos, alignBytes, "dst"));
      47              :         }
      48              :     }
      49            4 :     return true;
      50            8 : }
      51            4 : bool TikcppDataCopyCheck::CheckAddrAlign()
      52              : {
      53            4 :     bool retSrc = CheckDataCopyAlign(param_.srcAddr, param_.srcPos, true);
      54            4 :     bool retDst = CheckDataCopyAlign(param_.dstAddr, param_.dstPos, false);
      55            4 :     return retSrc && retDst;
      56              : }
      57              : } // namespace check
      58              : } // namespace AscendC
        

Generated by: LCOV version 2.0-1