What is the correct way to set MKL threads at runtime? Documentation seems to be misleading, it says to use BLAS.set_num_threads(1) to be single threaded, but it does not work. The only way I have found to actually make it work is calling julia with MKL_NUM_THREADS=1, is there no way to set it at runtime then?
small code used to run
using MKL
using LinearAlgebra
BLAS.set_num_threads(1)
A = rand(5000, 5000)
A .+= A'
eigen(A)
I thought this worked, but you’re right. As explained in the github issue you’ve also commented on, Setting MKL thread number · Issue #174 · JuliaLinearAlgebra/MKL.jl · GitHub, when using MKL, BLAS.set_num_threads(n) only affects the number of threads used for BLAS functions like A * B, not LAPACK functions like eigen. I don’t think this is the intended semantics, so hopefully someone will follow up on the github issue.