In OpenBLAS, if you call openblas_set_num_threads
asking for a number of threads which is to be higher than the number of CPU threads that you have,
then the actual number of threads it will be set to use is your number of CPU Threads.
This can be seen in the source code
I am wondering if MKL has the same behavior? The docs do not explicitly mention it. but they do say:
The number specified is a hint, and Intel® MKL may actually use a smaller number.
It seems to cap at the number of cores (not the number of threads). The code below ran on a 6-Core Intel Core i7:
julia> using MKL_jll
julia> get_max_threads() = ccall((:mkl_get_max_threads, libmkl_rt), Int32, ());
julia> set_max_threads(n) = ccall((:mkl_set_num_threads, libmkl_rt), Cvoid, (Ptr{Int32},), Ref(Int32(n)));
julia> get_max_threads()
6
julia> set_max_threads(4)
julia> get_max_threads()
4
julia> set_max_threads(8)
julia> get_max_threads() # maxed out at 6
6
julia> set_max_threads(24)
julia> get_max_threads() # maxed out at 6
6
julia> set_max_threads(1)
julia> get_max_threads()
1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With