Receive - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Grid

  

Receive

  

receive a message sent from another node

 

Calling Sequence

Parameters

Description

Examples

Compatibility

Calling Sequence

Receive()

Receive(node)

Parameters

node

-

(optional) integer, identifying the node that the message is coming from

Description

• 

The Send command is for use within the Maple code executed as part of a parallel computation.

• 

When a parallel job is started on a specified number of servers, say N, each server will be given an integer identifier between 0 and N-1 for the duration of this computation. The node parameter specifies the integer identifier of the node that we expect a message to arrive from.

• 

The Receive command will block until a message arrives from the specified node. If no node is specified, Receive will return the first message sent to it from any node.

• 

Note that you can create deadlock situations when all nodes are either done with their computation or still waiting to receive a message. Such deadlocks will be detected and the job will be automatically aborted.

Examples

fib := proc()
    uses Grid;
    local me, msg, n, dest;

    me := MyNode():
    n  := NumNodes():
    dest := me+1 mod n:
    if me=0 then
        # create a message
        msg := [1,1];
        # send it on to node number 1
        Send(dest, msg);
        # wait for a message to come back
        return Receive();
    else
        # wait for a message to arrive
        msg := Receive(me-1);
        # add to the sequence and send it on to the next node
        Send(dest, [op(msg),msg[-1]+msg[-2]] );
    end if;
end proc;

fibproclocalme,msg,n,dest;meGrid:-MyNode;nGrid:-NumNodes;destme+1modn;ifme=0thenmsg1,1;Grid:-Senddest,msg;returnGrid:-ReceiveelsemsgGrid:-Receiveme1;Grid:-Senddest,opmsg,msg[−1]+msg[−2]end ifend proc

(1)

Grid:-Launchfib,numnodes=8

1,1,2,3,5,8,13,21,34

(2)

Compatibility

• 

The Grid[Receive] command was introduced in Maple 15.

• 

For more information on Maple 15 changes, see Updates in Maple 15.

See Also

Grid

Grid[Send]

Grid[Setup]