LCOV - code coverage report
Current view: top level - legacy/ascend910/framework/device/common - aicpu_hccl_common.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 77.8 % 9 7
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 2 2

            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 __AICPU_HCCL_COMMON_H__
      12              : #define __AICPU_HCCL_COMMON_H__
      13              : 
      14              : #include "profiling_manager_device.h"
      15              : #include "dtype_common.h"
      16              : #include "log.h"
      17              : #include "sal_pub.h"
      18              : 
      19         1033 : inline uint32_t DataUnitSize(HcclDataType dataType)
      20              : {
      21         1033 :     if (dataType >= HCCL_DATA_TYPE_RESERVED) {
      22            0 :         HCCL_ERROR(
      23              :             "[dataUnitSize]data type[%s] out of range[%d, %d]", GetDataTypeEnumStr(dataType).c_str(),
      24              :             HCCL_DATA_TYPE_INT8, HCCL_DATA_TYPE_RESERVED - 1);
      25            0 :         return 0;
      26              :     }
      27              : 
      28         1033 :     return SIZE_TABLE[dataType];
      29              : }
      30              : 
      31              : #define NSEC_PER_SEC 1000000000U
      32              : 
      33    295473899 : inline u64 GetCurCpuTimestamp(bool isProfTime = false)
      34              : {
      35              : #ifndef CCL_LLT
      36              :     if (isProfTime && dfx::ProfilingManager::GetProfL1State()) {
      37              :         uint64_t cntvct;
      38              :         AsmCntvc(cntvct);
      39              :         return cntvct;
      40              :     } else {
      41              :         struct timespec timestamp;
      42              :         (void)clock_gettime(CLOCK_MONOTONIC_RAW, &timestamp);
      43              :         return static_cast<u64>((timestamp.tv_sec * NSEC_PER_SEC) + (timestamp.tv_nsec));
      44              :     }
      45              : #else
      46     45978248 :     struct timespec timestamp;
      47    295473899 :     (void)clock_gettime(CLOCK_MONOTONIC_RAW, &timestamp);
      48    295473899 :     return static_cast<u64>((timestamp.tv_sec * NSEC_PER_SEC) + (timestamp.tv_nsec));
      49              : #endif
      50              : }
      51              : 
      52              : #endif // __AICPU_HCCL_COMMON_HPP__
        

Generated by: LCOV version 2.0-1