Skip to content

Commit 30621dd

Browse files
traktofonandreasnoack
authored andcommitted
Fixed deprecations in SPMD.
All tests pass without deprecation warnings now.
1 parent cd94d5c commit 30621dd

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/spmd.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ function scatter(x, pid::Int; tag=nothing, pids=procs())
198198
p == pid && continue
199199
send_msg(p, :scatter, x[cnt*(i-1)+1:cnt*i], tag)
200200
end
201-
myidx = findfirst(sort(pids), pid)
201+
myidx = findfirst(isequal(pid), sort(pids))
202202
return x[cnt*(myidx-1)+1:cnt*myidx]
203203
else
204204
_, data = get_msg(:scatter, pid, tag)
@@ -208,13 +208,13 @@ end
208208

209209
function gather(x, pid::Int; tag=nothing, pids=procs())
210210
if myid() == pid
211-
gathered_data = Array{Any}(length(pids))
212-
myidx = findfirst(sort(pids), pid)
211+
gathered_data = Array{Any}(undef, length(pids))
212+
myidx = findfirst(isequal(pid), sort(pids))
213213
gathered_data[myidx] = x
214214
n = length(pids) - 1
215215
while n > 0
216216
from, data_x = get_msg(:gather, false, tag)
217-
fromidx = findfirst(sort(pids), from)
217+
fromidx = findfirst(isequal(from), sort(pids))
218218
gathered_data[fromidx] = data_x
219219
n=n-1
220220
end

test/spmd.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ spmd(spmd_test1)
7676
# define the function everywhere
7777
@everywhere function foo_spmd(d_in, d_out, n)
7878
pids=sort(vec(procs(d_in)))
79-
pididx = findfirst(pids, myid())
79+
pididx = findfirst(isequal(myid()), pids)
8080
mylp = localpart(d_in)
8181
localsum = 0
8282

@@ -122,7 +122,7 @@ println("SPMD: Passed testing of spmd function run concurrently")
122122
# define the function everywhere
123123
@everywhere function foo_spmd2(d_in, d_out, n)
124124
pids=sort(vec(procs(d_in)))
125-
pididx = findfirst(pids, myid())
125+
pididx = findfirst(isequal(myid()), pids)
126126
mylp = localpart(d_in)
127127

128128
# see if we have a value in the local store.
@@ -170,7 +170,7 @@ end
170170
# verify localstores with appropriate context store values exist.
171171
@everywhere begin
172172
if myid() != 1
173-
n = 0
173+
local n = 0
174174
for (k,v) in DistributedArrays.SPMD.map_ctxts
175175
store = v.store
176176
localsum = store[:LOCALSUM]

0 commit comments

Comments
 (0)