Skip to content

Fixes Edge Cases with #167 #169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/darray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,18 @@ end
# get array of start indices for dividing sz into nc chunks
function defaultdist(sz::Int, nc::Int)
if sz >= nc
return ceil.(Int, range(1, stop=sz+1, length=nc+1))
chunk_size = div(sz,nc)
remainder = rem(sz,nc)
grid = zeros(Int64, nc+1)
for i = 1:(nc+1)
grid[i] += (i-1)*chunk_size + 1
if i<= remainder
grid[i] += i-1
else
grid[i] += remainder
end
end
return grid
else
return [[1:(sz+1);]; zeros(Int, nc-sz)]
end
Expand Down
3 changes: 3 additions & 0 deletions test/darray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ using SparseArrays: nnz
@test fetch(@spawnat MYID length(localpart(DA)) == 2)
@test fetch(@spawnat OTHERIDS length(localpart(DA)) == 1)
close(DA)
@test DistributedArrays.defaultdist(50,4) == [1,14,27,39,51]
end


end

check_leaks()
Expand Down