Skip to content

Commit

Permalink
parallel forward
Browse files Browse the repository at this point in the history
  • Loading branch information
montyvesselinov committed Jan 22, 2024
1 parent 6ab6924 commit 210cab6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/MadsForward.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,29 @@ function forward(madsdata::AbstractDict, paramarray::AbstractArray; all::Bool=fa
local rv
restartdir = getrestartdir(madsdata_c)
if checkpointfrequency != 0 && restartdir != ""
@info("RobustPmap for parallel execution of forward runs ...")
if s[2] == np
rv = RobustPmap.crpmap(i->f(vec(paramarray[i, :])), checkpointfrequency, joinpath(restartdir, checkpointfilename), 1:nr)
else
rv = RobustPmap.crpmap(i->f(vec(paramarray[:, i])), checkpointfrequency, joinpath(restartdir, checkpointfilename), 1:nr)
end
r = hcat(collect(rv)...)
r = hcat(collect.(values.(rv))...)
elseif Distributed.nprocs() > 1
@info("Distributed.pmap for parallel execution of forward runs ...")
if s[2] == np
rv = Distributed.pmap(i->f(vec(paramarray[i, :])), 1:nr)
else
rv = Distributed.pmap(i->f(vec(paramarray[:, i])), 1:nr)
end
r = hcat(collect.(values.(rv))...)
else
@info("Serial execution of forward runs ...")
rv = Array{Array{Float64}}(undef, nr)
if s[2] == np
# r = RobustPmap.rpmap(i->f(vec(paramarray[i, :])), 1:nr)
@ProgressMeter.showprogress 4 for i = 1:nr
rv[i] = collect(values(f(vec(paramarray[i, :]))))
end
else
# r = RobustPmap.rpmap(i->f(vec(paramarray[:, i])), 1:nr)
@ProgressMeter.showprogress 4 for i = 1:nr
rv[i] = collect(values(f(vec(paramarray[:, i]))))
end
Expand Down

0 comments on commit 210cab6

Please sign in to comment.