Skip to content

Commit 86d883c

Browse files
traktofonandreasnoack
authored andcommitted
Add constructor for Array from DArray.
This fixes extreme slowness of convert(Array, ::DArray) which was falling back to the generic constructor from AbstractArray.
1 parent a77e35b commit 86d883c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/darray.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function ddata(;T::Type=Any, init::Function=I->nothing, pids=workers(), data::Ve
153153
end
154154

155155
function gather(d::DArray{T,1,T}) where T
156-
a=Array{T}(length(procs(d)))
156+
a=Array{T}(undef, length(procs(d)))
157157
@sync for (i,p) in enumerate(procs(d))
158158
@async a[i] = remotecall_fetch(localpart, p, d)
159159
end

test/darray.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,9 +892,10 @@ end
892892
d = DistributedArrays.drand(T, 10^i)
893893
@testset "sample = $sample" for sample in Any[true, false, (minimum(d),maximum(d)), rand(T, 10^i>512 ? 512 : 10^i)]
894894
d2 = DistributedArrays.sort(d; sample=sample)
895-
895+
a = convert(Array, d)
896+
a2 = convert(Array, d2)
896897
@test length(d) == length(d2)
897-
@test sort(convert(Array, d)) == convert(Array, d2)
898+
@test sort(a) == a2
898899
end
899900
d_closeall() # close the temporaries created above
900901
end

0 commit comments

Comments
 (0)