Exemplo n.º 1
0
print "Creating Data Array..."
data = Numeric.array( [1,2,3,4], Numeric.Int32 )

print "Initializing MPI: (%s,%s)"%(len(sys.argv),sys.argv)
try:
    rank, size = mpi.init( len(sys.argv), sys.argv )
    print "(%s,%s): initialized..." %(rank,size)

    if( rank == 0 ):
        print "(%s,%s): sending: %s" %( rank, size, data )
        request = mpi.isend( data, 4, mpi.MPI_INT, 1, 0, mpi.MPI_COMM_WORLD )
        print "(%s,%s): request#: %s" %( rank, size, request )
        data2 = Numeric.array([ -1, -1, -1, -1 ], Numeric.Int32 )
        print "(%s,%s): testing status of request#(%s):"%(rank,size,request)
        print "(%s,%s): waiting:"%(rank,size)
        request2 = mpi.wait(request)
        print "(%s,%s): request# after wait: %s" %(rank,size,request2)
        sys.stdout.flush()
    elif( rank == 1):
        print "(%s,%s): receiving..." %(rank,size)
        data2 = mpi.recv( 4, mpi.MPI_INT, 0, 0, mpi.MPI_COMM_WORLD )
        print "(%s,%s): received: %s" % ( rank, size, data2 )
    else:
        pass
    mpi.finalize()
    sys.stdout.flush()
except:
    mpi.finalize()
    sys.stdout.flush()
    raise 
Exemplo n.º 2
0
import sys
import Numeric
import mpi

try:
    rank,size = mpi.init( len(sys.argv), sys.argv )

    request,buffer = mpi.irecv( 10, mpi.MPI_INT, 0, 0, mpi.MPI_COMM_WORLD )

    print "Request #: %s"%(request)
    print "buffer: %s"%(buffer)

    A = Numeric.array([1,2,3,4,5,6,7,8,9,10],Numeric.Int32)
    send_request = mpi.isend( A, 10, mpi.MPI_INT, 0, 0, mpi.MPI_COMM_WORLD )
    print "Sending Request: %s"%(send_request)
    status = mpi.wait( request )
    status = mpi.wait( send_request )
    print "buffer(after send): %s"%(buffer)
    print "status:",status
    mpi.finalize()
except:
    mpi.finalize()
    raise