4

I have this info from /proc/cpuinfo (shown below). My question is which core is hyperthreaded here. Secondly, which core lies on which processor, as there are two quad core processors here, as it is a dual socket system with 8 cores in total.

I interpret this as, core 0, 2, 4 and 6 are the 4 physical cores in processor 1, while core 1, 3, 5 and 7 are the 4 physical cores on processor 0. Cores 9-15 are the hyperthreaded ones. Is my interpretation correct?

-bash-3.2$ cat /proc/cpuinfo | grep 'physical id'
physical id     : 1
physical id     : 0
physical id     : 1
physical id     : 0
physical id     : 1
physical id     : 0
physical id     : 1
physical id     : 0
physical id     : 1
physical id     : 0
physical id     : 1
physical id     : 0
physical id     : 1
physical id     : 0
physical id     : 1
physical id     : 0
-bash-3.2$ cat /proc/cpuinfo | grep 'core id'
core id         : 0
core id         : 0
core id         : 1
core id         : 1
core id         : 2
core id         : 2
core id         : 3
core id         : 3
core id         : 0
core id         : 0
core id         : 1
core id         : 1
core id         : 2
core id         : 2
core id         : 3
core id         : 3
-bash-3.2$ cat /proc/cpuinfo | grep 'processor'
processor       : 0
processor       : 1
processor       : 2
processor       : 3
processor       : 4
processor       : 5
processor       : 6
processor       : 7
processor       : 8
processor       : 9
processor       : 10
processor       : 11
processor       : 12
processor       : 13
processor       : 14
processor       : 15
3
  • 5
    Asking which core is hyperthreaded is like asking which of two brothers born at the same time is the twin. All CPUs on the same core are equal.
    – Gabe
    Sep 3, 2011 at 7:50
  • Gabe, I concur with you. Sep 3, 2011 at 8:29
  • Gabe, the only possible question here: what pairs of virtual processors share the physical core and physical die (socket).
    – osgx
    Sep 4, 2011 at 10:59

4 Answers 4

3

Can you post dmesg results from boot? They should contain description of coreids:

http://lxr.linux.no/linux+v3.0.4/arch/x86/kernel/cpu/common.c#L493

 493        if (!printed && (c->x86_max_cores * smp_num_siblings) > 1) {
 494                printk(KERN_INFO  "CPU: Physical Processor ID: %d\n",
 495                       c->phys_proc_id);
 496                printk(KERN_INFO  "CPU: Processor Core ID: %d\n",
 497                       c->cpu_core_id

Another variant is to use hwloc: http://www.open-mpi.org/projects/hwloc/

It was created to dig out topology of any system. Example of normal system:

Example of topology in graphic form

And it will represent HT-cores:

Example of HT-topology in graphic form

Output from this utility can be in text format, in xml format, rendered.

0

The best way to do it is just to benchmark it.

Write any trivial program that uses 2 threads. Then bind the threads to two cores. If the performance drops significantly between a pair of cores versus another pair, then you know those two cores are on the same physical core.

I would trust a benchmark like this over whatever anything else tells you.

In Windows, the logical/physical cores are interleaved. Cores 0,1 are on the same physical core. Cores 2,3 are on the same... Cores 4,5 are on the same... etc...

It may be different on Linux.

6
  • Yes, mystical I have also tried that and the results support my interpretation. Sep 3, 2011 at 7:45
  • Benchmarking this way is not reliable if the machine has some other unrelated load which is being run on the same cores.
    – snap
    Sep 3, 2011 at 10:50
  • MetallicPriest, you benchmark was a macro (fluidanimate) and it was different code when using different thread number. Try to use a simpler benchmark with 2 threads; no difference in code. E.g. do the barrier in a loop.
    – osgx
    Sep 4, 2011 at 11:01
  • osgx, I also tried with other benchmarks from PARSEC and yes all the results support my interpretation. In Linux CPU 0-7 are physical ones while 8-15 are hyperthreads. In Windows, its just like what u said, that is CPU 0,1 is one core. Sep 4, 2011 at 19:01
  • You should not to run a large (macro) bechmark to find HT-relations between cores. You should run microbenchmark on pair-to-pair basis.
    – osgx
    Sep 4, 2011 at 22:11
0

When you enable Hyperthreading, all processors become virtual. There are no purely physical processors. As Raymond Chen explains:

When you turn on hyperthreading, each individual physical processor acts as if it were two virtual processors. ... The two virtual processors associated with each physical processor are completely equivalent. It's not like one is physical and one is virtual. They are both virtual and compete equally for a share of the one physical CPU. When you set processor affinities, you set them to virtual processors.

1
  • We know, but naming them "physical" and "virtual" is just an easy way identify which pairs are together.
    – Mysticial
    Sep 4, 2011 at 22:40
0

To address only the question of how to interpret /proc/cpuinfo: a hyperthreaded pair can be identified by picking out "processor" entries that have the same values for cpu id and for core id.

So in the output provided in the original question, processor 0 and processor 8 are a hyperthreaded pair, as are 1 & 9, and 2 & 10, etc.

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.