5

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.

5
  • 8
    Out of curiosity, why would you want to know what physical core it is?
    – Bobby
    Commented Mar 24, 2010 at 16:25
  • As long as the labeling is consistent doesn't seem like it would matter. Commented Mar 24, 2010 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. Commented Mar 24, 2010 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
    Commented Mar 24, 2010 at 19:01
  • sounds like you're looking for a way to implement LPARs outside of AIX, perhaps?
    – warren
    Commented Apr 5, 2010 at 12:12

1 Answer 1

2

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.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .