Approximate Number of CPU Cycles for Various Operations

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 01:28:08
ant grobbelar

I did a small app to test this. A very approximate app using synthmaker free edition... e is for empty, numbers are very approx cycles

  divide|e:115|10
    mult|e: 48|10
     add|e: 48|10
    subs|e: 50|10
compare>|e: 50|10
     sin|e:135:10

The readings in the cycle analyser vary wildly from 50 to 100, usually single or double of the expected amount, these are figures that represent averages,the cycle analyzer is a very rough tool, but it gives fair results, a workaround user made exponent coded in ASM that calculates both the exp and the base at audio rate for example is around 800 cycles, so I'd say the above figures are close to at least 50 percent. I thought the divide was way more! It seems about twice as much. If you want the file I made to run in SM free version mail me, I was going to save an exe that is why i did it but you cant save in free version silly me! I am not going to code it from square one in version 1.17 :/ ant.stewart at the place yahoo dotty com.

nos

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

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.

This is going to be hardware-dependent. The best thing to do is to run some benchmarks on the particular hardware you want to test.

A benchmark would go roughly like this:

  • Run a primitive operation a million times (say, adding two integers)
  • Record the time it took to run (say, in seconds)
  • Multiply by the number of cycles your machine executes per second - this will give you the total number of cycles spent.
  • Divide 1000000 by the number from the previous step - this will give you the number of instructions per cycle. Keep in mind that with pipelining, this could be less than 1.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!