Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Clock cycles per instruction?

  1. Sep 4, 2007 #1


    User Avatar
    Science Advisor
    Homework Helper

    As a first step to optimizing code, I like to think about faster ways to do things. Algorithmic improvements are far better than minute improvements to code, or even use of inline assembly, in general. But most optimizations beyond common subroutine elimination and its ilk substitute inexpensive operations for expensive ones, rather than eliminating chunks entirely. Now when two solutions present themselves I can just code up both and time them, but for the purpose of planning early on into the coding it's good to have an idea of what costs more. For example, addition and negation are cheap while square roots and other transcendentals are expensive.

    Toward that end, is there a decent list of approximate costs for operations (on some common x86 chip, perhaps a Pentium IV or Core II Duo or Athlon 64)? I'm looking for some kind of chart with figures like "division: 28 cycles (max throughput 5 cycles)". Since I'm just looking for general ballparks, I'm not too sensitive about the particular chip it applies to -- although general notes about what ops chips are good with would be great as well.
  2. jcsd
  3. Sep 4, 2007 #2


    User Avatar

    Staff: Mentor

    This is not exactly what you are looking for, but it's pretty amazing. I checked wikipedia.org for computer benchmark info, and got a big page with lots of info and outside references:


    I know you want to compare different algorithms on the same processor, and that is different than benchmarking different processors against the same algorithm, but maybe poke around some of the links to see if you can find what you want, or see other terms to search on. Pretty interesting links that I followed....
  4. Sep 4, 2007 #3


    User Avatar
    Science Advisor
    Homework Helper

    For older processors this was fairly easy.
    Look up the instruction in the programmer's reference manual.
    Pick the cycle count for the addresing mode being used.

    For the proceesors you list this gets very complex with prefetch and what not.

    This should be the page you want for Intel processors.

    http://www.intel.com/products/processor/manuals/index.htm [Broken]

    and at least some cycle counting info appears here


    You will have to search for other manufactures
    Last edited by a moderator: May 3, 2017
  5. Sep 5, 2007 #4


    User Avatar
    Science Advisor
    Homework Helper

    Thanks, that looks like it just might serve.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook