Skip to content

Instantly share code, notes, and snippets.

@AStupidBear
Forked from amitmurthy/put_take.jl
Created February 1, 2017 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AStupidBear/e871355878bd7779c9eb16334f72142e to your computer and use it in GitHub Desktop.
Save AStupidBear/e871355878bd7779c9eb16334f72142e 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