Archived

This topic is now archived and is closed to further replies.

CPUID

This topic is 5133 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Intel recommends using CPUID when using RDTSC for timing small sections and getting average times over large sections of code on Pentium and Pentium II processors to force the previous instructions to complete for an accurate timer. For the later versions of Pentium Processors and the Athlon''s etc they say you don''t need to use it anymore as it doesn''t matter when forcing the previous commands to complete before calling RDTSC. My question is "does any one know why?". What I am trying to get at is does the RDTSC function on the newer processors force the previous instructions to complete by itself now instead of having to call the cpu identification instruction. That''s what I am assuming but if anyone knows for sure I would appreciate it. I don''t NEED to know why, but I''m curious as to why.
Beer - the love catalyst good ol'' homepage

Share this post


Link to post
Share on other sites
Starting with the Pentium you had multiple pipelines (the Pentium 1 had a U and V pipeline). When conditions where meant this allowed it to actually process two instructions in one cycle, completely parallel to each other (a superscalar CPU). The catch here is that this means a RDTSC instruction, which doesn''t affect many other things, has a good chance of actually executing at the same time (or with certain combinations in the pipeline on certain Pentium models when doing scheduling, before) the previous instruction. For instance you could place timing operations around a single instruction, and in some cases actually measure 0 cycles to complete it.

I assume the fact that this could happen was an oversight, and was corrected on later CPUs. The CPUID instruction is just a work around, since it forces completion of the previous instruction.

Share this post


Link to post
Share on other sites
quote:
I assume the fact that this could happen was an oversight, and was corrected on later CPUs. The CPUID instruction is just a work around, since it forces completion of the previous instruction.


Thank you! Makes alot of sense now. From the documentation I knew that the CPUID was a work around of some sort (and took a bit of time to, its around 30 clock cycles or so unfortunatly) but I never realised (or thought of) that thing about the RTDSC running in only the U pipe.

Thanks again!

Share this post


Link to post
Share on other sites