Created
February 15, 2013 10:52
-
-
Save shriphani/4959681 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 boost.mpi as mpi | |
def test_mpi_init(): | |
if mpi.rank == 0: | |
req = mpi.world.isend(1, 1, 1) | |
print '0 is done' | |
if mpi.rank == 1: | |
req = mpi.world.irecv(0, 1) | |
r = None | |
while r is None: | |
r= req.test() | |
print 'value:', r[0] | |
print 'err', r[1].error | |
print 'cancelled?', r[1].cancelled | |
print 'src:', r[1].source | |
def f(x): | |
print x | |
num_slaves = 2 | |
if mpi.rank == 0: | |
send_req = mpi.RequestList() | |
for i in range(1, num_slaves): | |
print 'sending to', i | |
req = mpi.world.isend(i, 0, i) | |
send_req.append(req) | |
mpi.wait_all(send_req) | |
recv_req = mpi.RequestList() | |
req = None | |
for i in range(1, num_slaves): | |
req = mpi.world.irecv(i, 0) | |
recv_req.append(req) | |
r = False | |
q = False | |
while not q: | |
#r = mpi.test_all(recv_req, f) | |
q = req.test() | |
print q | |
print 'done' | |
else: | |
print 'Hi I am', mpi.rank | |
req = mpi.world.irecv(0,0) | |
r = None | |
while not r: | |
r = req.test() | |
print r[0] | |
req = mpi.world.isend(0, 0, 0) | |
req.wait() | |
print "done from slave" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment