Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/zeromqinterface/doc/   (Algebra von RWTH Aachen Version 4.15.1©)  Datei vom 20.5.2025 mit Größe 13 kB image not shown  

Quelle  chap3.html   Sprache: HTML

 
 products/Sources/formale Sprachen/GAP/pkg/zeromqinterface/doc/chap3.html


<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>GAP (ZeroMQInterface) - Chapter 3: Using ZeroMQ with the zgap script</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="GAPDoc2HTML" />
<link rel="stylesheet" type="text/css" href="manual.css" />
<script src="manual.js" type="text/javascript"></script>
<script type="text/javascript">overwriteStyle();</script>
</head>
<body class="chap3"  onload="jscontent()">


<div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chapInd.html">Ind</a>  </div>

<div class="chlinkprevnexttop"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap2.html">[Previous Chapter]</a>    <a href="chapInd.html">[Next Chapter]</a>   </div>

<p id="mathjaxlink" class="pcenter"><a href="chap3_mj.html">[MathJax on]</a></p>
<p><a id="X823ACE5A8380FB0D" name="X823ACE5A8380FB0D"></a></p>
<div class="ChapSects"><a href="chap3.html#X823ACE5A8380FB0D">3 <span class="Heading">Using ZeroMQ with the zgap script</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap3.html#X7E80C0DB7D68DA60">3.1 <span class="Heading">Running zgap</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss"> </span><a href="chap3.html#X801F6BAD823982B7">3.2 <span class="Heading">Zgap API</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8551BAF585C80F26">3.2-1 ZExec</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7A8B812C86B04F6F">3.2-2 ZBind</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7F99C0288433A2B2">3.2-3 ZUnbind</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X822FACEA7E675154">3.2-4 ZCall</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X878EFC17847C03F9">3.2-5 ZQuery</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7F4D42487BF9D04D">3.2-6 ZResponse</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X7BC0A3AB859AC0A0">3.2-7 ZTask</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X8334DF718141DE22">3.2-8 ZAsync</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X87623A0F870BF0D9">3.2-9 ZRead</a></span>
<span class="ContSS"><br /><span class="nocss">  </span><a href="chap3.html#X852FCB6F7D337E65">3.2-10 ZReadGapRoot</a></span>
</div></div>
</div>

<h3>3 <span class="Heading">Using ZeroMQ with the zgap script</span></h3>

<p>The <code class="code">zgap</codescript 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><a id="X7E80C0DB7D68DA60" name="X7E80C0DB7D68DA60"></a></p>

<h4>3.1 <span class="Heading">Running zgap</span></h4>

<p>From the shell, run zgap via:</p>


<div class="example"><pre>
bin/zgap -N <nodes> <gap_options> <gap_files>
</pre></div>

<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>


<div class="example"><pre>
bin/zgap -N 4 -P 8 -m 1G common.g
</pre></div>

<p>On NUMA architectures that support the <code class="code">numactl</codecommand, it is possible to further specify which node each worker should be running on. This can take one of two forms:</p>


<div class="example"><pre>
bin/zgap -N <count>:<start>-<end>
bin/zgap -N <count>:+<start>-<end>
</pre></div>

<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>


<div class="example"><pre>
bin/zgap -N 4:+0-3 -P 8 -m 1G common.g
</pre></div>

<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><a id="X801F6BAD823982B7" name="X801F6BAD823982B7"></a></p>

<h4>3.2 <span class="Heading">Zgap API</span></h4>

<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>

<p><a id="X8551BAF585C80F26" name="X8551BAF585C80F26"></a></p>

<h5>3.2-1 ZExec</h5>

<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>

<p><a id="X7A8B812C86B04F6F" name="X7A8B812C86B04F6F"></a></p>

<h5>3.2-2 ZBind</h5>

<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="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">ZBind(ZAll, "counter", 0);</span>
</pre></div>

<p><a id="X7F99C0288433A2B2" name="X7F99C0288433A2B2"></a></p>

<h5>3.2-3 ZUnbind</h5>

<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="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">ZUnbind(ZAll, "status");</span>
</pre></div>

<p><a id="X822FACEA7E675154" name="X822FACEA7E675154"></a></p>

<h5>3.2-4 ZCall</h5>

<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</codein 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="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">ZBind(ZAll, "counter", 0);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ZExec(Zall, "add := function(n) counter := counter + n; end;");</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ZCall(1, "add", [1]);</span>
</pre></div>

<p><a id="X878EFC17847C03F9" name="X878EFC17847C03F9"></a></p>

<h5>3.2-5 ZQuery</h5>

<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="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">res := false;</span>
false
<span class="GAPprompt">gap></span> <span class="GAPinput">ZQuery(1, "ReturnTrue", [], function(x) res := x; end);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">res;</span>
true
</pre></div>

<p><a id="X7F4D42487BF9D04D" name="X7F4D42487BF9D04D"></a></p>

<h5>3.2-6 ZResponse</h5>

<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="example"><pre>
<span class="GAPprompt">gap></span> <span class="GAPinput">resp := ZResponse();;</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">ZQuery(1, "Z", [4], resp.put);</span>
<span class="GAPprompt">gap></span> <span class="GAPinput">resp.get();</span>
Z(2^2)
<span class="GAPprompt">gap></span> <span class="GAPinput">resp.test();</span>
true
</pre></div>

<p><a id="X7BC0A3AB859AC0A0" name="X7BC0A3AB859AC0A0"></a></p>

<h5>3.2-7 ZTask</h5>

<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>, <var class="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>

<p><a id="X8334DF718141DE22" name="X8334DF718141DE22"></a></p>

<h5>3.2-8 ZAsync</h5>

<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>

<p><a id="X87623A0F870BF0D9" name="X87623A0F870BF0D9"></a></p>

<h5>3.2-9 ZRead</h5>

<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>

<p><a id="X852FCB6F7D337E65" name="X852FCB6F7D337E65"></a></p>

<h5>3.2-10 ZReadGapRoot</h5>

<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>

<p> </p>


<div class="chlinkprevnextbot"> <a href="chap0.html">[Top of Book]</a>   <a href="chap0.html#contents">[Contents]</a>    <a href="chap2.html">[Previous Chapter]</a>    <a href="chapInd.html">[Next Chapter]</a>   </div>


<div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chapInd.html">Ind</a>  </div>

<hr />
<p class="foot">generated by <a href="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
</body>
</html>

100%


¤ Dauer der Verarbeitung: 0.19 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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.