Following up - this doesn't seem to work and I don't know why:
julia> nprocs()
4
julia> @everywhere d = Vector{LightGraphs.DijkstraState}(3000)
julia> @everywhere g = readgraph(
"/Users/seth/dev/julia/wip/LightGraphs.jl/test/testdata/pgp2.jgz")["pgp"]
julia> @everywhere h = g[1:3000]
julia> a = @sync @parallel for v in 1:nv(h) # iterate over the vectors
d[v] = dijkstra_shortest_paths(h,v) # put the return value of
d_s_p into the array
end
3-element Array{Any,1}:
RemoteRef{Channel{Any}}(2,1,61)
RemoteRef{Channel{Any}}(3,1,63)
RemoteRef{Channel{Any}}(4,1,65)
Why is @sync @parallel returning an array of RemoteRefs, and is there
something straightforward I need to do to make this work properly?
On Friday, August 28, 2015 at 9:57:29 AM UTC-7, Seth wrote:
>
> I'm not understanding the docs on parallelization. I'd like to parallelize
> a betweenness centrality calculation:
>
> for s in nodes
> state = dijkstra_shortest_paths(g, s; allpaths=true)
> if endpoints
> _accumulate_endpoints!(betweenness, state, g, s)
> else
> _accumulate_basic!(betweenness, state, g, s)
> end
> end
>
>
> nodes is a vector of ints over which the calculation should be run (by
> default, this is every vertex in the graph). Because both state() and
> _accumulate_* are independent calculations, it seems to me that I could
> take advantage of multiple cores / processors to speed things up. However,
> I don't know where to start. Any advice would be greatly appreciated.
>
> State has arrays of ints called "dists" and "parents" - each run through
> this loop alters these arrays, but there's no dependence between loop
> iterations.
>