I am running the script MWE.jl
using LinearAlgebra
display(BLAS.get_num_threads())
via SLURM command
srun --nodes=1 --ntasks-per-node=1 --cpus-per-task=6 --mem=1G julia MWE.jl
As far as I know, for SLURM the CPUs are logical, so if I set --cpus-per-task=6 I would expect that BLAS.get_num_threads() returns 6. Instead, it returns 3.
Why is that? Any help on this would be very much appreciated.
It’s on purpose that BLAS uses half of the available threads on x86_64 (to avoid potential hypethreading oversubscription), it’s also mentioned in Julia 1.12 Highlights. If you want to use a different number of OpenBLAS threads, set the env var OPENBLAS_NUM_THREADS appropriately.
I have done so via BLAS.set_num_threads and the impact on performance is terrible. Is that normal? The architecture of the computer is single-threaded. Even if it was multi-threaded, for SLURM the CPU number refers to logical CPUs, so I should always be able to set the same number of threads than logical CPUs.