Close
Close window
Set - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Mozilla Firefox.
Maplesoft logo
Maplesoft logo

Online Help

All Products Maple MapleSim


[フレーム] [フレーム]

Grid

Set

set a variable in a remote parallel compute node

Calling Sequence

Set(v1, v2, ...)

Set(node,v1, v2, ...)

Parameters

v1

-

can either be a variable name or equation of the form name=value

node

-

integer

Description

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.

Examples

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.

>

fxx2

fxx2

(1)
>

anamesuser

defaultScreenWidth,f

(2)
>

Grid:-Runanames,user

,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,⋯ 0 .. 63 Array

(3)
>

Grid:-Setf

>

Grid:-Runanames,user

f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,f,⋯ 0 .. 63 Array

(4)

This example shows results from multi-node computations are returned in an array

>

Grid:-Set0,r=1..5

>

Grid:-Set1,r=6..10

>

Grid:-Run0..1,add,i,i=r

15,40,⋯ 0 .. 1 Array

(5)

After setting variables, it can be useful to run a quick job that prints their value

>

Grid:-Run0,print,r,wait

1 .. 5

>

Grid:-Run1,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;

pproclocalloc;Grid:-Set1,loc=4;Grid:-Run1,print,the local variable,loc,'wait';Grid:-Run1,print,the global variable,:-loc,'wait'end proc

(6)
>

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:-Set1,v=4

>

Grid:-Run1,print,v,wait

4

>

Grid:-Set1,v=v

>

Grid:-Run1,print,v,wait

v

Compatibility

The Grid[Set] command was introduced in Maple 2015.

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

See Also


Download Help Document

AltStyle によって変換されたページ (->オリジナル) /