Number of threads, puzzle

Well it’s not just the “Julia threads” that get started. There’s also (at least) a signal thread (see signals-unix.c) as well as multiple OpenBLAS threads (libopenblas64_.so).

I’d suggest to do the following. First, use the built-in Threads.nthreads() to see that the number of Julia threads matches your expectation. Second, set OPENBLAS_NUM_THREADS=1 and rerun your original experiment to exclude the effect of OpenBLAS threads. Third, you may want something like done here and use gdb with a breakpoint at pthread_create to see which threads get started on a more fundamental level. Hope that helps.

UPDATE:

I just ran a simple experiment myself (with OPENBLAS_NUM_THREADS=1). I find

julia -t 1 # 2 threads
julia -t 2 # 3 threads
julia -t 3 # 4 threads
...

where I checked the number of threads with htop.

1 Like