Define settings for a local server.
Create a small test environment - This will start 3 nodes locally on this computer.
Note: These nodes are running in a child process of Maple and should be stopped prior to a restart or closing Maple.
The server would normally be started from the script provided in the bin directory that is part of the Grid Computing Toolbox installation.
Determine if the nodes are available.
Define a self-contained procedure containing code that will be executed on each of the nodes.
sampleCode := proc()
uses Grid;
local thisNode, maxNodes, val, i, rply;
thisNode := MyNode();
maxNodes := NumNodes();
print("PID=", kernelopts(pid));
if thisNode <> 0 then
# The other nodes: read input from the Master node
val := Receive(0);
val := val^thisNode;
print(val);
Send(0, val);
else
# This is the master node
# Send something to other nodes
for i from 1 to (maxNodes-1) do
Send(i, (i+10));
od;
rply := 0;
for i from 1 to (maxNodes-1) do
val := Receive(i);
print(val);
rply := rply, val;
od;
return [rply];
fi;
end:
Execute the code on the grid network. The Master Node, node 0, that controls the grid is defined by the Setup command.
Node 0: "PID=", 23461
Node 1: "PID=", 23465
Node 2: "PID=", 23463
Node 2: 144
Node 1: 11
Node 0: 11
Node 0: 144
| |