Created
July 13, 2015 12:25
-
-
Save amitmurthy/6a3dda483f2008e2a4b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import MPI | |
function do_sendrecv(N) | |
comm = MPI.COMM_WORLD | |
MPI.Barrier(comm) | |
rank = MPI.Comm_rank(comm) | |
size = MPI.Comm_size(comm) | |
rank ==0 && print("$N : ") | |
dst = rank == 0 ? 1 : 0 | |
tic() | |
for n in 1:10^4 | |
send_mesg = Array(Float64, N) | |
recv_mesg = Array(Float64, N) | |
fill!(send_mesg, Float64(n)) | |
rreq = MPI.Irecv!(recv_mesg, dst, n, comm) | |
#println("$rank: Sending $rank -> $dst = $send_mesg") | |
sreq = MPI.Isend(send_mesg, dst, n, comm) | |
stats = MPI.Waitall!([rreq, sreq]) | |
assert(send_mesg[1] == recv_mesg[1]) | |
#println("$rank: Receiving $src -> $rank = $recv_mesg") | |
end | |
t=toq() | |
rank ==0 && println(t) | |
MPI.Barrier(comm) | |
end | |
function main() | |
MPI.Init() | |
do_sendrecv(1) | |
for i in 1:6 | |
do_sendrecv(10^(i-1)) | |
end | |
MPI.Finalize() | |
end | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment