@@ -97,7 +97,7 @@ function DArray(id, init, dims, pids, idxs, cuts)
9797
9898 if length (unique (localtypes)) != 1
9999 @sync for p in pids
100- @async remotecall_fetch (release_localpart, p, id)
100+ @async remotecall_wait (release_localpart, p, id)
101101 end
102102 throw (ErrorException (" Constructed localparts have different `eltype`: $(localtypes) " ))
103103 end
@@ -147,8 +147,8 @@ function ddata(;T::Type=Any, init::Function=I->nothing, pids=workers(), data::Ve
147147 end
148148 end
149149
150- @sync for i = 1 : length ( pids)
151- @async remotecall_fetch (construct_localparts, pids[i] , init, id, (npids,), pids, idxs, cuts; T= T, A= T)
150+ @sync for p in pids
151+ @async remotecall_wait (construct_localparts, p , init, id, (npids,), pids, idxs, cuts; T= T, A= T)
152152 end
153153
154154 if myid () in pids
@@ -161,9 +161,10 @@ function ddata(;T::Type=Any, init::Function=I->nothing, pids=workers(), data::Ve
161161end
162162
163163function gather (d:: DArray{T,1,T} ) where T
164- a= Array {T} (undef, length (procs (d)))
165- @sync for (i,p) in enumerate (procs (d))
166- @async a[i] = remotecall_fetch (localpart, p, d)
164+ pids = procs (d)
165+ a = Vector {T} (undef, length (pids))
166+ asyncmap! (a, pids) do p
167+ remotecall_fetch (localpart, p, d)
167168 end
168169 a
169170end
@@ -195,12 +196,9 @@ function DArray(refs)
195196 dimdist = size (refs)
196197 id = next_did ()
197198
198- npids = [r. where for r in refs]
199199 nsizes = Array {Tuple} (undef, dimdist)
200- @sync for i in 1 : length (refs)
201- let i= i
202- @async nsizes[i] = remotecall_fetch (sz_localpart_ref, npids[i], refs[i], id)
203- end
200+ asyncmap! (nsizes, refs) do r
201+ remotecall_fetch (sz_localpart_ref, r. where, r, id)
204202 end
205203
206204 nindices = Array {NTuple{length(dimdist),UnitRange{Int}}} (undef, dimdist... )
@@ -223,7 +221,7 @@ function DArray(refs)
223221 ncuts = Array{Int,1 }[pushfirst! (sort (unique (lastidxs[x,:])), 1 ) for x in 1 : length (dimdist)]
224222 ndims = tuple ([sort (unique (lastidxs[x,:]))[end ]- 1 for x in 1 : length (dimdist)]. .. )
225223
226- DArray (id, refs, ndims, reshape (npids, dimdist ), nindices, ncuts)
224+ DArray (id, refs, ndims, map (r -> r . where, refs ), nindices, ncuts)
227225end
228226
229227macro DArray (ex0:: Expr )
@@ -683,8 +681,8 @@ Base.copy(d::SubDArray) = copyto!(similar(d), d)
683681Base. copy (d:: SubDArray{<:Any,2} ) = copyto! (similar (d), d)
684682
685683function Base. copyto! (dest:: SubOrDArray , src:: AbstractArray )
686- asyncmap ( procs (dest)) do p
687- remotecall_fetch (p) do
684+ @sync for p in procs (dest)
685+ @async remotecall_wait (p) do
688686 ldest = localpart (dest)
689687 copyto! (ldest, view (src, localindices (dest)... ))
690688 end
694692
695693function Base. deepcopy (src:: DArray )
696694 dest = similar (src)
697- asyncmap ( procs (src)) do p
698- remotecall_fetch (p) do
695+ @sync for p in procs (src)
696+ @async remotecall_wait (p) do
699697 dest[:L ] = deepcopy (src[:L ])
700698 end
701699 end
@@ -846,16 +844,17 @@ end
846844
847845function Base. fill! (A:: DArray , x)
848846 @sync for p in procs (A)
849- @async remotecall_fetch ((A,x)-> ( fill! (localpart (A), x); nothing ), p, A, x)
847+ @async remotecall_wait ((A,x)-> fill! (localpart (A), x), p, A, x)
850848 end
851849 return A
852850end
853851
854852using Random
855853
856854function Random. rand! (A:: DArray , :: Type{T} ) where T
857- asyncmap ( procs (A)) do p
858- remotecall_wait ((A, T)-> rand! (localpart (A), T), p, A, T)
855+ @sync for p in procs (A)
856+ @async remotecall_wait ((A, T)-> rand! (localpart (A), T), p, A, T)
859857 end
858+ return A
860859end
861860
0 commit comments