Exemplo n.º 1
0
def irecv(  source=core.MPI_ANY_SOURCE,
            tag=core.MPI_ANY_TAG,
            comm=core.MPI_COMM_WORLD ):
    """
    message,request = comm.recv( [destination(defaults to ANY_SOURCE), tag(defaults to ANY_TAG)])
    if( test(request) ):
    print 'Received message:', message
    
    
    Receives a message from any source and tag by default, or from specified source
    and tag.
    
    This is a NON-Blocking receive, meaning this process will not wait for the data if it is not
    yet ready.  The call will return immediately and you will want to call wait or test on
    the request object before actually using the 'message' object returned by this call.
    
    This method receives messages as arrays of characters.
    This method trades efficency for generality: i.e. It takes extra time and bandwidth
    to serialize and transmit the serialized object.  However, any Python object
    that can be Pickled can be received.
    
    Currently this method uses the python pickle module(rather then cPickle).
    """
    core.probe( source, tag, WORLD )
    count = core.get_count( core.MPI_CHAR )
    req, data = request.irecv( count, core.MPI_CHAR, source, tag, comm )
    message = pickle.loads( data )
    return message,req
Exemplo n.º 2
0
    def recv(self, source=ANY_SOURCE, tag=ANY_TAG):
        """
        message = comm.recv( [destination(defaults to ANY_SOURCE), tag(defaults to ANY_TAG)])

        Receives a message from any source and tag by default, or from specified source
        and tag.

        This method receives messages as arrays of characters.
        This method trades efficency for generality: i.e. It takes extra time and bandwidth
        to serialize and transmit the serialized object.  However, any Python object
        that can be Pickled can be received.

        Currently this method uses the python pickle module(rather then cPickle).
        """
        core.probe(source, tag, WORLD)
        count = core.get_count(core.MPI_CHAR)
        data = core.recv(count, core.MPI_CHAR, source, tag, self.id)
        message = pickle.loads(data)
        return message