Skip to content

clock

产品支持情况

  • Ascend 950PR/Ascend 950DT:支持
  • Atlas A3 训练系列产品/Atlas A3 推理系列产品:支持
  • Atlas A2 训练系列产品/Atlas A2 推理系列产品:支持
  • Atlas 200I/500 A2 推理产品:不支持
  • Atlas 推理系列产品AI Core:不支持
  • Atlas 推理系列产品Vector Core:不支持
  • Atlas 训练系列产品:不支持
  • Kirin X90:不支持
  • Kirin 9030:不支持

功能说明

本接口在SIMD和SIMT调试场景中提供Clock时间戳功能,用于记录从程序启动到接口调用时刻所经历的时钟周期数(Cycle Count),便于精确分析执行延迟和性能瓶颈。

函数原型

C++
__aicore__ inline uint64_t clock(void)

以下接口为SIMT中所使用的clock接口,仅支持Ascend 950PR/Ascend 950DT。

C++
inline uint64_t clock(void)

参数说明

返回值说明

从程序开始到调用时所经历的时钟周期数。

约束说明

  • SIMT场景的支持情况如下:
    • Ascend 950PR/Ascend 950DT:支持。
  • Atlas A3 训练系列产品/Atlas A3 推理系列产品:不支持。
  • Atlas A2 训练系列产品/Atlas A2 推理系列产品:不支持。
  • 需要包含的头文件

    使用该接口需要包含"utils/debug/asc_time.h"头文件。

    C++
    #include "utils/debug/asc_time.h"
    

    调用示例

    • SIMT编程场景:

      C++
      __global__ __launch_bounds__(1024) void SimtKernel(uint64_t* dst)
      {
          int idx = threadIdx.x + blockIdx.x * blockDim.x;
          dst[idx] = clock();
      }
      
    • SIMD与SIMT混合编程场景:

      C++
      __simt_vf__ __launch_bounds__(1024) inline void SimtKernel(__gm__ uint64_t* dst)
      {
          int idx = threadIdx.x + blockIdx.x * blockDim.x;
          dst[idx] = clock();
      }
      
    • SIMD编程场景:

      C++
      __global__ __aicore__ void AicoreKernel(__gm__ uint64_t* dst)
      {
          int idx = AscendC::GetBlockIdx();
          dst[idx] = clock();
      }
      

    免责声明:本站内容由 asc-devkit 仓 master 分支自动编译生成,属于持续开发版本,可能存在缺陷,仅供预览与参考。如需稳定及商用资料,请查阅官方 昇腾社区