Ok, Julia does not like this:
nw = 2;
addprocs(nw);
@everywhere using IterTools
@everywhere function Euler(x0, f, Δt, t_final)
x = deepcopy(x0);
t = 0.0;
n = round(Int,t_final/Δt);
for j = 1:n
x+= Δt * f(t, x);
end
return x
end
@everywhere function f(t, x, k)
return cos(k * x);
end
Δt_vals = logspace(-2,-1,31);
@everywhere x0 = 1.0;
@everywhere t_final = 1.0;
k_vals = [1,2,4,8,16];
results = pmap((Δt, k)-> Euler(x0, (t,x)->f(t,x,k), Δt, t_final), product(Δt_vals, k_vals) )
and gives the error
ERROR: LoadError: On worker 2:
MethodError: no method matching (::Base.Serializer.__deserialized_types__.##21#23)(::Tuple{Float64,Int64})
Closest candidates are:
#21(::Any, ::Any) at /Users/gideonsimpson/code/julia_testing/odeparams1.jl:26
#106 at ./distributed/process_messages.jl:268 [inlined]
run_work_thunk at ./distributed/process_messages.jl:56
macro expansion at ./distributed/process_messages.jl:268 [inlined]
#105 at ./event.jl:73
Stacktrace:
[1] #573 at ./asyncmap.jl:178 [inlined]
[2] foreach(::Base.##573#575, ::Array{Any,1}) at ./abstractarray.jl:1733
[3] maptwice(::Function, ::Channel{Any}, ::Array{Any,1}, ::IterTools.Product{Tuple{Array{Float64,1},Array{Int64,1}}}, ::Vararg{IterTools.Product{Tuple{Array{Float64,1},Array{Int64,1}}},N} where N) at ./asyncmap.jl:178
[4] wrap_n_exec_twice(::Channel{Any}, ::Array{Any,1}, ::Base.Distributed.##204#207{WorkerPool}, ::Function, ::IterTools.Product{Tuple{Array{Float64,1},Array{Int64,1}}}, ::Vararg{IterTools.Product{Tuple{Array{Float64,1},Array{Int64,1}}},N} where N) at ./asyncmap.jl:154
[5] #async_usemap#558(::Function, ::Void, ::Function, ::Base.Distributed.##188#190, ::IterTools.Product{Tuple{Array{Float64,1},Array{Int64,1}}}, ::Vararg{IterTools.Product{Tuple{Array{Float64,1},Array{Int64,1}}},N} where N) at ./asyncmap.jl:103
[6] (::Base.#kw##async_usemap)(::Array{Any,1}, ::Base.#async_usemap, ::Function, ::IterTools.Product{Tuple{Array{Float64,1},Array{Int64,1}}}, ::Vararg{IterTools.Product{Tuple{Array{Float64,1},Array{Int64,1}}},N} where N) at ./<missing>:0
[7] (::Base.#kw##asyncmap)(::Array{Any,1}, ::Base.#asyncmap, ::Function, ::IterTools.Product{Tuple{Array{Float64,1},Array{Int64,1}}}) at ./<missing>:0
[8] #pmap#203(::Bool, ::Int64, ::Void, ::Array{Any,1}, ::Void, ::Function, ::WorkerPool, ::Function, ::IterTools.Product{Tuple{Array{Float64,1},Array{Int64,1}}}) at ./distributed/pmap.jl:126
[9] pmap(::WorkerPool, ::Function, ::IterTools.Product{Tuple{Array{Float64,1},Array{Int64,1}}}) at ./distributed/pmap.jl:101
[10] #pmap#213(::Array{Any,1}, ::Function, ::Function, ::IterTools.Product{Tuple{Array{Float64,1},Array{Int64,1}}}) at ./distributed/pmap.jl:156
[11] pmap(::Function, ::IterTools.Product{Tuple{Array{Float64,1},Array{Int64,1}}}) at ./distributed/pmap.jl:156
[12] include_from_node1(::String) at ./loading.jl:576
[13] include(::String) at ./sysimg.jl:14