Skip to content

Commit c25fd4c

Browse files
committed
Print threadid before failure
1 parent d6e9c83 commit c25fd4c

File tree

3 files changed

+58
-56
lines changed

3 files changed

+58
-56
lines changed

src/threadsafe.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@ transformation(vi::ThreadSafeVarInfo) = transformation(vi.varinfo)
2222
# Instead of updating the log probability of the underlying variables we
2323
# just update the array of log probabilities.
2424
function acclogp!!(vi::ThreadSafeVarInfo, logp)
25-
vi.logps[Threads.threadid()] += logp
25+
vi.logps[1] += logp
2626
return vi
2727
end
2828
function acclogp!!(vi::ThreadSafeVarInfoWithRef, logp)
29-
vi.logps[Threads.threadid()][] += logp
29+
vi.logps[1][] += logp
3030
return vi
3131
end
3232

test/runtests.jl

+54-54
Original file line numberDiff line numberDiff line change
@@ -54,63 +54,63 @@ include("test_util.jl")
5454
if AQUA
5555
include("Aqua.jl")
5656
end
57-
include("utils.jl")
58-
include("compiler.jl")
59-
include("varnamedvector.jl")
60-
include("varinfo.jl")
61-
include("simple_varinfo.jl")
62-
include("model.jl")
63-
include("sampler.jl")
64-
include("independence.jl")
65-
include("distribution_wrappers.jl")
66-
include("logdensityfunction.jl")
67-
include("linking.jl")
68-
include("serialization.jl")
69-
include("pointwise_logdensities.jl")
70-
include("lkj.jl")
71-
include("contexts.jl")
72-
include("context_implementations.jl")
57+
# include("utils.jl")
58+
# include("compiler.jl")
59+
# include("varnamedvector.jl")
60+
# include("varinfo.jl")
61+
# include("simple_varinfo.jl")
62+
# include("model.jl")
63+
# include("sampler.jl")
64+
# include("independence.jl")
65+
# include("distribution_wrappers.jl")
66+
# include("logdensityfunction.jl")
67+
# include("linking.jl")
68+
# include("serialization.jl")
69+
# include("pointwise_logdensities.jl")
70+
# include("lkj.jl")
71+
# include("contexts.jl")
72+
# include("context_implementations.jl")
7373
include("threadsafe.jl")
74-
include("debug_utils.jl")
75-
include("deprecated.jl")
76-
include("submodels.jl")
74+
# include("debug_utils.jl")
75+
# include("deprecated.jl")
76+
# include("submodels.jl")
7777
end
7878

7979
if GROUP == "All" || GROUP == "Group2"
80-
@testset "compat" begin
81-
include(joinpath("compat", "ad.jl"))
82-
end
83-
@testset "extensions" begin
84-
include("ext/DynamicPPLMCMCChainsExt.jl")
85-
include("ext/DynamicPPLJETExt.jl")
86-
end
87-
@testset "ad" begin
88-
include("ext/DynamicPPLForwardDiffExt.jl")
89-
if !IS_PRERELEASE
90-
include("ext/DynamicPPLMooncakeExt.jl")
91-
end
92-
include("ad.jl")
93-
end
94-
@testset "prob and logprob macro" begin
95-
@test_throws ErrorException prob"..."
96-
@test_throws ErrorException logprob"..."
97-
end
98-
if !IS_PRERELEASE
99-
# Don't run doctests on prerelease as error messages etc. may vary
100-
@testset "doctests" begin
101-
DocMeta.setdocmeta!(
102-
DynamicPPL,
103-
:DocTestSetup,
104-
:(using DynamicPPL, Distributions);
105-
recursive=true,
106-
)
107-
doctestfilters = [
108-
# Ignore the source of a warning in the doctest output, since this is dependent on host.
109-
# This is a line that starts with "└ @ " and ends with the line number.
110-
r"└ @ .+:[0-9]+",
111-
]
112-
doctest(DynamicPPL; manual=false, doctestfilters=doctestfilters)
113-
end
114-
end
80+
# @testset "compat" begin
81+
# include(joinpath("compat", "ad.jl"))
82+
# end
83+
# @testset "extensions" begin
84+
# include("ext/DynamicPPLMCMCChainsExt.jl")
85+
# include("ext/DynamicPPLJETExt.jl")
86+
# end
87+
# @testset "ad" begin
88+
# include("ext/DynamicPPLForwardDiffExt.jl")
89+
# if !IS_PRERELEASE
90+
# include("ext/DynamicPPLMooncakeExt.jl")
91+
# end
92+
# include("ad.jl")
93+
# end
94+
# @testset "prob and logprob macro" begin
95+
# @test_throws ErrorException prob"..."
96+
# @test_throws ErrorException logprob"..."
97+
# end
98+
# if !IS_PRERELEASE
99+
# # Don't run doctests on prerelease as error messages etc. may vary
100+
# @testset "doctests" begin
101+
# DocMeta.setdocmeta!(
102+
# DynamicPPL,
103+
# :DocTestSetup,
104+
# :(using DynamicPPL, Distributions);
105+
# recursive=true,
106+
# )
107+
# doctestfilters = [
108+
# # Ignore the source of a warning in the doctest output, since this is dependent on host.
109+
# # This is a line that starts with "└ @ " and ends with the line number.
110+
# r"└ @ .+:[0-9]+",
111+
# ]
112+
# doctest(DynamicPPL; manual=false, doctestfilters=doctestfilters)
113+
# end
114+
# end
115115
end
116116
end

test/threadsafe.jl

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
global vi_ = __varinfo__
4343
x[1] ~ Normal(0, 1)
4444
Threads.@threads for i in 2:length(x)
45+
@show Threads.threadid()
4546
x[i] ~ Normal(x[i - 1], 1)
4647
end
4748
end
@@ -60,6 +61,7 @@
6061
@time wthreads(x)(vi)
6162

6263
# Ensure that we use `ThreadSafeVarInfo` to handle multithreaded observe statements.
64+
@info "Threads.threadid() = $(Threads.threadid())"
6365
DynamicPPL.evaluate_threadsafe!!(
6466
wthreads(x),
6567
vi,

0 commit comments

Comments
 (0)