receive a message sent from another node
(optional) integer, identifying the node that the message is coming from
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.
fib := proc()
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
# wait for a message to come back
# 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]] );
fib ≔ proclocalme,msg,n,dest;me ≔ Grid:-MyNode⁡;n ≔ Grid:-NumNodes⁡;dest ≔ me+1modn;ifme=0thenmsg ≔ 1,1;Grid:-Send⁡dest,msg;returnGrid:-Receive⁡elsemsg ≔ Grid:-Receive⁡me − 1;Grid:-Send⁡dest,op⁡msg,msg[−1]+msg[−2]end ifend proc
The Grid[Receive] command was introduced in Maple 15.
For more information on Maple 15 changes, see Updates in Maple 15.
Download Help Document