-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Description
Hit this issue while debugging Oceananigans+Reactant+MPI halo exchange.
The data from send_buf is properly received into recv_buf, but then when we try to "unpack the data", ie copy it from recv_buf into data_buf, data_buf does not get modified.
Interestingly, it all works fine when we wait for the request with Wait instead of Waitall.
using MPI
using Reactant
Reactant.set_default_backend("cpu")
const USE_WAITALL = parse(Bool, get(ENV, "USE_WAITALL", "true"))
function exchange!(send_buf, recv_buf, data_buf)
# send/recv
if rank == 0
dest = 1
req = MPI.Isend(send_buf, dest, tag, comm)
else
src = 0
req = MPI.Irecv!(recv_buf, src, tag, comm)
end
# waitall/wait
if USE_WAITALL
MPI.Waitall(vcat([req]...))
else
MPI.Wait(req)
end
# unpack recv_buf into data_buf
if rank == 1
# properly updated with wait, not modified with waitall
data_buf .= recv_buf
end
return nothing
end
# initialize
MPI.Init()
comm = MPI.COMM_WORLD
rank = MPI.Comm_rank(comm)
tag = 43
# allocate/init buffers
Nx=1
FT=Float64
send_buf = Reactant.to_rarray(zeros(FT, Nx))
send_buf .= reshape(FT.(collect(1:Nx)), Nx)
recv_buf = Reactant.to_rarray(zeros(FT, Nx))
data_buf = Reactant.to_rarray(zeros(FT, Nx))
# run
@jit exchange!(send_buf, recv_buf, data_buf)
# verify
# on rank 1 should have: recv_buf and data_buf == send_buf
if rank==1
println("send_buf = $(send_buf)")
println("recv_buf = $(recv_buf), ==send_buf:$(recv_buf==send_buf)")
println("data_buf = $(data_buf), ==send_buf:$(data_buf==send_buf)")
end
MPI.Finalize()Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels