Skip to content

Commit

Permalink
Avoid GPU synchronization in serial MPI runs
Browse files Browse the repository at this point in the history
  • Loading branch information
lcw committed Aug 6, 2024
1 parent 2142cfd commit 3bc64fe
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions src/communication.jl
Original file line number Diff line number Diff line change
Expand Up @@ -299,21 +299,38 @@ function progress(::AbstractCommManager)
end

function start!(A, cm::CommManagerBuffered)
setbuffer!(cm.sendbufferdevice, A, cm.pattern.sendindices)
KernelAbstractions.synchronize(get_backend(cm))
if !isempty(cm.sendrequests)
setbuffer!(cm.sendbufferdevice, A, cm.pattern.sendindices)
end

if !isempty(cm.sendrequests) || !isempty(cm.recvrequests)
KernelAbstractions.synchronize(get_backend(cm))
end

if !isempty(cm.recvrequests)
MPI.Startall(cm.recvrequests)
end

MPI.Startall(cm.recvrequests)
MPI.Startall(cm.sendrequests)
if !isempty(cm.sendrequests)
MPI.Startall(cm.sendrequests)
end

return
end

function finish!(A, cm::CommManagerBuffered)
MPI.Waitall(cm.recvrequests)
MPI.Waitall(cm.sendrequests)
if !isempty(cm.recvrequests)
MPI.Waitall(cm.recvrequests)
end

if !isempty(cm.sendrequests)
MPI.Waitall(cm.sendrequests)
end

A = viewwithghosts(A)
getbuffer!(A, cm.recvbufferdevice, cm.pattern.recvindices)
if !isempty(cm.recvrequests)
A = viewwithghosts(A)
getbuffer!(A, cm.recvbufferdevice, cm.pattern.recvindices)
end

return
end
Expand Down

0 comments on commit 3bc64fe

Please sign in to comment.