Hi,
I have some problems adding tuples in a parallel for-loop since an update from v0.5 to v0.6.
I define the addition of tuples in the following way …
#defining a function that adds up two tuples a and b of arbitrary length N and element type
addtup{N}(a::NTuple{N,Any},b::NTuple{N,Any}) = ntuple(i-> a[i]+b[i],Val{N})
and this function seems to work well both in v0.5 and v0.6 of Julia. E.g., defining a simple tuple of three entries (a scalar, vector and matrix) all composed of ones
mytuple = (1,[1,1,1],[1 1;1 1])
addtup(mytuple,mytuple) # => (2,[2,2,2],[2 2;2 2])
leads to the correct result (the addition of all tuple elements).
Now I am trying to use this addition operator in a parallel for-loop, that is
result = @parallel (addtup) for n=1:100
(1,[1,1,1],[1 1;1 1])
end
(in reality the parallel loop includes a function that returns a tuple, but the above minimal example should be sufficient). This should evaluate to
result = (100,[100,100,100],[100 100;100 100])
and works fine with Julia v0.5 (in parallel with different workers), and also in v.0.6 if I execute the above loop without starting multiple workers (i.e., starting Julia w/o the “-p” option). However, trying to parallelize it in v.0.6 leads to an error
ERROR: Error deserializing a remote exception from worker 2
Remote(original) exception of type TypeError
Remote stacktrace :
deserialize at ./serialize.jl:776
deserialize_typename at ./serialize.jl:938
deserialize at ./distributed/clusterserialize.jl:52
#99 at ./event.jl:73
Stacktrace:
[1] collect(::Base.Generator{Array{Task,1},Base.#wait}) at ./array.jl:441
[2] preduce(::Function, ::Function, ::UnitRange{Int64}) at ./distributed/macros.jl:148
If, in contrast, I replace the addition function by the less universal version (specifying directly the number of tuple elements to be 3)
addtup(a,b) = ntuple(i-> a[i]+b[i],3)
then everything works fine also in v0.6.
Does anyone have an idea what I am doing wrong or how this should be adjusted to work in v0.6 as well?
Many Thanks!