Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated Threads.nthreads() #204

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/solvers/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 8 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down