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-04 10:52:23 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("[dataUnitSize]data type[%s] out of range[%d, %d]", GetDataTypeEnumStr(dataType).c_str(),
      23              :             HCCL_DATA_TYPE_INT8, HCCL_DATA_TYPE_RESERVED - 1);
      24            0 :         return 0;
      25              :     }
      26              : 
      27         1033 :     return SIZE_TABLE[dataType];
      28              : }
      29              : 
      30              : #define NSEC_PER_SEC 1000000000U
      31              : 
      32    297083623 : inline u64 GetCurCpuTimestamp(bool isProfTime = false)
      33              : {
      34              : #ifndef CCL_LLT
      35              :     if (isProfTime && dfx::ProfilingManager::GetProfL1State()) {
      36              :         uint64_t cntvct;
      37              :         AsmCntvc(cntvct);
      38              :         return cntvct;
      39              :     } else {
      40              :         struct timespec timestamp;
      41              :         (void)clock_gettime(CLOCK_MONOTONIC_RAW, &timestamp);
      42              :         return static_cast<u64>((timestamp.tv_sec * NSEC_PER_SEC) + (timestamp.tv_nsec));
      43              :     }
      44              : #else
      45     45836223 :     struct timespec timestamp;
      46    297083623 :     (void)clock_gettime(CLOCK_MONOTONIC_RAW, &timestamp);
      47    297083623 :     return static_cast<u64>((timestamp.tv_sec * NSEC_PER_SEC) + (timestamp.tv_nsec));
      48              : #endif
      49              : }
      50              : 
      51              : #endif // __AICPU_HCCL_COMMON_HPP__
        

Generated by: LCOV version 2.0-1