Re: [julia-users] Mutual exclusion when writing to SharedArrays?

2015-07-21 Thread Tim Holy
On Monday, July 20, 2015 08:19:43 PM John Brock wrote: > Isn't that what DArrays are for, though? With a DArray, each chunk is local to only one process. That makes it really expensive to read data from other chunks. With SharedArrays, you have fast read access to the whole thing. But you have t

Re: [julia-users] Mutual exclusion when writing to SharedArrays?

2015-07-20 Thread John Brock
Isn't that what DArrays are for, though? Does Julia provide a mechanism for mutual exclusion/marking critical sections? I'm imagining something like: shared_result = SharedArray(Int64, (2,), init = S -> S[localindexes(S)] = 0 ) @parallel for i=1:3 lock shared_result shared_result[:] +

Re: [julia-users] Mutual exclusion when writing to SharedArrays?

2015-07-20 Thread Tim Holy
Usually the whole point of a SharedArray is that workers only update the piece they "own." You can make it work different if you implement locking, but lock contention can be a bottleneck. --Tim On Monday, July 20, 2015 04:29:04 PM John Brock wrote: > I'm seeing inconsistent results when multip

[julia-users] Mutual exclusion when writing to SharedArrays?

2015-07-20 Thread John Brock
I'm seeing inconsistent results when multiple workers write values to a SharedArray at the same time, presumably because += isn't atomic. Is this intended behavior, and is there a workaround? Behavior is reproducible in 0.3.8-pre+22 and 0.3.9. Sample code: function doStuff() result_shared =