<h3>3 <span class="Heading">Using ZeroMQ with the zgap script</span></h3>
<p>The <code class="code">zgap</code> script provides facilities to start a number of child processes controlled by a single master process and to allow for easy coordination between them.</p>
<p>Here, <code class="code">nodes</code> should be a positive integer that describes the number of workers one wishes to start. The rest of the command line, consisting of gap options and gap files, will be passed to the master and the worker processes verbatim. This allows, for example, the initialization of functions that need to be known by all workers. The first line of output will be prefixed with <code class="code">[zgap]</code> and will list the directory where <code class="code">zgap</code> will store the files and sockets it uses to communicate. In particular, the <code class="code">logXX.txt</code> files within that directory will contain the output generated by the workers; this is useful for debugging, as the workers do not have a working break loop. Example:</p>
<p>On NUMA architectures that support the <code class="code">numactl</code> command, it is possible to further specify which node each worker should be running on. This can take one of two forms:</p>
<p>Each will distribute <code class="code">count</code> worker processes on the physical nodes ranging from <code class="code">start</code> to <code class="code">end</code> in a round-robin fashion, reusing nodes if there are more workers than nodes. The first mode (without a <code class="code">+</code> sign) will use absolute node numbers, the second will be relative to the master process. See the <code class="code">numactl</code> manual page for further details. Example:</p>
<p>Note: Currently, <code class="code">zgap</code> can only be run from the GAP root directory. This is an implementation restriction that is to be removed at a later date.</p>
<p>Most of the following API functions take a <code class="code">dest</code> argument, which is used to specify the destination of the operation. To specify a worker thread, <code class="code">dest</code> would have to be an integer in the range from 1 to the number of worker processes; 0 specifies the master process. Multiple processes can be specified by a range or list of integers. The variable <code class="code">ZAll</code> contains a range encompassing the worker processes; <code class="code">ZSelf</code> contains the index of the current worker or 0 for the master.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ZExec</code>( <var class="Arg">dest</var>, <var class="Arg">cmd</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function sends <code class="code">cmd</code> to the given destination and executes it there. The command must be a valid GAP statement ending in a semicolon. If <code class="code">dest</code> specifies multiple processes, the command will be executed on all of them.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ZBind</code>( <var class="Arg">dest</var>, <var class="Arg">var</var>, <var class="Arg">expr</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function binds the global variable described by the string <code class="code">var</code> to the value <code class="code">expr</code> in all processes listed in <code class="code">dest</code>. Note that <code class="code">expr</code> must evaluate to a serializable value.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ZUnbind</code>( <var class="Arg">dest</var>, <var class="Arg">var</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function is the counterpart to <code class="code">ZBind</code>. It will unbind <code class="code">var</code> in all specified processes.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ZCall</code>( <var class="Arg">dest</var>, <var class="Arg">func</var>, <var class="Arg">args</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function will execute the function specified by the string <code class="code">func</code> in the specified processes. The string <code class="code">func</code> must be the name of a global variable referring to the function to be executed. This function should be created at startup by adding a file to the commandline that defines it in all workers or by <code class="code">ZExec</code>.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ZQuery</code>( <var class="Arg">dest</var>, <var class="Arg">func</var>, <var class="Arg">args</var>, <var class="Arg">callback</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function works like <code class="code">ZCall</code>, except that any return value will be passed to the callback function.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ZResponse</code>( )</td><td class="tdright">( function )</td></tr></table></div>
<p><code class="code">ZResponse</code> is a convenience function to construct blocking callbacks for <code class="code">ZCall</code> and <code class="code">ZTask</code>. It returns a record containing a <code class="code">put</code>, a <code class="code">get</code>, and a <code class="code">test</code> function. Here, <code class="code">put</code> is passed as the callback; <code class="code">get</code> can be used to read the returned value; and <code class="code">test</code> can be used to test for the presence of a value.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ZTask</code>( <var class="Arg">dest</var>, <var class="Arg">func</var>, <var class="Arg">args</var>, <varclass="Arg">callback</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function works like <code class="code">ZQuery</code>, except that the function will be executed via a task and <code class="code">callback</code> will be called after the task finishes and returns a result.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ZAsync</code>( <var class="Arg">dest</var>, <var class="Arg">func</var>, <var class="Arg">args</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function works like <code class="code">ZCall</code>, except that the function will be executed via a task.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ZRead</code>( <var class="Arg">dest</var>, <var class="Arg">file</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function does a <code class="code">Read(file)</code> for all specified processes.</p>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">‣ ZReadGapRoot</code>( <var class="Arg">dest</var>, <var class="Arg">file</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>This function does a <code class="code">ReadGapRoot(file)</code> for all specified processes.</p>
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.15Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.