Skip to content

Commit 6a0ecfa

Browse files
committed
Replace use of nthreads() in tests
1 parent e5a038e commit 6a0ecfa

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

test/compiler.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ module Issue537 end
606606
@model demo() = return __varinfo__
607607
retval, svi = DynamicPPL.init!!(demo(), SimpleVarInfo())
608608
@test svi == SimpleVarInfo()
609-
if Threads.nthreads() > 1
609+
if DynamicPPL.USE_THREADSAFE_EVAL[]
610610
@test retval isa DynamicPPL.ThreadSafeVarInfo{<:SimpleVarInfo}
611611
@test retval.varinfo == svi
612612
else

test/fasteval.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ end
9696
end
9797

9898
@testset "FastLDF: performance" begin
99-
if Threads.nthreads() == 1
99+
if !(DynamicPPL.USE_THREADSAFE_EVAL[])
100100
# Evaluating these three models should not lead to any allocations (but only when
101101
# not using TSVI).
102102
@model function f()

test/threadsafe.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464

6565
@testset "model" begin
6666
println("Peforming threading tests with $(Threads.nthreads()) threads")
67+
@show DynamicPPL.USE_THREADSAFE_EVAL[]
6768

6869
x = rand(10_000)
6970

@@ -79,10 +80,10 @@
7980
vi = VarInfo()
8081
model(vi)
8182
lp_w_threads = getlogjoint(vi)
82-
if Threads.nthreads() == 1
83-
@test vi_ isa VarInfo
84-
else
83+
if DynamicPPL.USE_THREADSAFE_EVAL[]
8584
@test vi_ isa DynamicPPL.ThreadSafeVarInfo
85+
else
86+
@test vi_ isa VarInfo
8687
end
8788

8889
println("With `@threads`:")
@@ -112,10 +113,10 @@
112113
vi = VarInfo()
113114
model(vi)
114115
lp_wo_threads = getlogjoint(vi)
115-
if Threads.nthreads() == 1
116-
@test vi_ isa VarInfo
117-
else
116+
if DynamicPPL.USE_THREADSAFE_EVAL[]
118117
@test vi_ isa DynamicPPL.ThreadSafeVarInfo
118+
else
119+
@test vi_ isa VarInfo
119120
end
120121

121122
println("Without `@threads`:")

0 commit comments

Comments
 (0)