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:
Now, we will focus only on some important attributes, rest are not so much important with respect to this topic, so I will park them as of now. We will start with
- Socket (s): The number of the physical socket to which the CPU belongs. In the above example, there is only one socket connects to one processor. A processor contains core/threads etc. within it.
- 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.
- Thread (s) per core: This number represents the Logical CPU count under each Core. Each thread under a core is worked as Logical CPU. These threads are also called as Hardware Thread. 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 having two threads.
- CPU (s): The total number of Logical CPUs available on the board. In above example, the number of Logical CPUs is 8.
- 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 the following pictorial view to get a better understanding:
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 having 4 Physical Cores (4C) with 2 Threads (Logical Cores) on each Physical core. Hence total 8 Logical cores.
Now, let’s run lscpu -e command, the output will be like this:
We have already discussed the term CPU, Node, Socket and Core. There are some more terms which do have some significance like:
- L1d: Data cache associated with the CPU.
- L1i: Instruction cache associated with the CPU
- L2: Cache associated with CPU
- 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 the following pictorial view to get a better understanding:
Now, try at your machine to do some practice.
You may be interested: