I believe this:

func(shared[:])

is equivalent to:

tmp = similar(shared)
for i in eachindex(shared)
   tmp[i] = shared[i]
end
func(tmp)

Note:

julia> typeof(similar(SharedArray(Float64,10)))
Array{Float64,1}



On Saturday, January 9, 2016 at 8:04:28 PM UTC+1, Nils Gudat wrote:
>
> Usually when doing calculations on SharedArrays, I would extract their 
> contents using sdata() to be able to pass them to functions only defined 
> for regular arrays, and then write the return value back into the 
> SharedArray. However, I just realized that instead of doing say:
>
> shared[:] = func(sdata(shared))
>
> I could also do:
>
> shared[:] = func(shared[:])
>
> as typeof(shared[:]) is Array{Float64,1}. What is happening here? Does [:] 
> call sdata()? 
> This behaviour is sort of intuitive I guess, given that one would expect a 
> call to, say, shared[1] to return a Float64 rather than a SharedFloat64 
> (which doesn't exist), but I still don't quite get it.
>

Reply via email to