set a variable in a remote parallel compute node
Set(v1, v2, ...)
Set(node,v1, v2, ...)
can either be a variable name or equation of the form name=value
The Set command sets variables in remote parallel compute nodes.
The Grid package provides routines for multiprocess parallelism. Each compute node runs a separate Maple process that does not share state with the main interactive Maple session. That means that a variable assigned in the main interactive session, say, a:=1 will not be automatically propagated to the remote compute nodes. The Set command provides a way to assign variables copying state from the current session to the remote session.
Calling Set(0,'a'=42) will assign the variable a the value 42 on node 0. If a is already assigned 42 in the local session, this command can be shortened to Set(0,'a'). Leaving the node number off, Set('a') will cause the same value of a to be assigned on all compute nodes.
The Set command is only available in local Grid mode.
This example uses the anames command to list all active variables. Note that until Grid:-Set is run, the compute nodes don't know about the variable f.
f ≔ x→x2
This example shows results from multi-node computations are returned in an array
After setting variables, it can be useful to run a quick job that prints their value
1 .. 5
6 .. 10
Variables that are local in the current scope will be global in the remote node.
p := proc()
Grid:-Run(1,print,["the local variable",loc],'wait');
Grid:-Run(1,print,["the global variable",:-loc],'wait');
p ≔ proclocalloc;Grid:-Set⁡1,loc=4;Grid:-Run⁡1,print,the local variable,loc,'wait';Grid:-Run⁡1,print,the global variable,:-loc,'wait'end proc
"the local variable", 4
"the global variable", loc
A common way to unassign variables is to use the syntax var = 'var'. Because there are two evaluations happening (once in the call to Set, and once on the remote node), two uneval quotes are needed:
The Grid[Set] command was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
Download Help Document