Skip to content

Instantly share code, notes, and snippets.

@amitmurthy
Created July 13, 2015 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save amitmurthy/50aaa18bb65487773fa4 to your computer and use it in GitHub Desktop.
Save amitmurthy/50aaa18bb65487773fa4 to your computer and use it in GitHub Desktop.
addprocs(1)
const rr1=RemoteRef()
const rr2=RemoteRef(2)
@everywhere function do_sendrecv(N, rr1, rr2)
myid() == 1 && print("$N : ")
if myid() == 1
rr_put = rr2
rr_take = rr1
else
rr_put = rr1
rr_take = rr2
end
tic()
for n in 1:10^4
@async put!(rr_put, fill(Float64(myid()), N))
take!(rr_take)
end
t=toq()
myid() == 1 && println(t)
end
@spawnat 2 do_sendrecv(1, rr1, rr2)
do_sendrecv(1, rr1, rr2)
function main()
for i in 1:6
@spawnat 2 do_sendrecv(10^(i-1), rr1, rr2)
do_sendrecv(10^(i-1), rr1, rr2)
end
end
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment