map CPU ID to threads to cores to sockets with hyperthreading

The Linux OS uses a predictable method to map hyperthread enabled CPU threads to CPU IDs. Here’s a reminder if you need a quick way to map them:

# egrep 'processor|core id|physical id' /proc/cpuinfo | cut -d : -f 2 | paste - - -  | awk '{print "CPU"$1"\tsocket "$2" core "$3}'
CPU0    socket 0 core 0
CPU1    socket 0 core 1
CPU2    socket 0 core 2
CPU3    socket 0 core 3
CPU4    socket 1 core 0
CPU5    socket 1 core 1
CPU6    socket 1 core 2
CPU7    socket 1 core 3
CPU8    socket 0 core 0
CPU9    socket 0 core 1
CPU10   socket 0 core 2
CPU11   socket 0 core 3
CPU12   socket 1 core 0
CPU13   socket 1 core 1
CPU14   socket 1 core 2
CPU15   socket 1 core 3

This is a dual quad core system with hyperthreading enabled. 2 physical CPUs with 4 cores each and 2 threads per core so the OS sees 16 CPUs. CPU0 and CPU8 are 2 threads on the first core (core 0 ) on the first physical processor (socket 0)

share:

Leave a Reply

Your email address will not be published. Required fields are marked *