Grid
Set
set a variable in a remote parallel compute node
Calling Sequence
Parameters
Description
Examples
Compatibility
Set(v1, v2, ...)
Set(node,v1, v2, ...)
v1
-
can either be a variable name or equation of the form name=value
node
integer
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
anames⁡user
defaultScreenWidth,f
Grid:-Run⁡anames,user
Grid:-Set⁡f
This example shows results from multi-node computations are returned in an array
Grid:-Set⁡0,r=1..5
Grid:-Set⁡1,r=6..10
Grid:-Run⁡0..1,add,i,i=r
After setting variables, it can be useful to run a quick job that prints their value
Grid:-Run⁡0,print,r,wait
1 .. 5
Grid:-Run⁡1,print,r,wait
6 .. 10
Variables that are local in the current scope will be global in the remote node.
p := proc() local loc; Grid:-Set(1,loc=4); Grid:-Run(1,print,["the local variable",loc],'wait'); Grid:-Run(1,print,["the global variable",:-loc],'wait'); end;
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
p⁡
"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:
Grid:-Set⁡1,v=4
Grid:-Run⁡1,print,v,wait
4
Grid:-Set⁡1,v=v
v
The Grid[Set] command was introduced in Maple 2015.
For more information on Maple 2015 changes, see Updates in Maple 2015.
See Also
Grid:-Run
Download Help Document