Skip to content
Snippets Groups Projects
Commit 34770493 authored by Jeremy Edward Kozdon's avatar Jeremy Edward Kozdon
Browse files

Finish comm pattern

parent 7c5bbcb8
Branches master
No related tags found
No related merge requests found
......@@ -190,23 +190,20 @@ function exchangedata!(A, xrng, yrng, mpicomm, Rx, Ry, Sx, Sy)
recvreqs = fill(MPI.REQUEST_NULL, 8)
# possible neighbors:
# Southwest: (Rx-1, Ry-1)
# southwest: (Rx-1, Ry-1)
if Rx > 0 && Ry > 0
# Convert neighbors Cartesian index (Rx-1, Ry-1) to the MPI linear index
# Convert neighbors Cartesian index to the MPI linear index
neigh_rank = (Rx-1) + (Ry-1) * Sx
recvdata = @view A[1:2, 1:2]
senddata = @view A[3:4, 3:4]
# recv data: (1:2, 1:2)
recvreqs[1] = MPI.Irecv!(recvdata, neigh_rank, 0, mpicomm)
# send data: (3:4, 3:4)
sendreqs[1] = MPI.Isend(senddata, neigh_rank, 0, mpicomm)
end
# south : (Rx , Ry-1)
if Ry > 0
# Convert neighbors Cartesian index (Rx, Ry-1) to the MPI linear index
# Convert neighbors Cartesian index to the MPI linear index
neigh_rank = (Rx) + (Ry-1) * Sx
recvdata = @view A[xrng, 1:2]
......@@ -215,24 +212,72 @@ function exchangedata!(A, xrng, yrng, mpicomm, Rx, Ry, Sx, Sy)
recvreqs[2] = MPI.Irecv!(recvdata, neigh_rank, 0, mpicomm)
sendreqs[2] = MPI.Isend(senddata, neigh_rank, 0, mpicomm)
end
# Southeast: (Rx+1, Ry-1)
if Ry > 0 && Rx + 1 < Sx
# Convert neighbors Cartesian index (Rx+1, Ry-1) to the MPI linear index
# southeast: (Rx+1, Ry-1)
if Rx + 1 < Sx && Ry > 0
# Convert neighbors Cartesian index to the MPI linear index
neigh_rank = (Rx+1) + (Ry-1) * Sx
# last two values of halo recv
recvdata = @view A[end-1:end, 1:2]
# last two values of real data send
senddata = @view A[xrng[end-1:end], 3:4]
recvreqs[3] = MPI.Irecv!(recvdata, neigh_rank, 0, mpicomm)
sendreqs[3] = MPI.Isend(senddata, neigh_rank, 0, mpicomm)
end
# west : (Rx-1, Ry )
if Rx > 0
# Convert neighbors Cartesian index to the MPI linear index
neigh_rank = (Rx-1) + (Ry) * Sx
recvdata = @view A[1:2, yrng]
senddata = @view A[3:4, yrng]
recvreqs[4] = MPI.Irecv!(recvdata, neigh_rank, 0, mpicomm)
sendreqs[4] = MPI.Isend(senddata, neigh_rank, 0, mpicomm)
end
# east : (Rx+1, Ry )
if Rx+1 < Sx
# Convert neighbors Cartesian index to the MPI linear index
neigh_rank = (Rx+1) + (Ry) * Sx
recvdata = @view A[end-1:end, yrng]
senddata = @view A[xrng[end-1:end], yrng]
recvreqs[5] = MPI.Irecv!(recvdata, neigh_rank, 0, mpicomm)
sendreqs[5] = MPI.Isend(senddata, neigh_rank, 0, mpicomm)
end
# northwest: (Rx-1, Ry+1)
if Rx > 0 && Ry+1 < Sy
# Convert neighbors Cartesian index to the MPI linear index
neigh_rank = (Rx-1) + (Ry+1) * Sx
recvdata = @view A[1:2, end-1:end]
senddata = @view A[3:4, yrng[end-1:end]]
recvreqs[6] = MPI.Irecv!(recvdata, neigh_rank, 0, mpicomm)
sendreqs[6] = MPI.Isend(senddata, neigh_rank, 0, mpicomm)
end
# north : (Rx , Ry+1)
if Ry+1 < Sy
# Convert neighbors Cartesian index to the MPI linear index
neigh_rank = (Rx) + (Ry+1) * Sx
recvdata = @view A[xrng, end-1:end]
senddata = @view A[xrng, yrng[end-1:end]]
recvreqs[7] = MPI.Irecv!(recvdata, neigh_rank, 0, mpicomm)
sendreqs[7] = MPI.Isend(senddata, neigh_rank, 0, mpicomm)
end
# northeast: (Rx+1, Ry+1)
if Rx + 1 < Sx && Ry+1<Sy
# Convert neighbors Cartesian index to the MPI linear index
neigh_rank = (Rx+1) + (Ry+1) * Sx
recvdata = @view A[end-1:end, end-1:end]
senddata = @view A[xrng[end-1:end], yrng[end-1:end]]
recvreqs[8] = MPI.Irecv!(recvdata, neigh_rank, 0, mpicomm)
sendreqs[8] = MPI.Isend(senddata, neigh_rank, 0, mpicomm)
end
MPI.Waitall!(recvreqs)
MPI.Waitall!(sendreqs)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment