11# FixMe! Right now the MPI workers are deduced from the DArrays, but if a DArray is distributed on fewer workers that what consistutes the MPI world, then this approach will fail.
22
3+ using DistributedArrays: procs
4+
35mutable struct RemoteElementalMatrix
46 refs:: Matrix{Any}
57end
68
7- function toback (A:: DArray{T,2,S} where {T<: BlasFloat ,S<: StridedMatrix })
8- rs = Array {Any} (size (procs (A)))
9+ function toback (A:: DArray{T,2,S} ) where {T<: BlasFloat ,S<: StridedMatrix }
10+ rs = Array {Any} (undef, size (procs (A)))
911 @sync for p in eachindex (procs (A))
10- ind = A. indexes [p]
12+ ind = A. indices [p]
1113 @async rs[p] = remotecall (procs (A)[p]) do
1214 lA = localpart (A)
1315 AlA = Elemental. DistMatrix (T)
1416 zeros! (AlA, size (A)... )
1517 for j = 1 : size (lA,2 ), i = 1 : size (lA, 1 )
1618 queueUpdate (AlA,
17- start (ind[1 ]) + i - 1 ,
18- start (ind[2 ]) + j - 1 , lA[i,j])
19+ first (ind[1 ]) + i - 1 ,
20+ first (ind[2 ]) + j - 1 , lA[i,j])
1921 end
2022 processQueues (AlA)
2123 AlA
@@ -25,7 +27,7 @@ function toback(A::DArray{T,2,S} where {T<:BlasFloat,S<:StridedMatrix})
2527end
2628
2729function tofront (r:: Base.Matrix )
28- tt = Array {Any} (length (r))
30+ tt = Array {Any} (undef, length (r))
2931 for i = 1 : length (r)
3032 tt[i] = remotecall (r[i]. where, r[i]) do t
3133 typeof (fetch (t))
@@ -50,15 +52,15 @@ function tofront(r::Base.Matrix)
5052 Int[r[i]. where for i in eachindex (r)])
5153
5254 @sync for p in eachindex (r)
53- ind = A. indexes [p]
55+ ind = A. indices [p]
5456 rr = r[p]
5557 @async remotecall_wait (r[p]. where) do
5658 rrr = fetch (rr)
5759 lA = localpart (A)
5860 for j = 1 : size (lA, 2 ), i = 1 : size (lA, 1 )
5961 queuePull (rrr,
60- start (ind[1 ]) + i - 1 ,
61- start (ind[2 ]) + j - 1 )
62+ first (ind[1 ]) + i - 1 ,
63+ first (ind[2 ]) + j - 1 )
6264 end
6365 processPullQueue (rrr, lA)
6466 end
@@ -75,7 +77,7 @@ function (\)(A::DArray{T,2,S}, B::DArray{T,2,S}) where {T<:BlasFloat,S}
7577 rA = toback (A)
7678 rB = toback (B)
7779 pidsAB = union (A. pids, B. pids)
78- rvals = Vector {Any} (length (pidsAB))
80+ rvals = Vector {Any} (undef, length (pidsAB))
7981 @sync for i = 1 : length (pidsAB)
8082 @async rvals[i] = remotecall_wait (pidsAB[i], rA[i], rB[i]) do t1,t2
8183 solve! (fetch (t1), fetch (t2))
8688
8789function LinearAlgebra. eigvals (A:: Hermitian{T,DArray{T,2,Array{T,2}}} where {T<: BlasFloat } )
8890 rA = toback (A. data)
89- rvals = Array {Any} (size (procs (A. data)))
91+ rvals = Array {Any} (undef, size (procs (A. data)))
9092 uplo = A. uplo == ' U' ? UPPER : LOWER
9193 @sync for i in eachindex (rvals)
9294 @async rvals[i] = remotecall_wait (rA[i]. where, rA[i]) do t
98100
99101function LinearAlgebra. svdvals (A:: DArray{<:BlasFloat,2} )
100102 rA = toback (A)
101- rvals = Array {Any} (size (procs (A)))
103+ rvals = Array {Any} (undef, size (procs (A)))
102104 @sync for i in eachindex (rvals)
103105 @async rvals[i] = remotecall_wait (rA[i]. where, rA[i]) do t
104106 svdvals (fetch (t))
109111
110112function LinearAlgebra. inv! (A:: DArray{<:BlasFloat,2} )
111113 rA = toback (A)
112- rvals = Array {Any} (size (procs (A)))
114+ rvals = Array {Any} (undef, size (procs (A)))
113115 @sync for j = 1 : size (rvals, 2 )
114116 for i = 1 : size (rvals, 1 )
115117 @async rvals[i,j] = remotecall_wait (t -> inverse! (fetch (t)), rA[i,j]. where, rA[i,j])
@@ -118,11 +120,11 @@ function LinearAlgebra.inv!(A::DArray{<:BlasFloat,2})
118120 return tofront (rvals)
119121end
120122
121- LinearAlgebra. inv (A:: DArray{<:BlasFloat,2} ) = inv! (copy (A))
123+ LinearAlgebra. inv (A:: DArray{<:BlasFloat,2} ) = LinearAlgebra . inv! (copy (A))
122124
123125function LinearAlgebra. logdet (A:: DArray{<:BlasFloat,2} )
124126 rA = toback (A)
125- rvals = Array {Any} (size (procs (A)))
127+ rvals = Array {Any} (undef, size (procs (A)))
126128 @sync for i in eachindex (rvals)
127129 @async rvals[i] = remotecall_wait (rA[i]. where, rA[i]) do t
128130 d = safeHPDDeterminant (Elemental. LOWER, fetch (t))
@@ -137,7 +139,7 @@ function spectralPortrait(A::DArray{T,2},
137139 imagSize:: Integer ,
138140 psCtrl:: PseudospecCtrl{T} = PseudospecCtrl (T)) where {T<: BlasReal }
139141 rA = toback (A)
140- rvals = Array {Any} (size (procs (A)))
142+ rvals = Array {Any} (undef, size (procs (A)))
141143 @sync for i in eachindex (rvals)
142144 @async rvals[i] = remotecall_wait (rA[i]. where, rA[i]) do t
143145 spectralPortrait (fetch (t), ElInt (realSize), ElInt (imagSize), psCtrl)[1 ]
@@ -151,7 +153,7 @@ function spectralPortrait(A::DArray{Complex{T},2},
151153 imagSize:: Integer ,
152154 psCtrl:: PseudospecCtrl{T} = PseudospecCtrl (T)) where {T<: BlasReal }
153155 rA = toback (A)
154- rvals = Array {Any} (size (procs (A)))
156+ rvals = Array {Any} (undef, size (procs (A)))
155157 @sync for i in eachindex (rvals)
156158 @async rvals[i,j] = remotecall_wait (rA[i]. where, rA[i]) do t
157159 spectralPortrait (fetch (t), ElInt (realSize), ElInt (imagSize), psCtrl)[1 ]
@@ -168,7 +170,7 @@ function spectralWindow(A::DArray{T,2},
168170 imagSize:: Integer ,
169171 psCtrl:: PseudospecCtrl{T} = PseudospecCtrl (T)) where {T<: BlasReal }
170172 rA = toback (A)
171- rvals = Array {Any} (size (procs (A)))
173+ rvals = Array {Any} (undef, size (procs (A)))
172174 @sync for i in eachindex (rvals)
173175 @async rvals[i] = remotecall_wait (rA[i]. where, rA[i]) do t
174176 spectralWindow (fetch (t), center, realWidth, imagWidth,
@@ -186,7 +188,7 @@ function spectralWindow(A::DArray{Complex{T},2},
186188 imagSize:: Integer ,
187189 psCtrl:: PseudospecCtrl{T} = PseudospecCtrl (T)) where {T<: BlasReal }
188190 rA = toback (A)
189- rvals = Array {Any} (size (procs (A)))
191+ rvals = Array {Any} (undef, size (procs (A)))
190192 @sync for i in eachindex (rvals)
191193 @async rvals[i] = remotecall_wait (rA[i,j]. where, rA[i]) do t
192194 spectralWindow (fetch (t), center, realWidth, imagWidth,
198200
199201function foxLi (:: Type{T} , n:: Integer , ω:: Real ) where {T<: BlasComplex }
200202 sz = tuple (DistributedArrays. defaultdist ((n,n), workers ())... )
201- rvals = Array {Any} (sz)
203+ rvals = Array {Any} (undef, sz)
202204 @sync for j = 1 : size (rvals, 2 ), i = 1 : size (rvals, 1 )
203205 @async rvals[i,j] = remotecall_wait (workers ()[sub2ind (sz, i, j)]) do
204206 A = Elemental. DistMatrix (T)
@@ -233,7 +235,7 @@ for (elty, ext) in ((:ElInt, :i),
233235 for id in workers ()
234236 let A = A, DA = DA
235237 @async remotecall_fetch (id) do
236- rows, cols = DistributedArrays. localindexes (DA)
238+ rows, cols = DistributedArrays. localindices (DA)
237239 i,j,v = findnz (DistributedArrays. localpart (DA))
238240 gi, gj, gv = (i.+ (first (rows)- 1 ), j.+ (first (cols)- 1 ), v)
239241 numLocal = length (gi)
0 commit comments