Cores vs Threads: How many threads should I run on this machine?

How many threads should I run on this machine?

My lscpu says there are 96 cores. Are those physical cores? What is the maximum and optimal thread that I can run on this machine?

https://stackoverflow.com/a/10670440/610569 show that I can run over 20 threads per core. Is that okay? Is that optimal?

alvas@server:~$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                96
On-line CPU(s) list:   0-95
Thread(s) per core:    2
Core(s) per socket:    12
Socket(s):             4
NUMA node(s):          4
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 62
Model name:            Intel(R) Xeon(R) CPU E5-4657L v2 @ 2.40GHz
Stepping:              4
CPU MHz:               2700.000
CPU max MHz:           2900.0000
CPU min MHz:           1200.0000
BogoMIPS:              4801.91
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              30720K
NUMA node0 CPU(s):     0,4,8,12,16,20,24,28,32,36,40,44,48,52,56,60,64,68,72,76,80,84,88,92
NUMA node1 CPU(s):     1,5,9,13,17,21,25,29,33,37,41,45,49,53,57,61,65,69,73,77,81,85,89,93
NUMA node2 CPU(s):     2,6,10,14,18,22,26,30,34,38,42,46,50,54,58,62,66,70,74,78,82,86,90,94
NUMA node3 CPU(s):     3,7,11,15,19,23,27,31,35,39,43,47,51,55,59,63,67,71,75,79,83,87,91,95

Pardon my noobiness in cores/threads.


Solution 1:

This is what you want to know

Thread(s) per core:    2
Core(s) per socket:    12
Socket(s):             4

You have 4 CPU sockets, each CPU can have, up to, 12 cores and each core can have two threads.

Your max thread count is, 4 CPU x 12 cores x 2 threads per core, so 12 x 4 x 2 is 96. Therefore the max thread count is 96 and max core count is 48.

What is better ?

That depends on what you want to do, more threads means less frequency (ie a 3ghz becomes split in two) but better multi-tasking (more threads) and using full cores (no hyper-threading) is better for high CPU usage tasks (ie games).

Hope this helps you.

Solution 2:

Your machine:

4 Sockets x 12 Cores/socket x 2 Threads/core, that's 96 threads and 48 cores

Ideally, no I/O, synchronization, etc., and there's nothing else running, use 48 threads of task.

Realistically, use about 95 threads may be better to exploit the max of your machine.

Because:

a core waits for data or I/O sometimes, so thread 2 could run while thread 1 not running.

Finally, you should test to get the best number based on your specific tasks.

Solution 3:

Each cpu core thread ( hardware-based thread ) - one of your 96 cores efficiently can handle 16 threads ( software-based thread f.e. C++ thread.h ) in most cases in my theoretical opinion.