Skip to content

Commit

Permalink
Integrated parallel implementation of ipmcmc similar to the proposal …
Browse files Browse the repository at this point in the history
…in #65
  • Loading branch information
trappmartin committed Aug 14, 2018
1 parent 20952e6 commit 0d43048
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions src/samplers/ipmcmc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,23 @@ step(model::Function, spl::Sampler{IPMCMC}, VarInfos::Array{VarInfo}, is_first::
log_zs = zeros(spl.alg.n_nodes)

# Run SMC & CSMC nodes
for j in 1:spl.alg.n_nodes
VarInfos[j].num_produce = 0
VarInfos[j] = step(model, spl.info[:samplers][j], VarInfos[j])
log_zs[j] = spl.info[:samplers][j].info[:logevidence][end]
if nprocs() > 1
tmp_ = @parallel (vcat) for j in 1:spl.alg.n_nodes
VarInfos[j].num_produce = 0
step(model, spl.info[:samplers][j], VarInfos[j])
end

for j in 1:spl.alg.n_nodes
VarInfos[j] = tmp_[j]
log_zs[j] = getlogp(tmp_[j])
end
tmp_ = nothing
else
for j in 1:spl.alg.n_nodes
VarInfos[j].num_produce = 0
VarInfos[j] = step(model, spl.info[:samplers][j], VarInfos[j])
log_zs[j] = spl.info[:samplers][j].info[:logevidence][end]
end
end

# Resampling of CSMC nodes indices
Expand Down

0 comments on commit 0d43048

Please sign in to comment.