Access to Distributed Arrays

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Access to Distributed Arrays

Sebastian Vollmer
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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Access to Distributed Arrays

Amit Murthy
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 <[hidden email]> 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 | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Access to Distributed Arrays

Sebastian Vollmer
Thanks a lot. That was helpful.
Loading...