File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 366366 @test jl_setaffinity (0 , mask, cpumasksize) == 0
367367 end
368368end
369+
370+ # Make sure default number of BLAS threads respects CPU affinity: issue #55572
371+ @testset " LinearAlgebra number of default threads" begin
372+ if AFFINITY_SUPPORTED
373+ allowed_cpus = findall (uv_thread_getaffinity ())
374+ cmd = addenv (` $(Base. julia_cmd ()) --startup-file=no -E 'using LinearAlgebra; BLAS.get_num_threads()'` ,
375+ # Remove all variables which could affect the default number of threads
376+ " OPENBLAS_NUM_THREADS" => nothing ,
377+ " GOTO_NUM_THREADS" => nothing ,
378+ " OMP_NUM_THREADS" => nothing )
379+ function test_num_threads (n)
380+ expected_num_threads = @static Sys. isapple () && Base. BinaryPlatforms. arch (Base. BinaryPlatforms. HostPlatform ()) == " aarch64" ? string (max (1 , n)) : string (max (1 , n ÷ 2 ))
381+ @test readchomp (setcpuaffinity (cmd, allowed_cpus[1 : n])) == " 1"
382+ end
383+ for n in 1 : length (allowed_cpus)
384+ test_num_threads (n)
385+ end
386+ end
387+ end
You can’t perform that action at this time.
0 commit comments