The DArray has been distributed only on the workers.  localpart(res) on the
master process returns "0x0 Array{Float64,2}" and hence the BoundsError()

You need to pass the DArray object to dowork. The following will work.

@everywhere function dowork(res)
    localpart(res)[1]+=rand()
end
@spawnat 2 dowork(res)



On Thu, Jul 24, 2014 at 4:41 AM, Sebastian Vollmer <[email protected]>
wrote:

> I am trying to access parts of a distributed array that  belongs to the
> current worker
>
> res=dzeros((1,length(workers())), workers(), [1,length(workers())])
>
> (for some reason res=dzeros((length(workers())), workers(),
> [length(workers())]) throws an error )
>
> @spawnat 2  localpart(res)[1]+=rand()
>
> works perfectly fine. However,
> @everywhere function dowork()
>     localpart(res)[1]+=rand()
> end
> @spawnat 2 dowork()
>
> produces error exception on 2: ERROR: res not defined
>
> so does
>
> @async begin
>     localpart(res)[1]+=rand()
> end
>
> throws  ERROR: BoundsError().
>
> Why do the two code snipplets produce errors?
>
>

Reply via email to