If I have a system with let's say two Quadcore CPUs and HyperThreading enabled, how do I know how the phsyical and virtual cores are sorted? For example if I force a process to run on "CPU 0" how to know which Core this really is? I remember a complex drawing about this, but didn't find anything useful.

Update: After discussing this with a programer I'm convinced that it doesn't make sense to bind a program/thread to a specific core. In most cases it's better to let the operating system decide what core(s) to use. However it would still be interesting how the enumeration works.

  • 8
    Out of curiosity, why would you want to know what physical core it is?
    – Bobby
    Mar 24 '10 at 16:25
  • As long as the labeling is consistent doesn't seem like it would matter. Mar 24 '10 at 16:29
  • 2
    It may matter if trying to manually control affinity for some reason. A CPU intensive threaded process that shares data between threads running on two or more cores of one CPU will run faster than one using the same number of processing units spread over distinct physical CPUs, and may event perform faster than one that is actively using more cores but spread over multiple CPUs, due to cache sharing/management, CPU<->RAM bandwidth, and related issues. Trying to optimise things this way is unlikely to be best use of your time though. Mar 24 '10 at 17:25
  • The idea is to have a program/thread A which uses all available cores expect of one and another program/thread B which can run on the "last" core on it's own. If the labeling is consistent it doesn't matter how it's done, but I'm curious how it works and if this differs for example between Windows/Linux or different PCs.
    – asdrubael
    Mar 24 '10 at 19:01
  • sounds like you're looking for a way to implement LPARs outside of AIX, perhaps?
    – warren
    Apr 5 '10 at 12:12

Take a look at the hwloc project. It provides an C API to answer these kind of questions and also a tool called lstopo which generates CPU/memory topology maps. See the URL for examples.

  • Thanks this is exactly what I was looking for. Again: This is only for "scientific" purposes.
    – asdrubael
    Apr 6 '10 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.