Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^3: Finding CPU stats on Win32?

by BrowserUk (Patriarch)
on Apr 15, 2005 at 22:33 UTC ( [id://448366]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Finding CPU stats on Win32?
in thread Finding CPU stats on Win32?

Detecting hyperthreading has to be done from assembler, and I'm not aware of any Win32 API that provides that information. There is an article on the Intel website that explains the intracacies.

Update: Here's an implementation in D. It should be trivial to convert to C.

import std.stream; import std.stdio; void main ( ) { int ht_supported = 0; int cores_per_socket = 1; asm{ mov EAX, 0; cpuid; test EAX, 0x10000000; jz NO_HYPER; mov ht_supported, 1; mov EAX, 4; cpuid; and EAX, 0xfc000000; shr EAX, 26; add EAX, 1; mov cores_per_socket, EAX; NO_HYPER:; }; if( ht_supported ) { printf( "Hyperthreading is supported and there are %d cores pe +r cpu\n", cores_per_socket ); } else { printf( "Hyperthreading is not supported on this processor\n" +); } }

Update2: I also turned up this quite comprehensive cpu features detector sample on MSDN


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
Lingua non convalesco, consenesco et abolesco.
Rule 1 has a caveat! -- Who broke the cabal?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://448366]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-25 15:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found