Does Julia detect the maximum number of threads availible and if so how?

I don’t know how to check if hyperthreading is disabled but here’s the results

dave@deepthought:~$ julia -t auto
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.3 (2021-09-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using Hwloc

julia> num_physical_cores()
36

julia> num_virtual_cores()
36

julia> Threads.nthreads()
36

julia> 

hyperthreading IS disabled GREAT SPOT!!! I’ll get that sorted out next reboot!

dave@deepthought:~$ lscpu
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   46 bits physical, 48 bits virtual
CPU(s):                          36
On-line CPU(s) list:             0-35
Thread(s) per core:              1
Core(s) per socket:              18
Socket(s):                       2
NUMA node(s):                    2

Well, as you can see, the system reports only 36 available threads. Hence, the reason why you get 36 for julia -t auto isn’t related to Julia at all but lies deeper. Again, my simple guess would be that hyperthreading is disabled (which would give you precisely the output that you see). Don’t know how to check that from the top of my head but should be easy to find out. You should be able to activate this in the BIOS I guess.

3 Likes

OUTSTANDING WORK!
thanks so much for clearing this up.

Here’s how I found out how to check hyperthreading

how to check intel hyperthreading

Maybe as a final comment, I’m not a fan of hyperthreading so I wouldn’t mind if it was turned off :slight_smile:

(In fact, on some of our clusters it is indeed turned off as more often than not it is not what users want, whether they know it or not :slight_smile: )

thanks for your help @carstenbauer My use case would benefit from threads as I intend to implement a group of finite state machines. I’m HOPING that Julia is thread safe, I’ll soon find out :slight_smile:

Hi @DNF, my understanding was that it is one thread per logical core. Just checked and it looks so. Pls see below. Also it seems that the same situation is in case of @theakson setup.

~$ julia -t auto
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.0-rc2 (2021-10-20)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> Threads.nthreads()
128

shell> lscpu
Architecture:                   x86_64
CPU op-mode(s):           32-bit, 64-bit
Byte Order:                     Little Endian
Address sizes:                52 bits physical, 57 bits virtual
CPU(s):                          128
On-line CPU(s) list:        0-127
Thread(s) per core:        2
Core(s) per socket:        32
Socket(s):                       2 
NUMA node(s):              2
Vendor ID:                      GenuineIntel
CPU family:                    6
Model:                           106
Model name:                 Intel(R) Xeon(R) Platinum 8358 CPU @ 2.60GHz

Is there maybe any general rule of thumb? My current assumption is that if there is more intense computation (like computations with higher memory consumption) it is better to use HT and it should bring better results even then JULIA_EXCLUSIVE=1 julia -t (n of physical cores). However, I have not done any extensive testing on this topic.

Yes, I see that too, now. I was so certain, I even remember reading why this was so. And my memory completely played a trick on me…

Yeah, thanks for pointing out to this. I have to admit that I always was starting Julia specifying desired number of threads. So it was a new experiment for me even though my understanding was that Julia auto policy is to set number of threads as equal to number of logical cores (if present), the same with OpenBlas for Julia v. 1.8.