Skip to content

Commit

Permalink
Add SharedArray get/setindex! for Colon()
Browse files Browse the repository at this point in the history
and a few trivial tests
  • Loading branch information
mbauman committed Feb 28, 2015
1 parent c1eb266 commit cbf8084
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions base/sharedarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ convert(::Type{Array}, S::SharedArray) = S.s
getindex(S::SharedArray) = getindex(S.s)
getindex(S::SharedArray, I::Real) = getindex(S.s, I)
getindex(S::SharedArray, I::AbstractArray) = getindex(S.s, I)
stagedfunction getindex(S::SharedArray, I::Union(Real,AbstractVector)...)
getindex(S::SharedArray, I::Colon) = getindex(S.s, I)
stagedfunction getindex(S::SharedArray, I::Union(Real,AbstractVector,Colon)...)
N = length(I)
Isplat = Expr[:(I[$d]) for d = 1:N]
quote
Expand All @@ -221,7 +222,8 @@ end
setindex!(S::SharedArray, x) = setindex!(S.s, x)
setindex!(S::SharedArray, x, I::Real) = setindex!(S.s, x, I)
setindex!(S::SharedArray, x, I::AbstractArray) = setindex!(S.s, x, I)
stagedfunction setindex!(S::SharedArray, x, I::Union(Real,AbstractVector)...)
setindex!(S::SharedArray, x, I::Colon) = setindex!(S.s, x, I)
stagedfunction setindex!(S::SharedArray, x, I::Union(Real,AbstractVector,Colon)...)
N = length(I)
Isplat = Expr[:(I[$d]) for d = 1:N]
quote
Expand Down
3 changes: 3 additions & 0 deletions test/parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ map!(x->1, d)

@test fill!(d, 1) == ones(10, 10)
@test fill!(d, 2.) == fill(2, 10, 10)
@test d[:] == fill(2, 100)
@test d[:,1] == fill(2, 10)
@test d[1,:] == fill(2, 1, 10)

# Boundary cases where length(S) <= length(pids)
@test 2.0 == remotecall_fetch(id_other, D->D[2], Base.shmem_fill(2.0, 2; pids=[id_me, id_other]))
Expand Down

0 comments on commit cbf8084

Please sign in to comment.