speed detection

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Stefan

speed detection

Post by Stefan »

Is there an memory location where I can find the speed in MHz of the processor, or I have to calculate it?
The calculation for frequency is the same for AMD processors, as for Intel?

Thank you!
anton

RE:speed detection

Post by anton »

There is no such mem location, you should calculate it. I don't understand, what you mean by "same for AMD processors, as for Intel". It's the same for all processors.
Anton.
Stefan

RE:speed detection

Post by Stefan »

I ment if the algorithm for calculating intel cpu frequency is the same for amd, cyrix, crusoe, etc.
carbonBased

RE:speed detection

Post by carbonBased »

Yes, and as was said, it's the same for all processors.

A one MHz computer can perform 1 million operations per second, regardless of the manufacturer.

Jeff
smaffy

RE:speed detection

Post by smaffy »

...cycles per second.
one operation can take more than one cycle :P

(ghaak.. i feel odd!)
Dave68

RE:speed detection

Post by Dave68 »

and conversely, modern super-scalar processors can do multiple instructions in one clock cycle - to say that every CPU can do one instruction in one clock cycle is amazingly wrong. That been said, Intel have an application note, primarily intended for information on how to use the CPUID instruction which is supported by all pentium + CPUs and some 486 (not 386 on as someone commented) which also contains a surprisingly accurate algorithm for MHz calculation, this also works extremely well on AMD CPUs, it may well hold up for other manufacturers as well but I have not personally tried it - note incidently that this routine uses internal performance counters in the CPU and does not just count how many instructions are executed in a second which cannot possibley work - hope this helps !
Dave68

RE:speed detection

Post by Dave68 »

Sorry, forgot to mention that the ap note can be had at

http://developer.intel.com/design/xeon/ ... 161821.pdf
carbonBased

RE:speed detection - clarification...?

Post by carbonBased »

Yes, indeed... sorry 'bout that.  I made a point not to say "instruction," but ended up just using a synonym.

I would imagine, however, that timing a single clocked instruction such as nop (that's 1 cycle on all x86 cpus, right?) would afford a somewhat accurate example of clock speed.  I've never done this, however, it's more a guess than a theory.

Of course, as was mentioned, modern cpus can execute multiple instructions concurrently (and indeed, out of order, I believe).  Those CPUs, however, all support CPUID for clock speed detection (late 486s, and pentiums should support CPUID, I believe), and should probably be used.

However, my understanding of these systems is that only certain combinations of instructions can be executed concurrently (?).  If this is true, it may still be possible to time based on instruction execution... although, obviously not as reliable as CPUID.

I'm curious, though.  My old 486 was 100Mhz, but actually ran at 102Mhz.  Which would CPUID return?

Lastly, the Linux sources can an accurate Mhz detection system (arch/i386/kernel/cpuid.c, I believe).

Jeff
Post Reply