TaskManager, HyperThreading: Which CPUs are real and which are HT?

7,118

Intel originally wanted BIOS implementers to enumerate all physical CPUs first before logical (HT) CPUs. The reason for this was that if an operating system supported fewer CPUs than were available in the system, it would see the physical cores first before seeing the logical cores. This isn't an issue nowadays, but back when it was possible to buy a dual-core Pentium 4 w/ HT, put it into a Windows 2000 Pro system, and only see 2 CPUs no matter what, it was a real concern. I doubt that the implementation would deviate from that. So in your case it's most likely that CPUs 0-3 are the physical cores and CPUs 4-7 are the HT cores.

If you're having problems with your own multi-threaded software not balancing well because of HT, then you'll probably want to limit your thread count to the physical cores only, or work on your algorithms/data structures to be more HT-friendly. GetLogicalProcessorInformation is the API call you need to look at to determine physical vs. logical core count. This page has sample code for determining the # of Physical CPUs.

Making your code more HT-friendly is, well, a whole different ball of wax and not really suited for SuperUser. :-)

Share:
7,118

Related videos on Youtube

Michael Stum
Author by

Michael Stum

The same thing we do every night, Pinky. Try to take over the world! Full-Stack Developer on Stack Overflow Enterprise, working to make our little corner of the Internet better for all of us.

Updated on September 17, 2022

Comments

  • Michael Stum
    Michael Stum over 1 year

    When I open Task Manager I see 8 CPUs in the CPU Graph, since I have a Core i7 with 4 Cores + HyperThreading (running on Win7 x64).

    When I set Process affinity I get CPU 0 to CPU 7 listed.

    How can I know which CPUs are real cores and which are HT Cores?

    I heard that 0/2/4/6 are the real cores and thus the first, third, fifth and seventh CPU graph are the real ones.

    Is that true?

  • Michael Stum
    Michael Stum over 13 years
    Indeed, for the most part it should be transparent and handled by the Windows Scheduler. However, if a 2-Thread Application is running on a Core and it's HT Core, then that can be a problem. Especially when setting affinity manually. SQL Server is one application that can have some quirks with HT, but I'm having some others (mainly some that I wrote myself :/) that don't balance well.
  • user3660103
    user3660103 over 13 years
    @Michael Stum I've been thinking about this and I remember that there was a game called Aquanox 2 back in the days when HT was new. It had option to enable or disable HT support. I wonder how they managed to do that...
  • afrazier
    afrazier over 13 years
    It looks like SIV can show you how Windows enumerates your CPUs. See this screenshot for an example.