Skip to content

Commit

Permalink
Merge pull request #11252 from JuliaLang/ksh/sharedarray
Browse files Browse the repository at this point in the history
Tests and bugfix for sharedarrays
  • Loading branch information
carlobaldassi committed May 13, 2015
2 parents eea99eb + 7cbbfd2 commit 7a30edd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/sharedarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ function rand!{T}(S::SharedArray{T})
end

function randn!(S::SharedArray)
f = S->map!(x->randn, S.loc_subarr_1d)
f = S->map!(x->randn(), S.loc_subarr_1d)
@sync for p in procs(S)
@async remotecall_wait(p, f, S)
end
Expand Down
20 changes: 20 additions & 0 deletions test/parallel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ copy!(s, d)
s = Base.shmem_rand(dims)
copy!(s, sdata(d))
@test s == d
a = rand(dims)
@test sdata(a) == a

d = SharedArray(Int, dims; init = D->fill!(D.loc_subarr_1d, myid()))
for p in procs(d)
Expand All @@ -70,6 +72,24 @@ for p in procs(d)
@test d[idxl] == p
end

# reshape

d = Base.shmem_fill(1.0, (10,10,10))
@test ones(100, 10) == reshape(d,(100,10))
d = Base.shmem_fill(1.0, (10,10,10))
@test_throws DimensionMismatch reshape(d,(50,))

# rand, randn
d = Base.shmem_rand(dims)
@test size(rand!(d)) == dims
d = Base.shmem_fill(1.0, dims)
@test size(randn!(d)) == dims

# similar
d = Base.shmem_rand(dims)
@test size(similar(d, Complex128)) == dims
@test size(similar(d, dims)) == dims

# issue #6362
d = Base.shmem_rand(dims)
s = copy(sdata(d))
Expand Down

0 comments on commit 7a30edd

Please sign in to comment.