Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^2: Finding CPU stats on Win32?

by guice (Scribe)
on Apr 15, 2005 at 20:13 UTC ( [id://448332]=note: print w/replies, xml ) Need Help??


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

Wow nice! Now if I can only find out if there's a way to view if Hyperthreading it turned on/off or possible...

-- philip
We put the 'K' in kwality!

Replies are listed 'Best First'.
Re^3: Finding CPU stats on Win32?
by BrowserUk (Patriarch) on Apr 15, 2005 at 22:33 UTC

    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://448332]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2024-03-28 08:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found