From 81786cda0aa94f346d60f54edab7582e85e6b99e Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 3 Aug 2022 14:42:24 -0400 Subject: [PATCH] fix deprecated Threads.threads() --- src/solvers/cholmod.jl | 6 +++++- test/runtests.jl | 10 ++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/solvers/cholmod.jl b/src/solvers/cholmod.jl index 64a4c2a7..5c860981 100644 --- a/src/solvers/cholmod.jl +++ b/src/solvers/cholmod.jl @@ -221,7 +221,11 @@ function __init__() ### Initiate CHOLMOD ### common controls the type of factorization and keeps pointers ### to temporary memory. We need to manage a copy for each thread. - nt = Threads.nthreads() + nt = @static if isdefined(Threads, :maxthreadid) + Threads.maxthreadid() + else + Threads.nthreads() + end resize!(COMMONS, nt) errorhandler = @cfunction(error_handler, Cvoid, (Cint, Cstring, Cint, Cstring)) for i in 1:nt diff --git a/test/runtests.jl b/test/runtests.jl index 081ac155..ae14fbeb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -7,14 +7,20 @@ end if Base.USE_GPL_LIBS + nt = @static if isdefined(Threads, :maxthreadid) + Threads.maxthreadid() + else + Threads.nthreads() + end + # Test multithreaded execution @testset "threaded SuiteSparse tests" verbose = true begin - @testset "threads = $(Threads.nthreads())" begin + @testset "threads = $(nt)" begin include("threads.jl") end # test both nthreads==1 and nthreads>1. spawn a process to test whichever # case we are not running currently. - other_nthreads = Threads.nthreads() == 1 ? 4 : 1 + other_nthreads = nt == 1 ? 4 : 1 @testset "threads = $other_nthreads" begin let p, cmd = `$(Base.julia_cmd()) --depwarn=error --startup-file=no threads.jl` p = run(