CPU ordering in Linux (with hyper threading)
Asked Answered
C

3

14

I'm curious what the CPU ordering is in Linux. Say I bind a thread to cpu0 and another to cpu1 on a hyperthreaded system, are they both going to be on the same physical core. Given a Core i7 920 with 4 cores and hyperthreading, the output of /proc/cpuinfo has me thinking that cpu0 and cpu1 are different physical cores, and cpu0 and cpu4 are on the same physical core.

Thanks.

Ciaphus answered 10/6, 2010 at 22:55 Comment(0)
I
22

The physical cpu/socket is listed as physical id.
The physical core is listed as core id.
A processor entry due to hypherthreading will get its own processor, but share core id and physical id with another.

Note that each physical cpu (physical id) can have multiple cores (core id), which can further be broken up into additional logical cpus by hyperthreading. The logical cpus are overall ordered by processor id.

There's a detailed explanation with examples here: archive.richweb.com/cpu_info via web.archive.org

Intelligence answered 10/6, 2010 at 23:31 Comment(2)
That's incorrect. 'Physical id' is a socket. He has a single socket computer with a quadcore i7 with hyperthreading. All of his cores should have 'physical id' 0. 'core id' refers to the physical cores, and he should have 0-3 of those. The logical cores are defined as 'processor' and should be numbered 0-7. ... On my system, processors 0 and 4 share the same core id, processors 1 and 5 share the same core id, etc. Just make sure you don't bind two processes to the same 'core id' unless you really want to. So processor 0 and 4 are logical cpus (hyperthreading) on the same core.Nonetheless
You can use egrep "(( id|processo).*:|^ *$)" /proc/cpuinfo to get only the relevant information from /proc/cpuinfoCondolent
J
2

You can use likwid-topology -g to get graphical topology of the cpu. It shows each cpu primary cores along with the sibling core.

Joanjoana answered 30/3, 2017 at 1:18 Comment(0)
W
-1

See the pointer provided in this link. The information is all in /proc/cpuinfo with regards to physical processors, cores, and hyperthreading, but you have to match info from multiple entries in that file to identify which ones group together.

Warring answered 28/1, 2011 at 22:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.