Search code examples
multithreadingcpu-cores

Using more software threads than CPUs = oversubscribing?


The output of lscpu gives (partial output included):

CPU(s):                12
On-line CPU(s) list:   0-11
Thread(s) per core:    1
Core(s) per socket:    6
Socket(s):             2
NUMA node(s):          2

I just want to confirm that my understanding is correct:

(1) I have 12 CPU(s)/cores. This number is also the number of HARDWARE threads that I have.

(2) If (1) is true, and, say, I run a code that uses more than 12 SOFTWARE threads, this would lead to oversubscription. Say that I use 13 software threads, would that mean that guarantee that 1 of my software threads cannot run concurrently with the other 12?


Solution

  • I think there is some terminology confusion. I presume that you meant parallelism because concurrency is not a parallelism (it's a broader conception) which implies multitasking where a system can execute multiple tasks at the same time. This can be achieved by pure parallelism, preemptive multitasking or cooperative multitasking but they all are just forms of concurrency. Logically a multi-threading execution can be represented as a single-threaded sequence of fine grained activities with arbitrary order, which still imposes the concurrency problems regardless of fact that we execute all of our tasks on a single core or in a single thread. So all 13 threads or more on your system with 12 hardware threads will run concurrently but only 12 will run in parallel.

    As a side note, hardware threads or logical CPUs aren't logical software threads but number of execution flows a CPU core can do simultaneously by means of Hyper-Threading so they also provide parallelism but with some limitations (in your case however each core has single logical CPU, so no hyper-threading).