Thanks German, indeed I have seen that SharedArrays couldn't be used for 
user-defined types...
I tried to compare the approach you suggested with the serial one, and 
results are so awfully slow with the parallel version that I might have 
done something wrong...
Here it is:

@everywhere type T a end
N = Int(1e5)
v = Array(T, N)
refs = Vector{RemoteRef}(N)
for i = 1:N
    refs[i] = @spawn begin T(i) end
end
for i = 1:N
    v[i] = fetch(refs[i])
end

called with:

time julia -p 4 parallel.jl

takes 0m31.706s, whereas

type T a end
N = Int(1e5)
v = Array(T, N)
for i = 1:N
    v[i] = T(i)
end

called with:

time julia serial.jl

takes only 0m0.293s...

Reply via email to