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

Enable parallelization #38

Merged
merged 23 commits into from
Apr 26, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Don't nest multi-threading by default
sethaxen committed Apr 26, 2022
commit 670276f43bb76ce9b1b5ec6e4b282876770157d8
10 changes: 5 additions & 5 deletions src/multipath.jl
Original file line number Diff line number Diff line change
@@ -42,9 +42,10 @@ resulting draws better approximate draws from the target distribution ``p`` inst
- `executor::Transducers.Executor`: Transducers.jl executor that determines if and how
to run the single-path runs in parallel. If `rng` is known to be thread-safe, the
default is `Transducers.PreferParallel(; basesize=1)` (parallel executation, defaulting
to multi-threading). Otherwise, it is `Transducers.SerialEx()` (no parallelization).
- `executor_per_run::Transducers.Executor`: Transducers.jl executor used within each run to
parallelize PRNG calls. See [`pathfinder`](@ref) for a description.
to multi-threading). Otherwise, it is `Transducers.SequentialEx()` (no parallelization).
- `executor_per_run::Transducers.Executor=Transducers.SequentialEx()`: Transducers.jl
executor used within each run to parallelize PRNG calls. Defaults to no parallelization.
See [`pathfinder`](@ref) for a description.
- `kwargs...` : Remaining keywords are forwarded to [`pathfinder`](@ref).

# Returns
@@ -90,7 +91,7 @@ function multipathfinder(
ndraws_per_run::Int=5,
rng::Random.AbstractRNG=Random.GLOBAL_RNG,
executor::Transducers.Executor=_default_executor(rng; basesize=1),
executor_per_run=_default_executor(rng),
executor_per_run=Transducers.SequentialEx(),
importance::Bool=true,
kwargs...,
)
@@ -103,7 +104,6 @@ function multipathfinder(
logp(x) = -optim_fun.f(x, nothing)

# run pathfinder independently from each starting point
# TODO: allow to be parallelized
trans = Transducers.Map() do θ₀
return pathfinder(
optim_fun, θ₀, ndraws_per_run; rng, executor=executor_per_run, kwargs...