各种操作的大概CPU周期数 [英] Approximate Number of CPU Cycles for Various Operations

查看:369
本文介绍了各种操作的大概CPU周期数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试查找各种​​操作大约需要多少个CPU周期的参考.

I am trying to find a reference for approximately how many CPU cycles various operations require.

我不需要确切的数字(因为这在CPU之间会有所不同),但是我想要一些相对可信的东西,它可以提供与朋友讨论时可以引用的大致数字.

I don't need exact numbers (as this is going to vary between CPUs) but I'd like something relatively credible that gives ballpark figures that I could cite in discussion with friends.

作为一个例子,我们都知道浮点除法比进行位移位要花费更多的CPU周期.

As an example, we all know that floating point division takes more CPU cycles than say doing a bitshift.

我猜想区别是除法大约是100个周期,其中1个班次为1个周期,但我正在寻找可以援引该结论的东西.

I'd guess that the difference is that the division is around 100 cycles, where as a shift is 1 but I'm looking for something to cite to back that up.

任何人都可以推荐这样的资源吗?

Can anyone recommend such a resource?

推荐答案

对于x86处理器,请参见英特尔®64和IA-32体系结构优化参考手册,可能是附录C.

For x86 processors, see Intel® 64 and IA-32 Architectures Optimization Reference Manual, probably Appendix C.

但是,要弄清一条指令在现代x86处理器上执行需要花费多少个周期,绝非易事,因为它在很大程度上取决于例如.访问缓存中的数据,对齐访问,分支预测是否失败,指令流水线是否停滞以及很多其他事情.

However, it's not in any way easy to figure out how many cycles an instruction takes to execute on a modern x86 processor, as it depends too much on e.g. accessing data in cache,aligned access, whether branch prediction fails, if there's a stall in the instruction pipeline and quite a lot of other things.

这篇关于各种操作的大概CPU周期数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆