@@ -538,14 +538,8 @@ Distribute a local array `A` like the distributed array `DA`.
538
538
function distribute (A:: AbstractArray , DA:: DArray )
539
539
size (DA) == size (A) || throw (DimensionMismatch (" Distributed array has size $(size (DA)) but array has $(size (A)) " ))
540
540
541
- owner = myid ()
542
- rr = RemoteChannel ()
543
- put! (rr, A)
544
-
545
- d = DArray (DA) do I
546
- remotecall_fetch (() -> fetch (rr)[I... ], owner)
547
- end
548
- return d
541
+ pas = PartitionedSerializer (A, procs (DA), DA. indexes)
542
+ return DArray (I-> verify_and_get (pas, I), DA)
549
543
end
550
544
551
545
Base. convert {T,N,S<:AbstractArray} (:: Type{DArray{T,N,S}} , A:: S ) = distribute (convert (AbstractArray{T,N}, A))
@@ -870,6 +864,21 @@ map_localparts(f::Callable, d::DArray) = DArray(i->f(localpart(d)), d)
870
864
map_localparts (f:: Callable , d1:: DArray , d2:: DArray ) = DArray (d1) do I
871
865
f (localpart (d1), localpart (d2))
872
866
end
867
+
868
+ function map_localparts (f:: Callable , DA:: DArray , A:: Array )
869
+ pas = PartitionedSerializer (A, procs (DA), DA. indexes)
870
+ DArray (DA) do I
871
+ f (localpart (DA), verify_and_get (pas, I))
872
+ end
873
+ end
874
+
875
+ function map_localparts (f:: Callable , A:: Array , DA:: DArray )
876
+ pas = PartitionedSerializer (A, procs (DA), DA. indexes)
877
+ DArray (DA) do I
878
+ f (verify_and_get (pas, I), localpart (DA))
879
+ end
880
+ end
881
+
873
882
function map_localparts! (f:: Callable , d:: DArray )
874
883
@sync for p in procs (d)
875
884
@async remotecall_fetch ((f,d)-> (f (localpart (d)); nothing ), p, f, d)
0 commit comments