简体   繁体   English

为什么perf显示的浮点事件少于预期的?

[英]Why does perf show less floating point events than expected?

I'm writing a C program that does a 50x50 matrix multiplication. 我正在编写一个执行50x50矩阵乘法的C程序。

I compiled it to assembly and I see it has at least 2 floating point instructions (mulsd and addsd) in the most inner loop. 我将其编译为汇编,并且看到它在最内部的循环中至少有2个浮点指令(mulsd和addd)。 The loop is executed 125000 times, so I was expecting perf stat to give me at least 250000 floating point operations counted. 该循环执行了125000次,因此我期望perf stat至少可以计数250000个浮点运算。

However when I run the following command, 但是,当我运行以下命令时,

perf stat -e r530110 -e r531010 -e r532010 -e r534010 -e r538010 ./matmul

I only get the following counts 我只得到以下数

           448 r530110                                                     
             0 r531010                                                     
             0 r532010                                                     
             0 r534010                                                     
 <not counted> r538010                 

   0.001082287 seconds time elapsed

My compiler does not produce SSE instructions so the other zero counts are expected. 我的编译器不生成SSE指令,因此期望其他零计数。 However, I only got 448 floating point operations. 但是,我只有448个浮点运算。

What is happening? 怎么了?

I've figured it out. 我知道了。 I misunderstood: mulsd and addsd are actually SSE instructions. 我误会了: mulsdaddsd实际上是SSE指令。

The stat r530110 (FP_COMPS_OPS_EXE:X87) does not count mulsd or addsd . stat r530110 (FP_COMPS_OPS_EXE:X87)不计入mulsdaddsd

I needed to look at r538010 (FP_COMPS_OPS:SSE_SCALAR_DOUBLE). 我需要查看r538010 (FP_COMPS_OPS:SSE_SCALAR_DOUBLE)。

My guess for the reason those were <not counted> in my program was because the program finished too quickly. 我之所以认为这些在我的程序中<not counted>是因为该程序完成得太快。 When I increased the size of the matrix (so the program runs longer), the floating point event count came out correct. 当我增加矩阵的大小(以便程序运行更长的时间)时,浮点事件计数正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM