Interrupt - Maple Help

Grid

 Interrupt
 interrupt computation on a specified node

 Calling Sequence Interrupt() Interrupt(node)

Parameters

 node - integer, identifying the node to interrupt

Description

 • The Interrupt command causes the computation running on the specified external node to be terminated. Interrupts can be initiated from compute nodes.
 • The node parameter is the specific node as determined by MyNode in the external process. For a description of node numbers, see Grid:-MyNode.
 • The no-argument version of Interrupt can be used in the main thread to terminate jobs started by the Grid:-Run command.
 • Node 0 cannot be interrupted on a job initiated by the Launch command because that would terminate the whole parallel job.
 • A node also cannot interrupt itself.
 • Note that interrupting a node can cause a deadlock if other nodes are blocked, waiting for a message to arrive from the interrupted node. Such deadlocks will be detected and the job will be automatically aborted.
 • The Interrupt command is not implemented when running the Grid package in "mpi" mode.  It can be called but does nothing.
 • This function is part of the Grid package, so it can be used in the short form Interrupt(..) only after executing the command with(Grid). However, it can always be accessed through the long form of the command by using Grid[Interrupt](..).

Examples

 > p := proc()     uses Grid;     local i;     if MyNode()=0 then        Receive(); # wait for a message     elif MyNode()=1 then        # interrupt everybody else        for i from 2 to NumNodes()-1 do           Interrupt(i);        end do;        # notify node 0        Grid:-Util:-Send(0, true);     else        # all other nodes are in an infinite loop        while true do end do;     end if; end proc;
 ${p}{≔}{\mathbf{proc}}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{local}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{i}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{Grid}}{:-}{\mathrm{MyNode}}{}\left({}\right){=}{0}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{then}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{Grid}}{:-}{\mathrm{Receive}}{}\left({}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{elif}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{Grid}}{:-}{\mathrm{MyNode}}{}\left({}\right){=}{1}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{then}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{for}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{i}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{from}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{2}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{to}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{Grid}}{:-}{\mathrm{NumNodes}}{}\left({}\right){-}{1}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{do}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{Grid}}{:-}{\mathrm{Interrupt}}{}\left({i}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end do}}{;}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathrm{Grid}}{:-}{\mathrm{Util}}{:-}{\mathrm{Send}}{}\left({0}{,}{\mathrm{true}}\right)\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{else}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{do}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end do}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end if}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}{\mathbf{end proc}}$ (1)
 > $\mathrm{Grid}:-\mathrm{Launch}\left(3,p\right)$
 ${\mathrm{true}}$ (2)

Compatibility

 • The Grid[Interrupt] command was introduced in Maple 15.
 • For more information on Maple 15 changes, see Updates in Maple 15.
 • The Grid[Interrupt] command was updated in Maple 2015.