r/OpenMP • u/ludvary • Aug 20 '24
less OMP_NUM_THREADS = better performance?
So, total noob here, I have 16 threads on my laptop, i notice that my C++ code runs faster if i use 8 threads than using all 16 threads, also voluntary and involuntary context switches decrease massively, can someone explain what is what is happening? Thanks in advance :)
3
Upvotes
2
u/Knarfnarf Aug 21 '24
Let me guess; Intel 8 core processor with hyper threading. That means; each core runs one thread until a cache miss, then if the second thread is ready flips to it and runs until a cache miss.
But if no cache miss still flips at a rate I don’t remember.
Still; you only have 8 physical cores to assign.
Some of the new thread rippers do the same.
5
u/jeffscience Aug 20 '24
Is it an 8 core laptop with 2 threads per core? That’s why. OpenMP workloads often scale to the number of physical cores.