Physical CPU and Logical CPU

To understand the difference between Physical and Logical CPU (core), you need to run the command lscpu on your Linux machine and you will get a result like this:

lscpu command
Figure 01: Result of lscpu command

Now, we will focus only on some important attributes, the rest are not so much important with respect to this topic, so I will park them as of now. We will start with

Important Terms:

  1. Socket (s): The number of the physical socket to which the CPU belongs. In the above example, there is only one socket connected to one processor. A processor contains core/threads etc. within it.
  2. Core (s) per socket: This number represents the count of the physical core (CPU) to which the hardware thread (logical CPU) belongs. In the above example, there are 4 cores under 1 processor.
  3. Thread (s) per core: This number represents the Logical CPU count under each Core. Each thread under a core is worked as a Logical CPU. These threads are also called Hardware threads. Hardware Thread supports executing multiple threads simultaneously on each core and every thread runs as an independent CPU instance. In the above example, each core has two threads.
  4. CPU (s): The total number of Logical CPUs available on the board. In the above example, the number of Logical CPUs is 8.
  5. NUMA node (s): Non-uniform memory access node. There is only 1 NUMA node.

Since each core has 2 threads, so this architecture represents 4 Physical cores (CPUs) and 8 Logical cores (CPUs). Refer to the following pictorial view to get a better understanding:

CPU Processor
Figure 02: Processor

Here, we can say 1P4C with 2 threads on each core so the summary is 1 Processor (1P) is connected to 1 Socket. That Processor has 4 Physical Cores (4C) with 2 Threads (Logical Cores) on each physical core. Hence total of 8 Logical cores.

Now, let’s run lscpu -e command, the output will be like this:

lscpu -e command
Figure 03: Result of lscpu -e command

We have already discussed the terms CPU, Node, Socket and Core. There are some more terms which do have some significance like:

  1. L1d: Data cache associated with the CPU.
  2. L1i: Instruction cache associated with the CPU
  3. L2: Cache associated with CPU
  4. L3: Cache associated with CPU

The output of lscpu command shows the size of the cache while lscpu -e command shows the number of caches associated with each Thread (Logical CPU). Refer to the following pictorial view to get a better understanding:

CPU Processor - Physical CPU vs Logical CPU
Figure 04: Processor

Now, try on your machine to do some practice.


You may be interested: