Nvidia 的 FLOPS nvprof 输出

Nvidia's nvprof outputs for FLOPS

我看到 nvprof 可以分析内核中的 flop 数量(使用如下参数)。另外,当我浏览文档时(这里 http://docs.nvidia.com/cuda... 它说 flop_count_sp 是 "Number of single-precision floating-point operations executed by non-predicated threads (add, multiply, multiply-accumulate and special). Each multiply-accumulate operation contributes 2 to the count."

但是当我 运行 时,flop_count_sp 的结果(应该是 flop_count_sp_add + flop_count_sp_mul + flop_count_sp_special + 2 * flop_count_sp_fma) 我发现总和中不包括 flop_count_sp_special.

的值

你能建议我应该使用什么吗?我应该将此值添加到 flop_count_sp 的总和中,还是应该考虑公式不包括 flop_count_sp_special 的值?

另外请问这些特殊操作是什么?

我正在使用以下命令行:

nvprof --metrics flops_sp --metrics flops_sp_add --metrics flops_sp_mul --metrics flops_sp_fma --metrics flops_sp_special myKernel args

其中 myKernel 是我的 CUDA 内核的名称,它有一些由 args 给出的输入参数。

例如,我的 nvprof 输出的一部分如下所示:

 ==20549== Profiling result:
 ==20549== Metric result:
 Invocations                               Metric Name                        Metric Description         Min         Max         Avg
 Device "Tesla K40c (0)"
    Kernel: mykernel(float*, int, int, float*, int, float*, int*)
           2                             flop_count_sp  Floating Point Operations(Single Precisi       70888       70888       70888
           2                         flop_count_sp_add  Floating Point Operations(Single Precisi       14465       14465       14465
           2                         flop_count_sp_mul  Floating Point Operation(Single Precisio       14465       14465       14465
           2                         flop_count_sp_fma  Floating Point Operations(Single Precisi       20979       20979       20979
           2                     flop_count_sp_special  Floating Point Operations(Single Precisi       87637       87637       87637

运算吞吐量table中列出的"special"运算在Programming Guide中,它们是:reciprocal, recip sqrt, log, exp, sin, cos。请注意,这些版本不如默认版本精确(但速度更快),您必须选择使用内部或编译器标志 (-use_fast_math)。

不管文档怎么说,特殊操作似乎不包括在 flop_count_sp 总数中。这是当前版本 (8.0) 中的一个错误,我已经提交了一个错误,所以它应该在未来的版本中修复(所以这段在某些时候会过时)。