File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 359359 @test jl_setaffinity (0 , mask, cpumasksize) == 0
360360 end
361361end
362+
363+ # Make sure default number of BLAS threads respects CPU affinity: issue #55572.
364+ # Note: we're doing this only on Linux.
365+ @testset " LinearAlgebra number of default threads" begin
366+ if AFFINITY_SUPPORTED
367+ allowed_cpus = findall (uv_thread_getaffinity ())
368+ cmd = addenv (` $(Base. julia_cmd ()) --startup-file=no -E 'using LinearAlgebra; BLAS.get_num_threads()'` ,
369+ # Remove all variables which could affect the default number of threads
370+ " OPENBLAS_NUM_THREADS" => nothing ,
371+ " GOTO_NUM_THREADS" => nothing ,
372+ " OMP_NUM_THREADS" => nothing )
373+ for n in 1 : min (length (allowed_cpus), 8 ) # Cap to 8 to avoid too many tests on large systems
374+ @test readchomp (setcpuaffinity (cmd, allowed_cpus[1 : n])) == string (max (1 , n ÷ 2 ))
375+ end
376+ end
377+ end
You can’t perform that action at this time.
0 commit comments