【发布时间】:2021-10-17 18:07:41
【问题描述】:
我正在尝试测量在 C++ 程序 (FLOPS) 中执行的计算次数。我使用的是基于 Broadwell 的 CPU 而不是 GPU。我尝试了以下命令,其中包含了我找到的所有与 FP 相关的事件。
perf stat -e fp_arith_inst_retired.128b_packed_double,fp_arith_inst_retired.128b_packed_single,fp_arith_inst_retired.256b_packed_double,fp_arith_inst_retired.256b_packed_single,fp_arith_inst_retired.double,fp_arith_inst_retired.packed,fp_arith_inst_retired.scalar,fp_arith_inst_retired.scalar_double,fp_arith_inst_retired.scalar_single,fp_arith_inst_retired.single,inst_retired.x87 ./test_exe
我得到的东西如下:
Performance counter stats for './test_exe':
0 fp_arith_inst_retired.128b_packed_double (36.36%)
0 fp_arith_inst_retired.128b_packed_single (36.36%)
0 fp_arith_inst_retired.256b_packed_double (36.37%)
0 fp_arith_inst_retired.256b_packed_single (36.37%)
4,520,439,602 fp_arith_inst_retired.double (36.37%)
0 fp_arith_inst_retired.packed (36.36%)
4,501,385,966 fp_arith_inst_retired.scalar (36.36%)
4,493,140,957 fp_arith_inst_retired.scalar_double (36.37%)
0 fp_arith_inst_retired.scalar_single (36.36%)
0 fp_arith_inst_retired.single (36.36%)
82,309,806 inst_retired.x87 (36.36%)
65.861043789 seconds time elapsed
65.692904000 seconds user
0.164997000 seconds sys
问题:
- 虽然C++程序是一个大项目,但我没有使用任何SSE/AVX指令。我不熟悉 SSE/AVX 指令集。该项目只是由“普通” C++编写的。为什么它包含许多
fp_arith_inst_retired.double、fp_arith_inst_retired.scalar和fp_arith_inst_retired.scalar_double?这些计数器与 SSE/AVX 计算有关,对吧? - 括号中的百分比是什么意思?比如(36.37%)
- 如何根据
perf结果计算 C++ 程序中的 FLOPS?
谢谢。
【问题讨论】:
标签: c++ linux profiling perf flops