Skip to content

Commit

Permalink
Merge pull request #17067 from JuliaLang/amitm/zeroshmem
Browse files Browse the repository at this point in the history
fix sharedarrays for singleton immutables
  • Loading branch information
vtjnash authored Jun 23, 2016
2 parents dbea5c3 + 8221cfb commit b23c812
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions base/sharedarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function SharedArray(T::Type, dims::NTuple; init=false, pids=Int[])
end

# All good, immediately unlink the segment.
if prod(dims) > 0
if (prod(dims) > 0) && (sizeof(T) > 0)
if onlocalhost
rc = shm_unlink(shm_seg_name)
else
Expand Down Expand Up @@ -508,7 +508,7 @@ function shm_mmap_array(T, dims, shm_seg_name, mode)
local s = nothing
local A = nothing

if prod(dims) == 0
if (prod(dims) == 0) || (sizeof(T) == 0)
return Array{T}(dims)
end

Expand Down
7 changes: 7 additions & 0 deletions test/parallel_exec.jl
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,13 @@ map!(x->1, d)
@test 2.0 == remotecall_fetch(D->D[2], id_other, Base.shmem_fill(2.0, 2; pids=[id_me, id_other]))
@test 3.0 == remotecall_fetch(D->D[1], id_other, Base.shmem_fill(3.0, 1; pids=[id_me, id_other]))

# Shared arrays of singleton immutables
@everywhere immutable ShmemFoo end
for T in [Void, ShmemFoo]
s = SharedArray(T, 10)
@test T() === remotecall_fetch(x->x[3], workers()[1], s)
end

# Issue #14664
d = SharedArray(Int,10)
@sync @parallel for i=1:10
Expand Down

0 comments on commit b23c812

Please sign in to comment.