Skip to content

Commit

Permalink
fix sharedarray indexing regression
Browse files Browse the repository at this point in the history
  • Loading branch information
Rene Donner committed Sep 6, 2015
1 parent b3a1be5 commit 55f2cf0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions base/sharedarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@ end
convert(::Type{Array}, S::SharedArray) = S.s

# pass through getindex and setindex! - unlike DArrays, these always work on the complete array
getindex(S::SharedArray, I::Real) = getindex(S.s, I)
getindex(S::SharedArray, i::Real) = getindex(S.s, i)

setindex!(S::SharedArray, x, I::Real) = setindex!(S.s, x, I)
setindex!(S::SharedArray, x, i::Real) = setindex!(S.s, x, i)

function fill!(S::SharedArray, v)
vT = convert(eltype(S), v)
Expand Down Expand Up @@ -334,10 +334,10 @@ function shmem_randn(dims; kwargs...)
end
shmem_randn(I::Int...; kwargs...) = shmem_randn(I; kwargs...)

similar(S::SharedArray, T, dims::Dims) = SharedArray(T, dims; pids=procs(S))
similar(S::SharedArray, T) = similar(S, T, size(S))
similar(S::SharedArray, dims::Dims) = similar(S, eltype(S), dims)
similar(S::SharedArray) = similar(S, eltype(S), size(S))
similar(S::SharedArray, T, dims::Dims) = similar(S.s, T, dims)
similar(S::SharedArray, T) = similar(S.s, T, size(S))
similar(S::SharedArray, dims::Dims) = similar(S.s, eltype(S), dims)
similar(S::SharedArray) = similar(S.s, eltype(S), size(S))

map(f, S::SharedArray) = (S2 = similar(S); S2[:] = S[:]; map!(f, S2); S2)

Expand Down
3 changes: 3 additions & 0 deletions test/parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ for p in procs(d)
@test d[idxl] == p
end

d = SharedArray(Float64, (2,3))
@test isa(d[:,2], Vector{Float64})

### SharedArrays from a file

# Mapping an existing file
Expand Down

0 comments on commit 55f2cf0

Please sign in to comment.