 MyNode - Maple Help

Grid

 MyNode
 query my node number Calling Sequence MyNode() Description

 • The MyNode command is for use 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. MyNode() returns the integer identifier for the node that it is called on. Examples

 > who := proc()    uses Grid;    local me,i;    me := MyNode();    if me = 0 then        return [0, seq(Receive(),i=1..NumNodes()-1)];    else        Send(0,me);    end if; end proc;
 ${\mathrm{who}}{≔}{\mathbf{proc}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{me}}{,}{i}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{me}}{≔}{\mathrm{Grid}}{:-}{\mathrm{MyNode}}{}\left({}\right){;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{me}}{=}{0}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{then}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{return}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\left[{0}{,}{\mathrm{seq}}{}\left({\mathrm{Grid}}{:-}{\mathrm{Receive}}{}\left({}\right){,}{i}{=}{1}{..}{\mathrm{Grid}}{:-}{\mathrm{NumNodes}}{}\left({}\right){-}{1}\right)\right]\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{else}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{Grid}}{:-}{\mathrm{Send}}{}\left({0}{,}{\mathrm{me}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (1)
 > $r≔\mathrm{Grid}:-\mathrm{Launch}\left(\mathrm{who},\mathrm{numnodes}=8\right)$
 ${r}{≔}\left[{0}{,}{1}{,}{2}{,}{3}{,}{4}{,}{5}{,}{6}{,}{7}\right]$ (2)
 > $\mathrm{sort}\left(r\right)$
 $\left[{0}{,}{1}{,}{2}{,}{3}{,}{4}{,}{5}{,}{6}{,}{7}\right]$ (3) Compatibility

 • The Grid[MyNode] command was introduced in Maple 15.