[Swift-commit] r8228 - www/Swift-T
wozniak at ci.uchicago.edu
wozniak at ci.uchicago.edu
Fri Aug 22 15:04:29 CDT 2014
Author: wozniak
Date: 2014-08-22 15:17:00 -0500 (Fri, 22 Aug 2014)
New Revision: 8228
Modified:
www/Swift-T/guide.html
Log:
Fix @prio 2
Modified: www/Swift-T/guide.html
===================================================================
--- www/Swift-T/guide.html 2014-08-22 20:15:08 UTC (rev 8227)
+++ www/Swift-T/guide.html 2014-08-22 20:17:00 UTC (rev 8228)
@@ -1,415 +1,1276 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
+ "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
+<meta name="generator" content="AsciiDoc 8.6.3" />
+<title>Swift/T Guide</title>
+<style type="text/css">
+/* Sans-serif font. */
+h1, h2, h3, h4, h5, h6,
+div.title, caption.title,
+thead, p.table.header,
+div#toctitle,
+span#author, span#revnumber, span#revdate, span#revremark,
+div#footer {
+ font-family: Arial,Helvetica,sans-serif;
+}
-////
-Swift/T guide, asciidoc format
-http://www.mcs.anl.gov/exm/local/guides/stc.html
-////
+/* Serif font. */
+div.sectionbody {
+ font-family: Georgia,"Times New Roman",Times,serif;
+}
-:toc:
-:numbered:
+/* Monospace font. */
+tt {
+ font-size: inherit;
+}
-////
-Settings:
-////
-:miscellaneous.newline: \n
+body {
+ margin: 1em 5% 1em 5%;
+}
-= Swift/T Guide
-v0.6.1, July 2014
+a {
+ color: blue;
+ text-decoration: underline;
+}
+a:visited {
+ color: fuchsia;
+}
-The Swift/Turbine Compiler (STC) allows you to write Swift programs
-and run them using Turbine.
+em {
+ font-style: italic;
+ color: navy;
+}
-== Support
+strong {
+ font-weight: bold;
+ color: #083194;
+}
-An overview of Swift/T may be found at the ExM project site:
+tt {
+ font-size: inherit;
+ color: navy;
+}
-https://sites.google.com/site/exmcomputing
+h1, h2, h3, h4, h5, h6 {
+ color: #527bbd;
+ margin-top: 1.2em;
+ margin-bottom: 0.5em;
+ line-height: 1.3;
+}
-The Swift/T user discussion mailing list is found here:
+h1, h2, h3 {
+ border-bottom: 2px solid silver;
+}
+h2 {
+ padding-top: 0.5em;
+}
+h3 {
+ float: left;
+}
+h3 + * {
+ clear: left;
+}
-http://lists.mcs.anl.gov/mailman/listinfo/exm-user
+div.sectionbody {
+ margin-left: 0;
+}
-== Installation
-Writing and running Swift/Turbine programs requires multiple packages.
-This section provides generic instructions for installing Swift/T
-on a range of systems. We first cover locating and/or installing
-prerequisite software packages, then we cover building Swift/T
-from a source package.
+hr {
+ border: 1px solid silver;
+}
-The link:turbine-sites.html[Turbine Sites Guide]
-is a accompanying resource for configuration settings and preinstalled software
-for specific systems.
+p {
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+}
-=== Installation of Prerequisites
+ul, ol, li > p {
+ margin-top: 0;
+}
+ul > li { color: #aaa; }
+ul > li > * { color: black; }
-1. Install or locate MPI implementation (MPICH, OpenMPI, etc.)
-+
-** On compute clusters, an MPI will almost certainly be pre-installed
-** Many operating systems provide packages with MPI implementations
- that are usable, but often outdated.
- E.g. the +mpich2+ package on Debian/Ubuntu.
-** See http://www.mpich.org[MPICH Guides] for information on installing the
- latest version of MPICH.
-** Other MPI implementations are <<Build_configuration, supported>> as well.
-+
-Swift/T attempts to use MPI 3.0 functionality by default. If you
-are using an MPI implementation that does not support the MPI 3.0 standard,
-you must set +MPI_VERSION=2+ (if using the +exm-setup.zsh+ build process),
-or provide the +--enable-mpi-2+ configure option (if using
-the manual build process).
-+
-2. Install or locate Tcl 8.6.
-+
-* Tcl is available through the package manager on many systems.
- You may need to install an additional Tcl development package
- in addition to the standard tcl package,
- e.g. +tcl8.6+ plus +tcl8.6-dev+ on Debian/Ubuntu systems.
-* Source distributions are available at the http://www.tcl.tk[Tcl web site]
-+
-3. Install or locate SWIG
-+
-* You can check if SWIG is installed by running +swig -version+
-* SWIG is available through the package manager on many systems.
-* Source distributions are available at
- the http://swig.org[SWIG web site]
+pre {
+ padding: 0;
+ margin: 0;
+}
-=== Installation of Swift/T from Source
+span#author {
+ color: #527bbd;
+ font-weight: bold;
+ font-size: 1.1em;
+}
+span#email {
+}
+span#revnumber, span#revdate, span#revremark {
+}
-Once you have found all prerequisites, we can continue with building
-Swift/T from source.
+div#footer {
+ font-size: small;
+ border-top: 2px solid silver;
+ padding-top: 0.5em;
+ margin-top: 4.0em;
+}
+div#footer-text {
+ float: left;
+ padding-bottom: 0.5em;
+}
+div#footer-badges {
+ float: right;
+ padding-bottom: 0.5em;
+}
-1. Obtain the Swift/T source package
-+
-----
-wget http://www.mcs.anl.gov/exm/local/downloads/exm-0.5.0.tar.gz
-----
-+
-Cf. http://www.mcs.anl.gov/exm/local/downloads/downloads.html[Swift/T Downloads]
-for other packages
-+
-2. Unpack and enter package directory
-+
-----
-tar xfz exm-trunk.tar.gz
-cd exm-trunk
-----
-+
-3. Edit the settings file: +exm-settings.sh+
-+
-At a minimum, you must set the install directory with +EXM_PREFIX+.
-On a standard system, no further configuration may be needed.
-In many cases, however, you will need to modify additional
-configuration settings so that all prerequisites can
-be correctly located and configured (see Section
-<<Build_configuration, Build configuration>>).
-+
-A range of other settings are also available here:
-enabling/disabling features, debug or optimized builds, etc.
-+
-TIP: Save your +exm-settings.sh+ when you download a new package
-+
-4. Run the setup script
-+
-----
-./exm-setup.zsh
-----
-+
-If +exm-setup.zsh+ does not succeed on your system, see Section
-<<Build_configuration, Build configuration>> below.
-+
-TIP: if you want more control than +exm-setup.zsh+ provides, you can
- build Swift/T with the
- <<Manual_build_configuration, manual configure/make workflow>>.
-+
-5. Add Turbine and STC to your paths
-+
-----
-PATH=${PATH}:/path/to/exm-install/turbine/bin
-PATH=${PATH}:/path/to/exm-install/stc/bin
-----
+div#preamble {
+ margin-top: 1.5em;
+ margin-bottom: 1.5em;
+}
+div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
+div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
+div.admonitionblock {
+ margin-top: 1.0em;
+ margin-bottom: 1.5em;
+}
+div.admonitionblock {
+ margin-top: 2.0em;
+ margin-bottom: 2.0em;
+ margin-right: 10%;
+ color: #606060;
+}
-== Usage
+div.content { /* Block element content. */
+ padding: 0;
+}
-Swift code is conventionally written in +\*.swift+ files. Turbine
-code is stored in Tcl files +*.tcl+. After writing the Swift program
-+program.swift+, run:
-----
-stc program.swift
-----
+/* Block element titles. */
+div.title, caption.title {
+ color: #527bbd;
+ font-weight: bold;
+ text-align: left;
+ margin-top: 1.0em;
+ margin-bottom: 0.5em;
+}
+div.title + * {
+ margin-top: 0;
+}
-This will compile the program to +program.tcl+. A second, optional
-argument may be given as an alternate output file name.
+td div.title:first-child {
+ margin-top: 0.0em;
+}
+div.content div.title:first-child {
+ margin-top: 0.0em;
+}
+div.content + div.title {
+ margin-top: 0.0em;
+}
-Then, to run the program, use Turbine:
+div.sidebarblock > div.content {
+ background: #ffffee;
+ border: 1px solid #dddddd;
+ border-left: 4px solid #f0f0f0;
+ padding: 0.5em;
+}
-----
-turbine -n 4 program.tcl
-----
+div.listingblock > div.content {
+ border: 1px solid #dddddd;
+ border-left: 5px solid #f0f0f0;
+ background: #f8f8f8;
+ padding: 0.5em;
+}
-See the <<Turbine,Turbine section>> for more information about
-running the program.
+div.quoteblock, div.verseblock {
+ padding-left: 1.0em;
+ margin-left: 1.0em;
+ margin-right: 10%;
+ border-left: 5px solid #f0f0f0;
+ color: #777777;
+}
-[[stc_arguments]]
-STC accepts the following arguments:
+div.quoteblock > div.attribution {
+ padding-top: 0.5em;
+ text-align: right;
+}
-+-A _name_=_value_+:: Set a command-line argument at
-compile-time. This may be found at runtime using the Swift
-<<argv,argument processing>> library. This option enables these
-arguments to be treated as compile-time constants for optimization.
-+-D _macro_=_value_+:: Define a C preprocessor macro.
-+-E+:: Just run the C preprocessor: do not compile the program. The
-output goes into the STC output file (the second file name argument).
-+-I+:: Add a directory to the import and include search path.
-+-O+:: Set optimization level: 0, 1, 2, or 3. See <<Optimizations>>.
-+-j+:: Set the location of the +java+ executable.
-+-p+:: Disable the C preprocessor.
-+-u+:: Only compile if output file is not up-to-date.
-+-v+:: Output version number and exit.
-+-V+:: Verbose output.
+div.verseblock > pre.content {
+ font-family: inherit;
+ font-size: inherit;
+}
+div.verseblock > div.attribution {
+ padding-top: 0.75em;
+ text-align: left;
+}
+/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
+div.verseblock + div.attribution {
+ text-align: left;
+}
-STC runs as a Java program. You may use +-j+ to set the Java VM
-executable. This Java VM must be compatible with the +javac+ used to
-compile STC.
+div.admonitionblock .icon {
+ vertical-align: top;
+ font-size: 1.1em;
+ font-weight: bold;
+ text-decoration: underline;
+ color: #527bbd;
+ padding-right: 0.5em;
+}
+div.admonitionblock td.content {
+ padding-left: 0.5em;
+ border-left: 3px solid #dddddd;
+}
-By default, STC runs the user script through the C preprocessor
-(+cpp+), enabling arbitrary macro processing, etc. The +-D+, +-E+,
-+-I+, and +-p+ options are relevant to this feature.
+div.exampleblock > div.content {
+ border-left: 3px solid #dddddd;
+ padding-left: 0.5em;
+}
-Additional arguments for advanced users/developers:
+div.imageblock div.content { padding-left: 0; }
+span.image img { border-style: none; }
+a.image:visited { color: white; }
-+-C+:: Specify an output file for STC internal representation
-+-l+:: Specify log file for STC debug log
-+-L+:: Specify log file for more verbose STC debug log
-+-T+:: Enable a specific optimization. See <<Optimizations>>
-+-t+:: Disable a specific compiler optimization. See <<Optimizations>>
+dl {
+ margin-top: 0.8em;
+ margin-bottom: 0.8em;
+}
+dt {
+ margin-top: 0.5em;
+ margin-bottom: 0;
+ font-style: normal;
+ color: navy;
+}
+dd > *:first-child {
+ margin-top: 0.1em;
+}
-== Program structure
+ul, ol {
+ list-style-position: outside;
+}
+ol.arabic {
+ list-style-type: decimal;
+}
+ol.loweralpha {
+ list-style-type: lower-alpha;
+}
+ol.upperalpha {
+ list-style-type: upper-alpha;
+}
+ol.lowerroman {
+ list-style-type: lower-roman;
+}
+ol.upperroman {
+ list-style-type: upper-roman;
+}
-Swift programs are composed of _composite_ functions. These
-share syntax with C-like languages. The program starts in +main()+.
-The following is a complete Swift program:
+div.compact ul, div.compact ol,
+div.compact p, div.compact p,
+div.compact div, div.compact div {
+ margin-top: 0.1em;
+ margin-bottom: 0.1em;
+}
-----
-main
-{}
-----
+div.tableblock > table {
+ border: 3px solid #527bbd;
+}
+thead, p.table.header {
+ font-weight: bold;
+ color: #527bbd;
+}
+tfoot {
+ font-weight: bold;
+}
+td > div.verse {
+ white-space: pre;
+}
+p.table {
+ margin-top: 0;
+}
+/* Because the table frame attribute is overriden by CSS in most browsers. */
+div.tableblock > table[frame="void"] {
+ border-style: none;
+}
+div.tableblock > table[frame="hsides"] {
+ border-left-style: none;
+ border-right-style: none;
+}
+div.tableblock > table[frame="vsides"] {
+ border-top-style: none;
+ border-bottom-style: none;
+}
-STC input is preprocessed by +cpp+, the C preprocessor.
-Hello world is written as:
+div.hdlist {
+ margin-top: 0.8em;
+ margin-bottom: 0.8em;
+}
+div.hdlist tr {
+ padding-bottom: 15px;
+}
+dt.hdlist1.strong, td.hdlist1.strong {
+ font-weight: bold;
+}
+td.hdlist1 {
+ vertical-align: top;
+ font-style: normal;
+ padding-right: 0.8em;
+ color: navy;
+}
+td.hdlist2 {
+ vertical-align: top;
+}
+div.hdlist.compact tr {
+ margin: 0;
+ padding-bottom: 0;
+}
-----
-import io;
-main
-{
- printf("Hello world");
+.comment {
+ background: yellow;
}
-----
-The newline is supplied by +printf()+.
+.footnote, .footnoteref {
+ font-size: 0.8em;
+}
-Swift programs eventually call _leaf_ functions, which are the primary
-way to do work. From the perspective of the Swift script, they are
-atomic operations that wait for input variables and set output
-variables. They may be implemented as native code functions or
-external application programs.
+span.footnote, span.footnoteref {
+ vertical-align: super;
+}
-== Comments
+#footnotes {
+ margin: 20px 0 20px 0;
+ padding: 7px 0 0 0;
+}
-Swift supports C/C++-style comments:
+#footnotes div.footnote {
+ margin: 0 0 5px 0;
+}
-----
-// This is a comment
-/* This is a
-comment */
-/** Also a
-comment */
-----
+#footnotes hr {
+ border: none;
+ border-top: 1px solid silver;
+ height: 1px;
+ text-align: left;
+ margin-left: 0;
+ width: 20%;
+ min-width: 100px;
+}
-Additionally, if the preprocessor is disabled, single-line comments
-starting with # are supported:
-----
-# This will work if source file is not preprocessed
-----
+div.colist td {
+ padding-right: 0.5em;
+ padding-bottom: 0.3em;
+ vertical-align: top;
+}
+div.colist td img {
+ margin-top: 0.3em;
+}
-== Modules
+ at media print {
+ div#footer-badges { display: none; }
+}
-Swift has a module system that allows you to import function and variable
-definitions into your source file. Importing a module will import all
-function and variable definitions from that module into your program.
-----
-import io;
-import mypackage.mymodule;
-----
+div#toc {
+ margin-bottom: 2.5em;
+}
-The mechanisms for locating source files is as follows:
+div#toctitle {
+ color: #527bbd;
+ font-size: 1.1em;
+ font-weight: bold;
+ margin-top: 1.0em;
+ margin-bottom: 0.1em;
+}
-* STC searches a list of directories in order to find a Swift source
- file in the correct directory with the correct name.
-* The standard library is always first on the search path,
- and the current working directory is last.
-* Additional directories can be added with the +-I+ option to STC.
-* Swift source files must have a +.swift+ suffix. E.g. +import io;+
- looks for a file called +io.swift+.
-* In the case of a multi-part import name, E.g. +import mypackage.mymodule+,
- then, it looks for +mymodule.swift+ in subdirectory +mypackage+.
+div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+div.toclevel2 {
+ margin-left: 2em;
+ font-size: 0.9em;
+}
+div.toclevel3 {
+ margin-left: 4em;
+ font-size: 0.9em;
+}
+div.toclevel4 {
+ margin-left: 6em;
+ font-size: 0.9em;
+}
-The alternative +#include+ statement textually includes an entire
-file using the C preprocessor at the point of the statement.
-Note that +#include+ will only work if the preprocessor is enabled
-on the current file. In contrast to +import+, +#include+ will run the
-C preprocessor on any included modules. +import+ is recommended over
-+#include+ unless the imported module requires preprocessing.
-----
-#include <mypackage/mymodule.swift>
-----
+/* SWIFT/T GUIDE CUSTOMIZATIONS */
-== Dataflow evaluation
+a:visited {
+ color: gray;
+}
+h5 {
+ font-size: 0.8em;
+}
-Swift expressions are evaluated in _dataflow_ order:
+</style>
+<script type="text/javascript">
+/*<![CDATA[*/
+window.onload = function(){asciidoc.footnotes(); asciidoc.toc(2);}
+var asciidoc = { // Namespace.
-----
-int z1,z2;
+/////////////////////////////////////////////////////////////////////
+// Table Of Contents generator
+/////////////////////////////////////////////////////////////////////
+
+/* Author: Mihai Bazon, September 2002
+ * http://students.infoiasi.ro/~mishoo
+ *
+ * Table Of Content generator
+ * Version: 0.4
+ *
+ * Feel free to use this script under the terms of the GNU General Public
+ * License, as long as you do not remove or alter this notice.
+ */
+
+ /* modified by Troy D. Hanson, September 2006. License: GPL */
+ /* modified by Stuart Rackham, 2006, 2009. License: GPL */
+
+// toclevels = 1..4.
+toc: function (toclevels) {
+
+ function getText(el) {
+ var text = "";
+ for (var i = el.firstChild; i != null; i = i.nextSibling) {
+ if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
+ text += i.data;
+ else if (i.firstChild != null)
+ text += getText(i);
+ }
+ return text;
+ }
+
+ function TocEntry(el, text, toclevel) {
+ this.element = el;
+ this.text = text;
+ this.toclevel = toclevel;
+ }
+
+ function tocEntries(el, toclevels) {
+ var result = new Array;
+ var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
+ // Function that scans the DOM tree for header elements (the DOM2
+ // nodeIterator API would be a better technique but not supported by all
+ // browsers).
+ var iterate = function (el) {
+ for (var i = el.firstChild; i != null; i = i.nextSibling) {
+ if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
+ var mo = re.exec(i.tagName);
+ if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
+ result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
+ }
+ iterate(i);
+ }
+ }
+ }
+ iterate(el);
+ return result;
+ }
+
+ var toc = document.getElementById("toc");
+ var entries = tocEntries(document.getElementById("content"), toclevels);
+ for (var i = 0; i < entries.length; ++i) {
+ var entry = entries[i];
+ if (entry.element.id == "")
+ entry.element.id = "_toc_" + i;
+ var a = document.createElement("a");
+ a.href = "#" + entry.element.id;
+ a.appendChild(document.createTextNode(entry.text));
+ var div = document.createElement("div");
+ div.appendChild(a);
+ div.className = "toclevel" + entry.toclevel;
+ toc.appendChild(div);
+ }
+ if (entries.length == 0)
+ toc.parentNode.removeChild(toc);
+},
+
+
+/////////////////////////////////////////////////////////////////////
+// Footnotes generator
+/////////////////////////////////////////////////////////////////////
+
+/* Based on footnote generation code from:
+ * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
+ */
+
+footnotes: function () {
+ var cont = document.getElementById("content");
+ var noteholder = document.getElementById("footnotes");
+ var spans = cont.getElementsByTagName("span");
+ var refs = {};
+ var n = 0;
+ for (i=0; i<spans.length; i++) {
+ if (spans[i].className == "footnote") {
+ n++;
+ // Use [\s\S] in place of . so multi-line matches work.
+ // Because JavaScript has no s (dotall) regex flag.
+ note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
+ noteholder.innerHTML +=
+ "<div class='footnote' id='_footnote_" + n + "'>" +
+ "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
+ n + "</a>. " + note + "</div>";
+ spans[i].innerHTML =
+ "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
+ "' title='View footnote' class='footnote'>" + n + "</a>]";
+ var id =spans[i].getAttribute("id");
+ if (id != null) refs["#"+id] = n;
+ }
+ }
+ if (n == 0)
+ noteholder.parentNode.removeChild(noteholder);
+ else {
+ // Process footnoterefs.
+ for (i=0; i<spans.length; i++) {
+ if (spans[i].className == "footnoteref") {
+ var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
+ href = href.match(/#.*/)[0]; // Because IE return full URL.
+ n = refs[href];
+ spans[i].innerHTML =
+ "[<a href='#_footnote_" + n +
+ "' title='View footnote' class='footnote'>" + n + "</a>]";
+ }
+ }
+ }
+}
+
+}
+/*]]>*/
+</script>
+</head>
+<body class="article" style="max-width:750px">
+<div id="header">
+<h1>Swift/T Guide</h1>
+<span id="author">v0.6.1, July 2014</span><br />
+<div id="toc">
+ <div id="toctitle">Table of Contents</div>
+ <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
+</div>
+</div>
+<div id="content">
+<div id="preamble">
+<div class="sectionbody">
+<div class="paragraph"><p>The Swift/Turbine Compiler (STC) allows you to write Swift programs
+and run them using Turbine.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_support">1. Support</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>An overview of Swift/T may be found at the ExM project site:</p></div>
+<div class="paragraph"><p><a href="https://sites.google.com/site/exmcomputing">https://sites.google.com/site/exmcomputing</a></p></div>
+<div class="paragraph"><p>The Swift/T user discussion mailing list is found here:</p></div>
+<div class="paragraph"><p><a href="http://lists.mcs.anl.gov/mailman/listinfo/exm-user">http://lists.mcs.anl.gov/mailman/listinfo/exm-user</a></p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_installation">2. Installation</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Writing and running Swift/Turbine programs requires multiple packages.
+This section provides generic instructions for installing Swift/T
+on a range of systems. We first cover locating and/or installing
+prerequisite software packages, then we cover building Swift/T
+from a source package.</p></div>
+<div class="paragraph"><p>The <a href="turbine-sites.html">Turbine Sites Guide</a>
+is a accompanying resource for configuration settings and preinstalled software
+for specific systems.</p></div>
+<div class="sect2">
+<h3 id="_installation_of_prerequisites">2.1. Installation of Prerequisites</h3>
+<div class="olist arabic"><ol class="arabic">
+<li>
+<p>
+Install or locate MPI implementation (MPICH, OpenMPI, etc.)
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+On compute clusters, an MPI will almost certainly be pre-installed
+</p>
+</li>
+<li>
+<p>
+Many operating systems provide packages with MPI implementations
+ that are usable, but often outdated.
+ E.g. the <tt>mpich2</tt> package on Debian/Ubuntu.
+</p>
+</li>
+<li>
+<p>
+See <a href="http://www.mpich.org">MPICH Guides</a> for information on installing the
+ latest version of MPICH.
+</p>
+</li>
+<li>
+<p>
+Other MPI implementations are <a href="#Build_configuration">supported</a> as well.
+</p>
+<div class="paragraph"><p>Swift/T attempts to use MPI 3.0 functionality by default. If you
+are using an MPI implementation that does not support the MPI 3.0 standard,
+you must set <tt>MPI_VERSION=2</tt> (if using the <tt>exm-setup.zsh</tt> build process),
+or provide the <tt>--enable-mpi-2</tt> configure option (if using
+the manual build process).</p></div>
+</li>
+</ul></div>
+</li>
+<li>
+<p>
+Install or locate Tcl 8.6.
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+Tcl is available through the package manager on many systems.
+ You may need to install an additional Tcl development package
+ in addition to the standard tcl package,
+ e.g. <tt>tcl8.6</tt> plus <tt>tcl8.6-dev</tt> on Debian/Ubuntu systems.
+</p>
+</li>
+<li>
+<p>
+Source distributions are available at the <a href="http://www.tcl.tk">Tcl web site</a>
+</p>
+</li>
+</ul></div>
+</li>
+<li>
+<p>
+Install or locate SWIG
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+You can check if SWIG is installed by running <tt>swig -version</tt>
+</p>
+</li>
+<li>
+<p>
+SWIG is available through the package manager on many systems.
+</p>
+</li>
+<li>
+<p>
+Source distributions are available at
+ the <a href="http://swig.org">SWIG web site</a>
+</p>
+</li>
+</ul></div>
+</li>
+</ol></div>
+</div>
+<div class="sect2">
+<h3 id="_installation_of_swift_t_from_source">2.2. Installation of Swift/T from Source</h3>
+<div class="paragraph"><p>Once you have found all prerequisites, we can continue with building
+Swift/T from source.</p></div>
+<div class="olist arabic"><ol class="arabic">
+<li>
+<p>
+Obtain the Swift/T source package
+</p>
+<div class="listingblock">
+<div class="content">
+<pre><tt>wget http://www.mcs.anl.gov/exm/local/downloads/exm-0.5.0.tar.gz</tt></pre>
+</div></div>
+<div class="paragraph"><p>Cf. <a href="http://www.mcs.anl.gov/exm/local/downloads/downloads.html">Swift/T Downloads</a>
+for other packages</p></div>
+</li>
+<li>
+<p>
+Unpack and enter package directory
+</p>
+<div class="listingblock">
+<div class="content">
+<pre><tt>tar xfz exm-trunk.tar.gz
+cd exm-trunk</tt></pre>
+</div></div>
+</li>
+<li>
+<p>
+Edit the settings file: <tt>exm-settings.sh</tt>
+</p>
+<div class="paragraph"><p>At a minimum, you must set the install directory with <tt>EXM_PREFIX</tt>.
+On a standard system, no further configuration may be needed.
+In many cases, however, you will need to modify additional
+configuration settings so that all prerequisites can
+be correctly located and configured (see Section
+<a href="#Build_configuration">Build configuration</a>).</p></div>
+<div class="paragraph"><p>A range of other settings are also available here:
+enabling/disabling features, debug or optimized builds, etc.</p></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Tip</div>
+</td>
+<td class="content">Save your <tt>exm-settings.sh</tt> when you download a new package</td>
+</tr></table>
+</div>
+</li>
+<li>
+<p>
+Run the setup script
+</p>
+<div class="listingblock">
+<div class="content">
+<pre><tt>./exm-setup.zsh</tt></pre>
+</div></div>
+<div class="paragraph"><p>If <tt>exm-setup.zsh</tt> does not succeed on your system, see Section
+<a href="#Build_configuration">Build configuration</a> below.</p></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Tip</div>
+</td>
+<td class="content">if you want more control than <tt>exm-setup.zsh</tt> provides, you can
+ build Swift/T with the
+ <a href="#Manual_build_configuration">manual configure/make workflow</a>.</td>
+</tr></table>
+</div>
+</li>
+<li>
+<p>
+Add Turbine and STC to your paths
+</p>
+<div class="listingblock">
+<div class="content">
+<pre><tt>PATH=${PATH}:/path/to/exm-install/turbine/bin
+PATH=${PATH}:/path/to/exm-install/stc/bin</tt></pre>
+</div></div>
+</li>
+</ol></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_usage">3. Usage</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Swift code is conventionally written in <tt>*.swift</tt> files. Turbine
+code is stored in Tcl files <tt>*.tcl</tt>. After writing the Swift program
+<tt>program.swift</tt>, run:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>stc program.swift</tt></pre>
+</div></div>
+<div class="paragraph"><p>This will compile the program to <tt>program.tcl</tt>. A second, optional
+argument may be given as an alternate output file name.</p></div>
+<div class="paragraph"><p>Then, to run the program, use Turbine:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>turbine -n 4 program.tcl</tt></pre>
+</div></div>
+<div class="paragraph"><p>See the <a href="#Turbine">Turbine section</a> for more information about
+running the program.</p></div>
+<div class="paragraph" id="stc_arguments"><p>STC accepts the following arguments:</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>-A <em>name</em>=<em>value</em></tt>
+</dt>
+<dd>
+<p>
+Set a command-line argument at
+compile-time. This may be found at runtime using the Swift
+<a href="#argv">argument processing</a> library. This option enables these
+arguments to be treated as compile-time constants for optimization.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-D <em>macro</em>=<em>value</em></tt>
+</dt>
+<dd>
+<p>
+Define a C preprocessor macro.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-E</tt>
+</dt>
+<dd>
+<p>
+Just run the C preprocessor: do not compile the program. The
+output goes into the STC output file (the second file name argument).
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-I</tt>
+</dt>
+<dd>
+<p>
+Add a directory to the import and include search path.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-O</tt>
+</dt>
+<dd>
+<p>
+Set optimization level: 0, 1, 2, or 3. See <a href="#Optimizations">[Optimizations]</a>.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-j</tt>
+</dt>
+<dd>
+<p>
+Set the location of the <tt>java</tt> executable.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-p</tt>
+</dt>
+<dd>
+<p>
+Disable the C preprocessor.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-u</tt>
+</dt>
+<dd>
+<p>
+Only compile if output file is not up-to-date.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-v</tt>
+</dt>
+<dd>
+<p>
+Output version number and exit.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-V</tt>
+</dt>
+<dd>
+<p>
+Verbose output.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>STC runs as a Java program. You may use <tt>-j</tt> to set the Java VM
+executable. This Java VM must be compatible with the <tt>javac</tt> used to
+compile STC.</p></div>
+<div class="paragraph"><p>By default, STC runs the user script through the C preprocessor
+(<tt>cpp</tt>), enabling arbitrary macro processing, etc. The <tt>-D</tt>, <tt>-E</tt>,
+<tt>-I</tt>, and <tt>-p</tt> options are relevant to this feature.</p></div>
+<div class="paragraph"><p>Additional arguments for advanced users/developers:</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>-C</tt>
+</dt>
+<dd>
+<p>
+Specify an output file for STC internal representation
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-l</tt>
+</dt>
+<dd>
+<p>
+Specify log file for STC debug log
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-L</tt>
+</dt>
+<dd>
+<p>
+Specify log file for more verbose STC debug log
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-T</tt>
+</dt>
+<dd>
+<p>
+Enable a specific optimization. See <a href="#Optimizations">[Optimizations]</a>
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-t</tt>
+</dt>
+<dd>
+<p>
+Disable a specific compiler optimization. See <a href="#Optimizations">[Optimizations]</a>
+</p>
+</dd>
+</dl></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_program_structure">4. Program structure</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Swift programs are composed of <em>composite</em> functions. These
+share syntax with C-like languages. The program starts in <tt>main()</tt>.
+The following is a complete Swift program:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>main
+{}</tt></pre>
+</div></div>
+<div class="paragraph"><p>STC input is preprocessed by <tt>cpp</tt>, the C preprocessor.</p></div>
+<div class="paragraph"><p>Hello world is written as:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>import io;
+main
+{
+ printf("Hello world");
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>The newline is supplied by <tt>printf()</tt>.</p></div>
+<div class="paragraph"><p>Swift programs eventually call <em>leaf</em> functions, which are the primary
+way to do work. From the perspective of the Swift script, they are
+atomic operations that wait for input variables and set output
+variables. They may be implemented as native code functions or
+external application programs.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_comments">5. Comments</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Swift supports C/C++-style comments:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>// This is a comment
+/* This is a
+comment */
+/** Also a
+comment */</tt></pre>
+</div></div>
+<div class="paragraph"><p>Additionally, if the preprocessor is disabled, single-line comments
+starting with # are supported:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt># This will work if source file is not preprocessed</tt></pre>
+</div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_modules">6. Modules</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Swift has a module system that allows you to import function and variable
+definitions into your source file. Importing a module will import all
+function and variable definitions from that module into your program.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>import io;
+import mypackage.mymodule;</tt></pre>
+</div></div>
+<div class="paragraph"><p>The mechanisms for locating source files is as follows:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+STC searches a list of directories in order to find a Swift source
+ file in the correct directory with the correct name.
+</p>
+</li>
+<li>
+<p>
+The standard library is always first on the search path,
+ and the current working directory is last.
+</p>
+</li>
+<li>
+<p>
+Additional directories can be added with the <tt>-I</tt> option to STC.
+</p>
+</li>
+<li>
+<p>
+Swift source files must have a <tt>.swift</tt> suffix. E.g. <tt>import io;</tt>
+ looks for a file called <tt>io.swift</tt>.
+</p>
+</li>
+<li>
+<p>
+In the case of a multi-part import name, E.g. <tt>import mypackage.mymodule</tt>,
+ then, it looks for <tt>mymodule.swift</tt> in subdirectory <tt>mypackage</tt>.
+</p>
+</li>
+</ul></div>
+<div class="paragraph"><p>The alternative <tt>#include</tt> statement textually includes an entire
+file using the C preprocessor at the point of the statement.
+Note that <tt>#include</tt> will only work if the preprocessor is enabled
+on the current file. In contrast to <tt>import</tt>, <tt>#include</tt> will run the
+C preprocessor on any included modules. <tt>import</tt> is recommended over
+<tt>#include</tt> unless the imported module requires preprocessing.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>#include <mypackage/mymodule.swift></tt></pre>
+</div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_dataflow_evaluation">7. Dataflow evaluation</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Swift expressions are evaluated in <em>dataflow</em> order:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>int z1,z2;
int y;
int x = f(y);
y = g(2);
z1 = h(x,y,1);
z2 = h(x,y,2);
-int output = r(z1,z2);
-----
-
-This allows code to execute as concurrently as possible, limited
-only by data availability. In this example, +g()+ runs first, because it
-is dependent only on a literal. When +y+ is set, +f()+ runs, setting
-+x+. Then, two invocations of +h()+ execute. Finally, +z1+ and +z2+
-are set, allowing +r()+ to run.
-
-Variables may be assigned only once. Multiple assignment is often
+int output = r(z1,z2);</tt></pre>
+</div></div>
+<div class="paragraph"><p>This allows code to execute as concurrently as possible, limited
+only by data availability. In this example, <tt>g()</tt> runs first, because it
+is dependent only on a literal. When <tt>y</tt> is set, <tt>f()</tt> runs, setting
+<tt>x</tt>. Then, two invocations of <tt>h()</tt> execute. Finally, <tt>z1</tt> and <tt>z2</tt>
+are set, allowing <tt>r()</tt> to run.</p></div>
+<div class="paragraph"><p>Variables may be assigned only once. Multiple assignment is often
detected at compile time, and will always be detected at run time,
resulting in a run time error. If variable is not assigned,
expressions that depend on the variable cannot execute. If the variable
is never assigned during the course of program execution, these
expressions will never execute. Upon program completion, Swift/T will
report the error and print debug information about any unexecuted
-expressions and identifiers of corresponding unassigned variables.
-
-== Composite functions
-
-Swift code is written in composite functions. The composite function
-+main+ is required.
-
-Composite functions have the form:
-
-----
-[(<output list>)] function_name [(<input list>)]
+expressions and identifiers of corresponding unassigned variables.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_composite_functions">8. Composite functions</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Swift code is written in composite functions. The composite function
+<tt>main</tt> is required.</p></div>
+<div class="paragraph"><p>Composite functions have the form:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>[(<output list>)] function_name [(<input list>)]
{
statement;
statement;
...
-}
-----
-
-An empty input or output list may be omitted or written as +()+.
-
-The output list may have more than one entry. Thus, assignments
-may be written as:
-----
-x1, x2 = f(i1, i2);
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>An empty input or output list may be omitted or written as <tt>()</tt>.</p></div>
+<div class="paragraph"><p>The output list may have more than one entry. Thus, assignments
+may be written as:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>x1, x2 = f(i1, i2);
// or equivalently:
-(x1, x2) = f(i1, i2);
-----
-
-== Types
-
-Swift provides a similar range of primitive types to many other
+(x1, x2) = f(i1, i2);</tt></pre>
+</div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_types">9. Types</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Swift provides a similar range of primitive types to many other
programming languages. Files are a primitive type in Swift, unlike
in many other languages, and have a number of special characteristics
that merit special mention.
-Two basic kinds of data structure are provided: arrays and structs.
-
-=== Primitive types
-
-Swift has the conventional types:
-
-+string+:: A complete string (not an array of characters).
-+int+:: A 64-bit integer.
-+float+:: A 64-bit (double-precision) floating point number.
-+boolean+:: A boolean (true/false).
-+file+:: A file (see Section Files).
-+blob+:: External byte data (see Section Blobs).
-
-Literals for these types use conventional syntax:
-
-* +int+ literals are written as decimal numbers, e.g. +-1234+
-* +float+ literals are written as decimal numbers with a decimal point,
- e.g +5493.352+ or +1.0+.
+Two basic kinds of data structure are provided: arrays and structs.</p></div>
+<div class="sect2">
+<h3 id="_primitive_types">9.1. Primitive types</h3>
+<div class="paragraph"><p>Swift has the conventional types:</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>string</tt>
+</dt>
+<dd>
+<p>
+A complete string (not an array of characters).
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>int</tt>
+</dt>
+<dd>
+<p>
+A 64-bit integer.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>float</tt>
+</dt>
+<dd>
+<p>
+A 64-bit (double-precision) floating point number.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>boolean</tt>
+</dt>
+<dd>
+<p>
+A boolean (true/false).
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>file</tt>
+</dt>
+<dd>
+<p>
+A file (see Section Files).
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>blob</tt>
+</dt>
+<dd>
+<p>
+External byte data (see Section Blobs).
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Literals for these types use conventional syntax:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+<tt>int</tt> literals are written as decimal numbers, e.g. <tt>-1234</tt>
+</p>
+</li>
+<li>
+<p>
+<tt>float</tt> literals are written as decimal numbers with a decimal point,
+ e.g <tt>5493.352</tt> or <tt>1.0</tt>.
Scientific notation may be used,
- as in +2.3e-2+ which is equivalent to +0.023+.
- The literals +NaN+ and +inf+ may be used. In some contexts +int+
- literals are promoted automatically to +float+.
-* +boolean+ literals +true+ and +false+ may be used.
-* +string+ literals are enclosed in double quotes, with a range of escape
+ as in <tt>2.3e-2</tt> which is equivalent to <tt>0.023</tt>.
+ The literals <tt>NaN</tt> and <tt>inf</tt> may be used. In some contexts <tt>int</tt>
+ literals are promoted automatically to <tt>float</tt>.
+</p>
+</li>
+<li>
+<p>
+<tt>boolean</tt> literals <tt>true</tt> and <tt>false</tt> may be used.
+</p>
+</li>
+<li>
+<p>
+<tt>string</tt> literals are enclosed in double quotes, with a range of escape
sequences supported:
-** +\\+ for a single backslash
-** +\"+ for a quote
-** +\n+ for newline
-** +\t+ for tab
-** +\a+ (alarm)
-** +\b+ (backspace)
-** +\f+ (form feed)
-** +\r+ (carriage return)
-** +\v+ (vertical tab)
-** octal escape codes, e.g. +\001+
-** hexadecimal escape codes, e.g. +\xf2+
-** For more information: http://en.wikipedia.org/wiki/US-ASCII#ASCII_control_code_chart[ASCII control codes].
-* Multi-line strings may be used in two syntaxes:
-** Python-style:
-+
-----
-string s =
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+<tt>\\</tt> for a single backslash
+</p>
+</li>
+<li>
+<p>
+<tt>\"</tt> for a quote
+</p>
+</li>
+<li>
+<p>
+<tt>\n</tt> for newline
+</p>
+</li>
+<li>
+<p>
+<tt>\t</tt> for tab
+</p>
+</li>
+<li>
+<p>
+<tt>\a</tt> (alarm)
+</p>
+</li>
+<li>
+<p>
+<tt>\b</tt> (backspace)
+</p>
+</li>
+<li>
+<p>
+<tt>\f</tt> (form feed)
+</p>
+</li>
+<li>
+<p>
+<tt>\r</tt> (carriage return)
+</p>
+</li>
+<li>
+<p>
+<tt>\v</tt> (vertical tab)
+</p>
+</li>
+<li>
+<p>
+octal escape codes, e.g. <tt>\001</tt>
+</p>
+</li>
+<li>
+<p>
+hexadecimal escape codes, e.g. <tt>\xf2</tt>
+</p>
+</li>
+<li>
+<p>
+For more information: <a href="http://en.wikipedia.org/wiki/US-ASCII#ASCII_control_code_chart">ASCII control codes</a>.
+</p>
+</li>
+</ul></div>
+</li>
+<li>
+<p>
+Multi-line strings may be used in two syntaxes:
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+Python-style:
+</p>
+<div class="listingblock">
+<div class="content">
+<pre><tt>string s =
"""
line data 1
line data 2
-""";
-----
-+
-** Asciidoc-style: like Python-style but use 4 dashes instead of 3 quotes.
-** *Note:* Multi-line strings are somewhat incompatible with the C preprocessor:
+""";</tt></pre>
+</div></div>
+</li>
+<li>
+<p>
+Asciidoc-style: like Python-style but use 4 dashes instead of 3 quotes.
+</p>
+</li>
+<li>
+<p>
+<strong>Note:</strong> Multi-line strings are somewhat incompatible with the C preprocessor:
if you try to compile a Swift program using multi-line strings with
the preprocessor enabled, you will likely see warnings or strange
- behavior. To disable the C preprocessor, use the +-p+ option
+ behavior. To disable the C preprocessor, use the <tt>-p</tt> option
to STC.
-
-=== Files
-
-A file is a first-class entity in Swift that in many ways can be treated
+</p>
+</li>
+</ul></div>
+</li>
+</ul></div>
+</div>
+<div class="sect2">
+<h3 id="_files">9.2. Files</h3>
+<div class="paragraph"><p>A file is a first-class entity in Swift that in many ways can be treated
as any other variable. The main difference is that a file can be
-*mapped* to path in a filesystem. Assigning to a mapped file variable
+<strong>mapped</strong> to path in a filesystem. Assigning to a mapped file variable
results in a file being created in the file system at the specified path.
-File paths can be arbitrary Swift expressions of type +string+. Absolute
+File paths can be arbitrary Swift expressions of type <tt>string</tt>. Absolute
paths or relative paths are specified, with relative paths interpreted
relative to the path in which turbine was run.
File variables can also be initialized with data from a pre-existing
-file using the +input_file+ function. File paths are relative to the
-working directory for Turbine.
-
-For example, if +/home/user/in.txt+ is a file with some data in it,
-the following Swift program will copy the file to +/home/user/out.txt+.
-----
-main
+file using the <tt>input_file</tt> function. File paths are relative to the
+working directory for Turbine.</p></div>
+<div class="paragraph"><p>For example, if <tt>/home/user/in.txt</tt> is a file with some data in it,
+the following Swift program will copy the file to <tt>/home/user/out.txt</tt>.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>main
{
file x = input_file("/home/user/in.txt");
- file y <"/home/user/out.txt">; // Declare a mapped file
+ file y <"/home/user/out.txt">; // Declare a mapped file
y = x; // Do the copy
-}
-----
-
-
-A range of functions to work with files are provided in the
-+files+ library module.
-
-----
-// Initialize an array of files from a range of files on disk with glob
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>A range of functions to work with files are provided in the
+<tt>files</tt> library module.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>// Initialize an array of files from a range of files on disk with glob
file f[] = glob("directory/*.txt");
// Read the contents of a file with read
@@ -421,79 +1282,79 @@
file tmp = write("first line\nsecond line");
// Find the name of a file with filename
-trace("Temporary filename is: " + filename(tmp));
-----
-
-Temporary files are created as necessary if unmapped files are
-written to. For example, the file +tmp+ in the above code snippet.
-This feature is implemented by calling GNU +mktemp+ with suffix
-+.turbine+; thus, the directory is set with environment variable
-+TMPDIR+ which defaults to +/tmp+.
-
-Currently Swift/T assumes that the file system is shared among
-all nodes.
-
-[NOTE]
-======
-The syntax
-----
-file f<"f.txt"> = g();
-----
-is allowed but
-----
-file f<"f.txt">=g();
-----
-results in a parse error: the +>=+ sequence is tokenized as
-_greater-than-or-equal-to_.
-======
-
-=== Blobs
-
-Blobs represent raw byte data. They are primarily used to pass
+trace("Temporary filename is: " + filename(tmp));</tt></pre>
+</div></div>
+<div class="paragraph"><p>Temporary files are created as necessary if unmapped files are
+written to. For example, the file <tt>tmp</tt> in the above code snippet.
+This feature is implemented by calling GNU <tt>mktemp</tt> with suffix
+<tt>.turbine</tt>; thus, the directory is set with environment variable
+<tt>TMPDIR</tt> which defaults to <tt>/tmp</tt>.</p></div>
+<div class="paragraph"><p>Currently Swift/T assumes that the file system is shared among
+all nodes.</p></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">
+<div class="paragraph"><p>The syntax</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>file f<"f.txt"> = g();</tt></pre>
+</div></div>
+<div class="paragraph"><p>is allowed but</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>file f<"f.txt">=g();</tt></pre>
+</div></div>
+<div class="paragraph"><p>results in a parse error: the <tt>>=</tt> sequence is tokenized as
+<em>greater-than-or-equal-to</em>.</p></div>
+</td>
+</tr></table>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_blobs">9.3. Blobs</h3>
+<div class="paragraph"><p>Blobs represent raw byte data. They are primarily used to pass
data to and from native code libraries callable from Swift. They are
-like Swift strings but may contain arbitrary data.
-
-Swift provides multiple builtin functions to create blobs, convert
-blobs to and from Swift types, and pass blobs to leaf functions.
-
-=== Arrays
-
-Arrays can be declared with empty square brackets:
-
-----
-int A[];
-----
-
-Arrays with empty square brackets have integer indices. It is
+like Swift strings but may contain arbitrary data.</p></div>
+<div class="paragraph"><p>Swift provides multiple builtin functions to create blobs, convert
+blobs to and from Swift types, and pass blobs to leaf functions.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_arrays">9.4. Arrays</h3>
+<div class="paragraph"><p>Arrays can be declared with empty square brackets:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>int A[];</tt></pre>
+</div></div>
+<div class="paragraph"><p>Arrays with empty square brackets have integer indices. It is
also possible to declare integers with other index types, such as
-strings:
-
-----
-string dict[string];
-----
-
-They are dynamically sized, expanding each time an item is inserted at
-a new index. Arrays are indexed using square brackets.
-----
-int A[string];
+strings:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>string dict[string];</tt></pre>
+</div></div>
+<div class="paragraph"><p>They are dynamically sized, expanding each time an item is inserted at
+a new index. Arrays are indexed using square brackets.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>int A[string];
int B[];
B = function_returning_array();
A["zero"] = B[0];
-A["one"] = B[1];
-----
-
-Each array index can only be assigned to once.
-
-A given array variable must be assigned either _in toto_ (as a whole)
-or _in partes_ (piece by piece). In this example, +B+ is assigned in toto
-and +A+ is assigned in partes. Code that attempts to do both is in error.
-
-Arrays may be used as inputs or outputs of functions.
-
-Arrays are part of Swift dataflow semantics. An array is closed
-when all possible insertions to it are complete.
-----
-(int B[]) f(int j)
+A["one"] = B[1];</tt></pre>
+</div></div>
+<div class="paragraph"><p>Each array index can only be assigned to once.</p></div>
+<div class="paragraph"><p>A given array variable must be assigned either <em>in toto</em> (as a whole)
+or <em>in partes</em> (piece by piece). In this example, <tt>B</tt> is assigned in toto
+and <tt>A</tt> is assigned in partes. Code that attempts to do both is in error.</p></div>
+<div class="paragraph"><p>Arrays may be used as inputs or outputs of functions.</p></div>
+<div class="paragraph"><p>Arrays are part of Swift dataflow semantics. An array is closed
+when all possible insertions to it are complete.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>(int B[]) f(int j)
{
int A[];
A = subroutine_function(1);
@@ -503,72 +1364,69 @@
// OK: assigning to output variable
B = subroutine_function(2);
-}
-
-----
-
-Array literals may be expressed using the range operator:
-----
-int start = 0;
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>Array literals may be expressed using the range operator:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>int start = 0;
int stop = 10;
int step = 2;
// Array of length 10:
int A[] = [start:stop];
// Array of length 5, containing only even numbers:
-int B[] = [start:stop:step];
-----
-
-Array literals may also be expressed with list syntax:
-----
-int C[] = [4,5,6];
-----
-
-=== Nested arrays
-Swift allows arrays of arrays: nested arrays. They can be declared and
-assigned as follows:
-
-----
-// An array of arrays of files with string keys
+int B[] = [start:stop:step];</tt></pre>
+</div></div>
+<div class="paragraph"><p>Array literals may also be expressed with list syntax:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>int C[] = [4,5,6];</tt></pre>
+</div></div>
+</div>
+<div class="sect2">
+<h3 id="_nested_arrays">9.5. Nested arrays</h3>
+<div class="paragraph"><p>Swift allows arrays of arrays: nested arrays. They can be declared and
+assigned as follows:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>// An array of arrays of files with string keys
file A[string][string];
A["foo"]["bar"] = input_file("test.txt");
-A["foo"]["qux"] = input_file("test2.txt");
-----
-
-*Note:* there is currently a limitation in assignment of nested arrays
+A["foo"]["qux"] = input_file("test2.txt");</tt></pre>
+</div></div>
+<div class="paragraph"><p><strong>Note:</strong> there is currently a limitation in assignment of nested arrays
that a given array can only be assigned at a single "index level". If
-+A+ is a 2D array, for example, then you cannot mix assignments specifying
-one index (e.g. +A[i] = ...+) with assignments specifying three indices
-(e.g. +A[i][j] = ...+).
-
-=== Structs
-
-In Swift, structs are defined with the +type+ keyword. They define
-a new type.
-
-----
-type person
+<tt>A</tt> is a 2D array, for example, then you cannot mix assignments specifying
+one index (e.g. <tt>A[i] = …</tt>) with assignments specifying three indices
+(e.g. <tt>A[i][j] = …</tt>).</p></div>
+</div>
+<div class="sect2">
+<h3 id="_structs">9.6. Structs</h3>
+<div class="paragraph"><p>In Swift, structs are defined with the <tt>type</tt> keyword. They define
+a new type.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>type person
{
string name;
int age;
int events[];
-}
-----
-
-Structs are accessed with the +.+ syntax:
-
-----
-person p;
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>Structs are accessed with the <tt>.</tt> syntax:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>person p;
p.name = "Abe";
-p.age = 90;
-----
-
-It is possible to have arrays of structs, with some restriction on
+p.age = 90;</tt></pre>
+</div></div>
+<div class="paragraph"><p>It is possible to have arrays of structs, with some restriction on
how they can be assigned. Each struct in the array must be assigned
-_in toto_ (as a whole). For example, the following code is valid:
+<em>in toto</em> (as a whole). For example, the following code is valid:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>person people[], p1, p2;
-----
-person people[], p1, p2;
-
p1.name = "Thelma";
p1.age = 31;
@@ -576,50 +1434,46 @@
p2.age = 29;
people[0] = p1;
-people[1] = p2;
-----
-
-However, attempting to assign the structs in the following way is
-currently unsupported:
-----
-people[2].name = "Abe"; // Not supported!
-people[2].age = 90; // Not supported!
-----
-
-=== Defining new types
-
-Swift has two ways to define new types based on existing types.
-
-The first is +typedef+, which creates a new name for the type.
+people[1] = p2;</tt></pre>
+</div></div>
+<div class="paragraph"><p>However, attempting to assign the structs in the following way is
+currently unsupported:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>people[2].name = "Abe"; // Not supported!
+people[2].age = 90; // Not supported!</tt></pre>
+</div></div>
+</div>
+<div class="sect2">
+<h3 id="_defining_new_types">9.7. Defining new types</h3>
+<div class="paragraph"><p>Swift has two ways to define new types based on existing types.</p></div>
+<div class="paragraph"><p>The first is <tt>typedef</tt>, which creates a new name for the type.
The new type and the existing type will be completely interchangeable,
since they are simply different names for the same underlying type.
-The new type name simply serves to improve readability or documentation.
+The new type name simply serves to improve readability or documentation.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>typedef newint int;
-----
-typedef newint int;
-
main {
// We can freely convert between int and newint
newint x = 1;
int y = x;
newint z = y;
-}
-----
-
-The second is with +type+, which creates a new type that is a
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>The second is with <tt>type</tt>, which creates a new type that is a
specialization of an existing type. That is, it is a distinct
type that is not interchangeable. A specialized type can be
converted into the original type, but the reverse transformation is
not possible. This means that you can write functions that are more
strictly typechecked, for example, only accepted particular types of
-file.
-
-*Note:* This feature is immature, so you will have a higher probability
-of encountering compiler bugs or limitations.
-
-----
-
-typedef sorted_file file;
+file.</p></div>
+<div class="paragraph"><p><strong>Note:</strong> This feature is immature, so you will have a higher probability
+of encountering compiler bugs or limitations.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>typedef sorted_file file;
app (sorted_file out) sort (file i) {
"/usr/bin/sort" "-o" out i
}
@@ -631,54 +1485,54 @@
main {
file unsorted = input_file("input.txt");
- sorted_file sorted <"sorted.txt"> = sort(unsorted);
- file u <"unique.txt"> = unique(sorted);
+ sorted_file sorted <"sorted.txt"> = sort(unsorted);
+ file u <"unique.txt"> = unique(sorted);
// Can convert from sorted_file to file
file result2 = sort(unsorted);
// This would cause a type error
// sorted_file not_sorted = unsorted;
-}
-----
-
-=== Global Constants
-
-Swift supports a basic feature for defining globally visible constants. You
-can use the +global const+ statement at the top level of the program. The
+}</tt></pre>
+</div></div>
+</div>
+<div class="sect2">
+<h3 id="_global_constants">9.8. Global Constants</h3>
+<div class="paragraph"><p>Swift supports a basic feature for defining globally visible constants. You
+can use the <tt>global const</tt> statement at the top level of the program. The
syntax only supports literals of scalar types: e.g. integer literals, floating
-point literals and string literals.
-
-----
-global const string hello = "Hello World";
+point literals and string literals.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>global const string hello = "Hello World";
global const float pi_approx = 3.142;
global const int ONE = 1;
main () {
trace(hello, pi_approx, ONE);
-}
-----
-
-*Note:* global constants provide no performance benefit compared with
-variables initialized to constant values at optimization levels +O1+
-or greater.
-
-*Note:* better support is planned in future for more flexible support for
-global variables and code.
-
-== Control structures
-
-Swift provides control structures that may be placed as statements
-inside a composite function.
-
-=== Conditionals
-
-==== If statement
-
-If statements have the form:
-
-----
-if (<condition>)
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p><strong>Note:</strong> global constants provide no performance benefit compared with
+variables initialized to constant values at optimization levels <tt>O1</tt>
+or greater.</p></div>
+<div class="paragraph"><p><strong>Note:</strong> better support is planned in future for more flexible support for
+global variables and code.</p></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_control_structures">10. Control structures</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Swift provides control structures that may be placed as statements
+inside a composite function.</p></div>
+<div class="sect2">
+<h3 id="_conditionals">10.1. Conditionals</h3>
+<div class="sect3">
+<h4 id="_if_statement">10.1.1. If statement</h4>
+<div class="paragraph"><p>If statements have the form:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>if (<condition>)
{
statement;
...
@@ -687,16 +1541,16 @@
{
statement;
...
-}
-----
-
-As required by dataflow processing, neither branch of the conditional can
-execute until the value of the condition expression is available.
-
-==== Switch statement
-
-----
-int a = 20;
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>As required by dataflow processing, neither branch of the conditional can
+execute until the value of the condition expression is available.</p></div>
+</div>
+<div class="sect3">
+<h4 id="_switch_statement">10.1.2. Switch statement</h4>
+<div class="listingblock">
+<div class="content">
+<pre><tt>int a = 20;
switch (a)
{
case 1:
@@ -710,51 +1564,48 @@
default:
b = 2102 + 2420;
}
-printf("b: %i\n", b);
-----
-
-*Note:* there is no fall-through between cases in switch statements.
-
-=== Iteration
-
-Iteration is performed with the +foreach+ and +for+ statements.
-
-==== Foreach loop
-
-The +foreach+ loop allows for parallel iteration over an array:
-
-----
-string A[];
+printf("b: %i\n", b);</tt></pre>
+</div></div>
+<div class="paragraph"><p><strong>Note:</strong> there is no fall-through between cases in switch statements.</p></div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_iteration">10.2. Iteration</h3>
+<div class="paragraph"><p>Iteration is performed with the <tt>foreach</tt> and <tt>for</tt> statements.</p></div>
+<div class="sect3">
+<h4 id="_foreach_loop">10.2.1. Foreach loop</h4>
+<div class="paragraph"><p>The <tt>foreach</tt> loop allows for parallel iteration over an array:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>string A[];
foreach value, index in A
{
printf("A[%i] = %s\n", index, value);
-}
-----
-
-The +index+ and +value+ variables are automatically declared. The
-+index+ variable may be omitted from the syntax.
-
-A special case of the foreach loop occurs when combined with the
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>The <tt>index</tt> and <tt>value</tt> variables are automatically declared. The
+<tt>index</tt> variable may be omitted from the syntax.</p></div>
+<div class="paragraph"><p>A special case of the foreach loop occurs when combined with the
array range operator. This is the idiomatic way to iterate over
a range of integer values in Swift. The STC compiler has special
-handling for this case that avoids constructing an array.
-
-----
-foreach i in [start:stop:step] {
+handling for this case that avoids constructing an array.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>foreach i in [start:stop:step] {
...
-}
-----
-
-==== For loop
-
-The +for+ loop allows for sequential iteration. This example
+}</tt></pre>
+</div></div>
+</div>
+<div class="sect3">
+<h4 id="_for_loop">10.2.2. For loop</h4>
+<div class="paragraph"><p>The <tt>for</tt> loop allows for sequential iteration. This example
implements a counter based on the return values of a function that
-accepts integers:
-
-----
-int N = 100;
+accepts integers:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>int N = 100;
int count = 0;
-for (int i = 0; i < N; i = i+1, count = count+c)
+for (int i = 0; i < N; i = i+1, count = count+c)
{
int c;
if (condition_function(i))
@@ -765,612 +1616,1151 @@
{
c = 0;
}
-}
-----
-
-The general form is:
-----
-for ( <initializer> ; <condition> ; <updates> )
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>The general form is:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>for ( <initializer> ; <condition> ; <updates> )
{
statement;
...
-}
-----
-
-The initializer is executed first, once. The initializer is a
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>The initializer is executed first, once. The initializer is a
comma-separated list of statements. The body statements are then
executed. Then, the assignments are performed, formatted as a
comma-separated list. Each is a special assignment in which the
-left-hand-side is the variable in the _next_ iteration of the loop,
-while the right-hand-side is the variable in the _previous_ loop
+left-hand-side is the variable in the <em>next</em> iteration of the loop,
+while the right-hand-side is the variable in the <em>previous</em> loop
iteration. Then, the condition is checked for loop exit. If the loop
-continues, the body is executed again, etc.
-
-*Performance Tip:* use the +foreach+ loop instead of +for+ if your
-loop iterations are independent and can be executed in parallel.
-
-=== Explicit data-dependent execution
-
-In general, execution ordering in Swift/T is implicit and driven by
+continues, the body is executed again, etc.</p></div>
+<div class="paragraph"><p><strong>Performance Tip:</strong> use the <tt>foreach</tt> loop instead of <tt>for</tt> if your
+loop iterations are independent and can be executed in parallel.</p></div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_explicit_data_dependent_execution">10.3. Explicit data-dependent execution</h3>
+<div class="paragraph"><p>In general, execution ordering in Swift/T is implicit and driven by
data dependencies. In some cases it is useful to add explicit data
dependencies, for example if you want to print a message to indicate
that variable was assigned. It is possible for the programmer to
-express additional execution ordering using two constructs: the +wait+
-statement and the +\=>+ chaining operator.
-
-In a wait statement, a block of code is executed after
-one or more variables are closed.
-----
-x = f();
+express additional execution ordering using two constructs: the <tt>wait</tt>
+statement and the <tt>=></tt> chaining operator.</p></div>
+<div class="paragraph"><p>In a wait statement, a block of code is executed after
+one or more variables are closed.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>x = f();
y = g();
wait (x) {
trace("x is closed!");
}
wait(x, y) {
trace("x and y are closed!");
-}
-----
-
-The chaining operator chains statements together so that a
-statement only executes after the previous statement's output
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>The chaining operator chains statements together so that a
+statement only executes after the previous statement’s output
value is closed. This is
-a more concise way to express dependencies than the +wait+ statement.
-----
-sleep(1) =>
- x = f() =>
- int y = g() =>
- trace("DONE!");
-----
-
-Chaining is based on the *output values*
-of a statement. In the simple case of a function call +f() \=> ...+,
+a more concise way to express dependencies than the <tt>wait</tt> statement.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>sleep(1) =>
+ x = f() =>
+ int y = g() =>
+ trace("DONE!");</tt></pre>
+</div></div>
+<div class="paragraph"><p>Chaining is based on the <strong>output values</strong>
+of a statement. In the simple case of a function call <tt>f() => …</tt>,
the output values are the output values of the function. In the
-case of and assignment +x = f() \=> ...+ or a declaration,
-+int y = g() \=> ...+, then the next statement is dependent on
+case of and assignment <tt>x = f() => …</tt> or a declaration,
+<tt>int y = g() => …</tt>, then the next statement is dependent on
the assigned values, or the declared values. Some functions such
-as +sleep+ have +void+ output values so that they can be used
-in this fashion.
-
-=== Scoping blocks
-
-Arbitrary scoping blocks may be used. In this example, two different
-variables, both represented by +b+, are assigned different values.
-
-----
-{
+as <tt>sleep</tt> have <tt>void</tt> output values so that they can be used
+in this fashion.</p></div>
+</div>
+<div class="sect2">
+<h3 id="_scoping_blocks">10.4. Scoping blocks</h3>
+<div class="paragraph"><p>Arbitrary scoping blocks may be used. In this example, two different
+variables, both represented by <tt>b</tt>, are assigned different values.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>{
int b;
b = 1;
}
{
int b;
b = 2;
-}
-----
-
-== Operators
-
-The following binary arithmetic operators on numbers are defined:
-
-+++ (plus), +-+ (minus), +\*+ (times), +/+ (divide),
-+%/+ (integer divide), +%%+ (modulus), +**+ (power)
-
-+&&+ (boolean and), +||+ (boolean or),
-+==+ (equals), +!=+ (not equals), +>+ (greater than), +<+ (less than),
-+>=+ (greater than or equal to), +<=+ (less than or equal to)
-
-+xor()+ is a builtin function.
-
-Swift boolean operators are not short-circuited (to allow maximal
-concurrency). For conditional execution, use an +if+ statement.
-
-The following unary operators are defined:
-
-+-+ (negate), +!+ (boolean not)
-
-String concatenation is also performed with +++ (plus). +==+ and
-+!=+ may also be used on strings. Operator +s1/s2+ is equivalent to
-+s1+"/"+s2+.
-
-== Standard library
-
-Each category of function is shown with the required import
-statement, if necessary.
-
-Functions that accept an input of any type are denoted +anything+.
+}</tt></pre>
+</div></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_operators">11. Operators</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The following binary arithmetic operators on numbers are defined:</p></div>
+<div class="paragraph"><p><tt>+</tt> (plus), <tt>-</tt> (minus), <tt>*</tt> (times), <tt>/</tt> (divide),
+<tt>%/</tt> (integer divide), <tt>%%</tt> (modulus), <tt>**</tt> (power)</p></div>
+<div class="paragraph"><p><tt>&&</tt> (boolean and), <tt>||</tt> (boolean or),
+<tt>==</tt> (equals), <tt>!=</tt> (not equals), <tt>></tt> (greater than), <tt><</tt> (less than),
+<tt>>=</tt> (greater than or equal to), <tt><=</tt> (less than or equal to)</p></div>
+<div class="paragraph"><p><tt>xor()</tt> is a builtin function.</p></div>
+<div class="paragraph"><p>Swift boolean operators are not short-circuited (to allow maximal
+concurrency). For conditional execution, use an <tt>if</tt> statement.</p></div>
+<div class="paragraph"><p>The following unary operators are defined:</p></div>
+<div class="paragraph"><p><tt>-</tt> (negate), <tt>!</tt> (boolean not)</p></div>
+<div class="paragraph"><p>String concatenation is also performed with <tt>+</tt> (plus). <tt>==</tt> and
+<tt>!=</tt> may also be used on strings. Operator <tt>s1/s2</tt> is equivalent to
+<tt>s1+"/"+s2</tt>.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_standard_library">12. Standard library</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Each category of function is shown with the required import
+statement, if necessary.</p></div>
+<div class="paragraph"><p>Functions that accept an input of any type are denoted <tt>anything</tt>.
Functions that accept variable numbers of arguments are denoted with
-ellipsis +...+.
-
-A function that accepts more than one type is denoted as +f(int|string)+.
-
-If a function is described below an *Import:* label, be sure to
-+import+ that package.
-
-=== General
-
-+xor(boolean,boolean) -> boolean+:: Exclusive logical or
-+make_void() -> void+:: Create a void value
-+size(A[]) -> int+:: Obtain the size of array +A+
-+contains(A[], key) -> boolean+:: Test that future +A[key]+ exists.
-This function blocks until +A+ is closed. Consumers of +A[key]+ may
-block again until +A[key]+ is stored.
-
-=== Type conversion
-
-+fromint(int) -> string+:: Convert integer to string
-+toint(string) -> int+:: Convert string to integer
-+fromfloat(float) -> string+:: Convert float to string
-+tofloat(string) -> float+:: Convert string to float
-+itof(int) -> float+:: Convert integer to float
-+repr(*) -> string+:: Convert any type to internal
+ellipsis <tt>…</tt>.</p></div>
+<div class="paragraph"><p>A function that accepts more than one type is denoted as <tt>f(int|string)</tt>.</p></div>
+<div class="paragraph"><p>If a function is described below an <strong>Import:</strong> label, be sure to
+<tt>import</tt> that package.</p></div>
+<div class="sect2">
+<h3 id="_general">12.1. General</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>xor(boolean,boolean) → boolean</tt>
+</dt>
+<dd>
+<p>
+Exclusive logical or
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>make_void() → void</tt>
+</dt>
+<dd>
+<p>
+Create a void value
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>size(A[]) → int</tt>
+</dt>
+<dd>
+<p>
+Obtain the size of array <tt>A</tt>
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>contains(A[], key) → boolean</tt>
+</dt>
+<dd>
+<p>
+Test that future <tt>A[key]</tt> exists.
+This function blocks until <tt>A</tt> is closed. Consumers of <tt>A[key]</tt> may
+block again until <tt>A[key]</tt> is stored.
+</p>
+</dd>
+</dl></div>
+</div>
+<div class="sect2">
+<h3 id="_type_conversion">12.2. Type conversion</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>fromint(int) → string</tt>
+</dt>
+<dd>
+<p>
+Convert integer to string
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>toint(string) → int</tt>
+</dt>
+<dd>
+<p>
+Convert string to integer
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>fromfloat(float) → string</tt>
+</dt>
+<dd>
+<p>
+Convert float to string
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>tofloat(string) → float</tt>
+</dt>
+<dd>
+<p>
+Convert string to float
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>itof(int) → float</tt>
+</dt>
+<dd>
+<p>
+Convert integer to float
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>repr(*) → string</tt>
+</dt>
+<dd>
+<p>
+Convert any type to internal
string representation (exact format not guaranteed
to be consistent, even from call to call)
-+array_repr(*[]) -> string[]+:: Convert array of any type to internal
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>array_repr(*[]) → string[]</tt>
+</dt>
+<dd>
+<p>
+Convert array of any type to internal
string representation (exact format not guaranteed
to be consistent, even from call to call)
-
-=== Output
-
-+trace(anything, anything, ...)+:: Report the value of any variable
-
-*Import:* +io+
-
-+printf(string format, int|float|string|boolean...)+::
-As +printf()+ in C
-
-=== String functions
-
-+strcat(string,string)+: Concatenation
-
-*Import:* +string+
-
-+substring(string s, int start, int length) -> string+::
-Obtain substring of given string +s+ starting at character +start+ and of
-length +length+
-
-+find(string s, string substring, int start_index, int end_index) -> int+::
-Find the index of the first occurence of the string +substring+ within
-the string +s+ between the indices +start_index+ and +end_index+. Here
-an index of +-1+ passed to +end_index+ results in +end_index+ being
-treated as the length of the string +s+. +find+ returns +-1+ in case
-there is no occurence of +substring+ in +s+ in the specified range.
-
-+string_count(string s, string substring, int start_index, int end_index) -> int+::
-Counts the occurences of the string +substring+ within the string +s+
-between the indices +start_index+ and +end_index+. Here an index of
-+-1+ passed to +end_index+ results in +end_index+ being treated as the
-length of the string +s+
-
-+is_int(string s) -> boolean+::
-Returns true if string +s+ is a number, else false.
-
-+replace(string s, string substring, string rep_string, int start_index) -> string+::
+</p>
+</dd>
+</dl></div>
+</div>
+<div class="sect2">
+<h3 id="_output">12.3. Output</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>trace(anything, anything, …)</tt>
+</dt>
+<dd>
+<p>
+Report the value of any variable
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p><strong>Import:</strong> <tt>io</tt></p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>printf(string format, int|float|string|boolean…)</tt>
+</dt>
+<dd>
+<p>
+As <tt>printf()</tt> in C
+</p>
+</dd>
+</dl></div>
+</div>
+<div class="sect2">
+<h3 id="_string_functions">12.4. String functions</h3>
+<div class="paragraph"><p><tt>strcat(string,string)</tt>: Concatenation</p></div>
+<div class="paragraph"><p><strong>Import:</strong> <tt>string</tt></p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>substring(string s, int start, int length) → string</tt>
+</dt>
+<dd>
+<p>
+Obtain substring of given string <tt>s</tt> starting at character <tt>start</tt> and of
+length <tt>length</tt>
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>find(string s, string substring, int start_index, int end_index) → int</tt>
+</dt>
+<dd>
+<p>
+Find the index of the first occurence of the string <tt>substring</tt> within
+the string <tt>s</tt> between the indices <tt>start_index</tt> and <tt>end_index</tt>. Here
+an index of <tt>-1</tt> passed to <tt>end_index</tt> results in <tt>end_index</tt> being
+treated as the length of the string <tt>s</tt>. <tt>find</tt> returns <tt>-1</tt> in case
+there is no occurence of <tt>substring</tt> in <tt>s</tt> in the specified range.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>string_count(string s, string substring, int start_index, int end_index) → int</tt>
+</dt>
+<dd>
+<p>
+Counts the occurences of the string <tt>substring</tt> within the string <tt>s</tt>
+between the indices <tt>start_index</tt> and <tt>end_index</tt>. Here an index of
+<tt>-1</tt> passed to <tt>end_index</tt> results in <tt>end_index</tt> being treated as the
+length of the string <tt>s</tt>
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>is_int(string s) → boolean</tt>
+</dt>
+<dd>
+<p>
+Returns true if string <tt>s</tt> is a number, else false.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>replace(string s, string substring, string rep_string, int start_index) → string</tt>
+</dt>
+<dd>
+<p>
Obtain the string created by replacing the first occurence of the
-string +substring+ within string +s+, after the index +start_index+,
-with the string +rep_string+. In case there is no such occurence of
-the string +substring+ in string +s+, the original string +s+ is
+string <tt>substring</tt> within string <tt>s</tt>, after the index <tt>start_index</tt>,
+with the string <tt>rep_string</tt>. In case there is no such occurence of
+the string <tt>substring</tt> in string <tt>s</tt>, the original string <tt>s</tt> is
returned unmodified.
-
-+replace_all(string s, string substring, string rep_string, int start_index) -> string+::
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>replace_all(string s, string substring, string rep_string, int start_index) → string</tt>
+</dt>
+<dd>
+<p>
Obtain the string created by replacing all the occurences of the
-string +substring+ within string +s+, after the index +start_index+,
-with the string +rep_string+. In case no such occurence of +substring+
-exists in +s+, the original string +s+ is returned unmodified.
-
-+split(string s, string delimiter) -> string[]+::
-Tokenize string +s+ with given delimiter
-
-+trim(string s) -> string+::
-Remove leading and trailing whitespace from +s+
-
-+strlen(string) -> int+::
+string <tt>substring</tt> within string <tt>s</tt>, after the index <tt>start_index</tt>,
+with the string <tt>rep_string</tt>. In case no such occurence of <tt>substring</tt>
+exists in <tt>s</tt>, the original string <tt>s</tt> is returned unmodified.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>split(string s, string delimiter) → string[]</tt>
+</dt>
+<dd>
+<p>
+Tokenize string <tt>s</tt> with given delimiter
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>trim(string s) → string</tt>
+</dt>
+<dd>
+<p>
+Remove leading and trailing whitespace from <tt>s</tt>
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>strlen(string) → int</tt>
+</dt>
+<dd>
+<p>
Obtain the length of the given string
-
-+hash(string) -> int+::
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>hash(string) → int</tt>
+</dt>
+<dd>
+<p>
Hash the string to a 32-bit integer
-
-+sprintf(string format, int|float|string|boolean...)+::
-As +sprintf()+ in C
-
-+string_join(string A[], string separator) -> string+::
-Join strings in +A+ with given separator. The separator may be the
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>sprintf(string format, int|float|string|boolean…)</tt>
+</dt>
+<dd>
+<p>
+As <tt>sprintf()</tt> in C
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>string_join(string A[], string separator) → string</tt>
+</dt>
+<dd>
+<p>
+Join strings in <tt>A</tt> with given separator. The separator may be the
empty string
-
-=== Math
-
-+max|min_integer(int,int) -> int+:: Obtain maximum or minimum integer,
+</p>
+</dd>
+</dl></div>
+</div>
+<div class="sect2">
+<h3 id="_math">12.5. Math</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>max|min_integer(int,int) → int</tt>
+</dt>
+<dd>
+<p>
+Obtain maximum or minimum integer,
respectively
-+max|min_float(float,float) -> float+:: Obtain maximum or minimum float,
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>max|min_float(float,float) → float</tt>
+</dt>
+<dd>
+<p>
+Obtain maximum or minimum float,
respectively
-+pow_integer(int b,int x)+:: Obtain b^x^
-+pow_float(float b,float x)+:: Obtain b^x^
-
-*Import:* +math+
-
-+floor(float) -> int+:: Round down
-+ceil(float) -> int+:: Round up
-+round(float) -> int+:: Round nearest
-+log(float) -> float+:: Natural logarithm
-+exp(float) -> float+:: Natural exponentiation: e^i^
-+sqrt(float) -> float+:: Square root
-+is_nan(float) -> boolean+:: Check for NaN
-+abs_integer(int) -> int+:: Absolute value
-+abs_float(float) -> float+:: Absolute value
-
-*Import:* +random+
-
-+random() -> float+:: Obtain random number
-
-+randint(int start, int end)+::
-Obtain random integer from +start+, inclusive, to +end+, exclusive
-
-*Import:* stats
-
-+sum_integer(int[]) -> int+:: Sum
-+avg(int|float[]) -> float+:: Average
-
-=== System
-
-*Import:* +sys+
-
-+getenv(string) -> string+:: Obtain an environment variable
-
-[[argv]]
-==== Command line
-
-Consider this command line:
-
- turbine -l -n 3 program.tcl -v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt
-
-The arguments to +program.tcl+ are just the tokens after +program.tcl+
-
-+args() -> string+::
-
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>pow_integer(int b,int x)</tt>
+</dt>
+<dd>
+<p>
+Obtain b<sup>x</sup>
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>pow_float(float b,float x)</tt>
+</dt>
+<dd>
+<p>
+Obtain b<sup>x</sup>
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p><strong>Import:</strong> <tt>math</tt></p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>floor(float) → int</tt>
+</dt>
+<dd>
+<p>
+Round down
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>ceil(float) → int</tt>
+</dt>
+<dd>
+<p>
+Round up
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>round(float) → int</tt>
+</dt>
+<dd>
+<p>
+Round nearest
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>log(float) → float</tt>
+</dt>
+<dd>
+<p>
+Natural logarithm
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>exp(float) → float</tt>
+</dt>
+<dd>
+<p>
+Natural exponentiation: e<sup>i</sup>
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>sqrt(float) → float</tt>
+</dt>
+<dd>
+<p>
+Square root
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>is_nan(float) → boolean</tt>
+</dt>
+<dd>
+<p>
+Check for NaN
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>abs_integer(int) → int</tt>
+</dt>
+<dd>
+<p>
+Absolute value
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>abs_float(float) → float</tt>
+</dt>
+<dd>
+<p>
+Absolute value
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p><strong>Import:</strong> <tt>random</tt></p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>random() → float</tt>
+</dt>
+<dd>
+<p>
+Obtain random number
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>randint(int start, int end)</tt>
+</dt>
+<dd>
+<p>
+Obtain random integer from <tt>start</tt>, inclusive, to <tt>end</tt>, exclusive
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p><strong>Import:</strong> stats</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>sum_integer(int[]) → int</tt>
+</dt>
+<dd>
+<p>
+Sum
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>avg(int|float[]) → float</tt>
+</dt>
+<dd>
+<p>
+Average
+</p>
+</dd>
+</dl></div>
+</div>
+<div class="sect2">
+<h3 id="_system">12.6. System</h3>
+<div class="paragraph"><p><strong>Import:</strong> <tt>sys</tt></p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>getenv(string) → string</tt>
+</dt>
+<dd>
+<p>
+Obtain an environment variable
+</p>
+</dd>
+</dl></div>
+<div class="sect3">
+<h4 id="argv">12.6.1. Command line</h4>
+<div class="paragraph"><p>Consider this command line:</p></div>
+<div class="literalblock">
+<div class="content">
+<pre><tt>turbine -l -n 3 program.tcl -v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt</tt></pre>
+</div></div>
+<div class="paragraph"><p>The arguments to <tt>program.tcl</tt> are just the tokens after <tt>program.tcl</tt></p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>args() → string</tt>
+</dt>
+<dd>
+<p>
Obtain all arguments as single string
-+
-E.g., +"-v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt"+
-
-The remaining functions are convenience functions oriented around
+</p>
+<div class="paragraph"><p>E.g., <tt>"-v -a=file1.txt file2.txt --exec="prog thing1 thing2" --help file4.txt"</tt></p></div>
+</dd>
+</dl></div>
+<div class="paragraph"><p>The remaining functions are convenience functions oriented around
Swift conventions. Under these conventions, the example command above
-has _flagged_ arguments +v+, +a=file.txt+, +exec="prog thing1
-thing2"+, and +help+. The command has _unflagged_ arguments
-+file2.txt+ and +file4.txt+
-
-+argc()+::
+has <em>flagged</em> arguments <tt>v</tt>, <tt>a=file.txt</tt>, <tt>exec="prog thing1
+thing2"</tt>, and <tt>help</tt>. The command has <em>unflagged</em> arguments
+<tt>file2.txt</tt> and <tt>file4.txt</tt></p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>argc()</tt>
+</dt>
+<dd>
+<p>
Get count of unflagged arguments
-
-+argv(string)+::
-_(argument-value)_
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>argv(string)</tt>
+</dt>
+<dd>
+<p>
+<em>(argument-value)</em>
Given a string, returns the flagged argument with that key:
-+
-+argv("a") -> file1.txt+
-+
-In addition to regular run-time arguments, the STC _compile-time
-arguments_ feature allows +argv()+ arguments to be provided at compile
+</p>
+<div class="paragraph"><p><tt>argv("a") → file1.txt</tt></p></div>
+<div class="paragraph"><p>In addition to regular run-time arguments, the STC <em>compile-time
+arguments</em> feature allows <tt>argv()</tt> arguments to be provided at compile
time. This allows a specialized, optimized version of code to be
-compiled for a particular set of arguments. See the +-A
-_name_=_value_+ <<stc_arguments,argument>> to +stc+. Note that if the
-argument is re-specified at run-time, an error will occur.
-
-+argp(int)+::
-_(argument-positional)_
+compiled for a particular set of arguments. See the <tt>-A
+<em>name</em>=<em>value</em></tt> <a href="#stc_arguments">argument</a> to <tt>stc</tt>. Note that if the
+argument is re-specified at run-time, an error will occur.</p></div>
+</dd>
+<dt class="hdlist1">
+<tt>argp(int)</tt>
+</dt>
+<dd>
+<p>
+<em>(argument-positional)</em>
Given an integer, returns the unflagged argument at that index:
-+
-+argp(2) -> file4.txt+
-+
-Given 0, returns the program name,
-+
-+argp(0) -> /path/to/program.tcl+
-
-+argv_accept(string...)+::
-
+</p>
+<div class="paragraph"><p><tt>argp(2) → file4.txt</tt></p></div>
+<div class="paragraph"><p>Given 0, returns the program name,</p></div>
+<div class="paragraph"><p><tt>argp(0) → /path/to/program.tcl</tt></p></div>
+</dd>
+<dt class="hdlist1">
+<tt>argv_accept(string…)</tt>
+</dt>
+<dd>
+<p>
If program is given flagged command line arguments not contained in given
list, abort.
-E.g., +argv_accept("x")+ would cause program failure at run time
-
-+argv_contains(string) -> boolean+::
-
+E.g., <tt>argv_accept("x")</tt> would cause program failure at run time
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>argv_contains(string) → boolean</tt>
+</dt>
+<dd>
+<p>
Test if the command line contains the given flagged argument:
-+
-+argv_contains("v") -> true+
-
-==== Debugging
-
-*Import:* +assert+
-
-+assert(boolean condition, string message)+::
-If condition is false, report +message+ and exit immediately.
-
-[[Turbine_information]]
-==== Turbine information
-
-+adlb_servers() -> int+:: Number of ADLB servers
-+turbine_workers() -> int+:: Number of Turbine workers
-
-=== Files
-
-+filename(file) -> string+:: Obtain the name of a file
-+input(string) -> file+:: Obtain a +file+. At run time, the
+</p>
+<div class="paragraph"><p><tt>argv_contains("v") → true</tt></p></div>
+</dd>
+</dl></div>
+</div>
+<div class="sect3">
+<h4 id="_debugging">12.6.2. Debugging</h4>
+<div class="paragraph"><p><strong>Import:</strong> <tt>assert</tt></p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>assert(boolean condition, string message)</tt>
+</dt>
+<dd>
+<p>
+If condition is false, report <tt>message</tt> and exit immediately.
+</p>
+</dd>
+</dl></div>
+</div>
+<div class="sect3">
+<h4 id="Turbine_information">12.6.3. Turbine information</h4>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>adlb_servers() → int</tt>
+</dt>
+<dd>
+<p>
+Number of ADLB servers
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>turbine_workers() → int</tt>
+</dt>
+<dd>
+<p>
+Number of Turbine workers
+</p>
+</dd>
+</dl></div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_files_2">12.7. Files</h3>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>filename(file) → string</tt>
+</dt>
+<dd>
+<p>
+Obtain the name of a file
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>input(string) → file</tt>
+</dt>
+<dd>
+<p>
+Obtain a <tt>file</tt>. At run time, the
filesystem is checked for the given file name
-+input_file(string) -> file+:: Alias for +input()+
-+input_url(string) -> file+:: Obtain a +file+. Some
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>input_file(string) → file</tt>
+</dt>
+<dd>
+<p>
+Alias for <tt>input()</tt>
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>input_url(string) → file</tt>
+</dt>
+<dd>
+<p>
+Obtain a <tt>file</tt>. Some
automatic operations and optimizations are disabled
-+urlname(file) -> string+:: Obtain the name of a file created with
-+input_url()+
-
-*Import:* +files+
-
-+read(file) -> string+:: Read file as a string
-+write(string) -> file+:: Write string to file
-
-+file_lines(file) -> string[]+::
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>urlname(file) → string</tt>
+</dt>
+<dd>
+<p>
+Obtain the name of a file created with
+<tt>input_url()</tt>
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p><strong>Import:</strong> <tt>files</tt></p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>read(file) → string</tt>
+</dt>
+<dd>
+<p>
+Read file as a string
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>write(string) → file</tt>
+</dt>
+<dd>
+<p>
+Write string to file
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>file_lines(file) → string[]</tt>
+</dt>
+<dd>
+<p>
Reads the whole file, returning each line as a separate entry in the
-output array. Comments with +#+ are excised, leading and trailing
+output array. Comments with <tt>#</tt> are excised, leading and trailing
whitespace is trimmed, and blank lines are omitted.
-
-+glob(string) -> file[]+:: Perform glob operation, returning files
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>glob(string) → file[]</tt>
+</dt>
+<dd>
+<p>
+Perform glob operation, returning files
that match. Available glob symbols include:
-+
-* +*+: any character sequence (including the zero-length sequence)
-* +?+: any character
-* +[chars]+: any of the given characters
-* +\x+: character +x+
-* +{a,b,c,...}+ any of +a+, +b+, +c+, etc.
-
-=== Blobs
-
-*Import:* +blob+
-
-+blob_size(blob) -> int+:: Obtain the size of a blob in bytes.
-
-+blob_null() -> blob+:: Obtain an empty blob of size 0.
-
-+blob_from_string(string) -> blob+:: Convert a string into a blob.
-
-+string_from_blob(blob) -> string+:: Convert a blob into a string. If
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+<tt>*</tt>: any character sequence (including the zero-length sequence)
+</p>
+</li>
+<li>
+<p>
+<tt>?</tt>: any character
+</p>
+</li>
+<li>
+<p>
+<tt>[chars]</tt>: any of the given characters
+</p>
+</li>
+<li>
+<p>
+<tt>\x</tt>: character <tt>x</tt>
+</p>
+</li>
+<li>
+<p>
+<tt>{a,b,c,…}</tt> any of <tt>a</tt>, <tt>b</tt>, <tt>c</tt>, etc.
+</p>
+</li>
+</ul></div>
+</dd>
+</dl></div>
+</div>
+<div class="sect2">
+<h3 id="_blobs_2">12.8. Blobs</h3>
+<div class="paragraph"><p><strong>Import:</strong> <tt>blob</tt></p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>blob_size(blob) → int</tt>
+</dt>
+<dd>
+<p>
+Obtain the size of a blob in bytes.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>blob_null() → blob</tt>
+</dt>
+<dd>
+<p>
+Obtain an empty blob of size 0.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>blob_from_string(string) → blob</tt>
+</dt>
+<dd>
+<p>
+Convert a string into a blob.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>string_from_blob(blob) → string</tt>
+</dt>
+<dd>
+<p>
+Convert a blob into a string. If
the blob is not NULL-terminated, this function appends the
NULL-terminator.
-
-+blob_from_floats(float[]) -> blob+:: Convert an array of Swift floats
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>blob_from_floats(float[]) → blob</tt>
+</dt>
+<dd>
+<p>
+Convert an array of Swift floats
(implemented as doubles) to blob containing the C-formatted array of
doubles .
-
-+blob_from_floats(blob) -> float[]+:: Convert blob containing the
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>blob_from_floats(blob) → float[]</tt>
+</dt>
+<dd>
+<p>
+Convert blob containing the
C-formatted array of doubles to an array of Swift floats
(implemented as doubles).
-
-+blob_from_ints(int i[]) -> blob+:: Convert blob containing the
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>blob_from_ints(int i[]) → blob</tt>
+</dt>
+<dd>
+<p>
+Convert blob containing the
C-formatted array of ints to an array of Swift ints (implemented
as 64-bit integers).
-
-+blob_from_file(file) -> blob+:: Reads whole file, returning it as a
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>blob_from_file(file) → blob</tt>
+</dt>
+<dd>
+<p>
+Reads whole file, returning it as a
blob.
-
-[[library_location]]
-=== Location
-
-See the section about <<location,location>>.
-
-+location_from_rank(int) -> location+:: Convert the rank integer to a
-+location+ variable compatible with + at location+.
-
-+random_worker() -> location+:: Obtain a worker at random.
-
-+hostmap_list() -> string[]+:: Obtain the whole hostmap.
-
-+hostmap_one(string) -> location+:: Lookup the string as a host in the
+</p>
+</dd>
+</dl></div>
+</div>
+<div class="sect2">
+<h3 id="library_location">12.9. Location</h3>
+<div class="paragraph"><p>See the section about <a href="#location">location</a>.</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>location_from_rank(int) → location</tt>
+</dt>
+<dd>
+<p>
+Convert the rank integer to a
+<tt>location</tt> variable compatible with <tt>@location</tt>.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>random_worker() → location</tt>
+</dt>
+<dd>
+<p>
+Obtain a worker at random.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>hostmap_list() → string[]</tt>
+</dt>
+<dd>
+<p>
+Obtain the whole hostmap.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>hostmap_one(string) → location</tt>
+</dt>
+<dd>
+<p>
+Lookup the string as a host in the
hostmap and return one rank running on that host.
-
-+hostmap_one_worker(string) -> location+:: Lookup the string as a host
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>hostmap_one_worker(string) → location</tt>
+</dt>
+<dd>
+<p>
+Lookup the string as a host
in the hostmap and return one worker rank running on that host.
-
-== Defining leaf functions
-
-In typical Swift applications, the computationally intensive parts of
+</p>
+</dd>
+</dl></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_defining_leaf_functions">13. Defining leaf functions</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>In typical Swift applications, the computationally intensive parts of
the application are not written in the Swift language. Rather, the
-work is done by _leaf functions_ that are _composed_ together with
-Swift code. Leaf functions may be extension or app functions.
-
-The Swift runtime, Turbine, is built on Tcl, a language which intends
-to makes it easy to call C/C\+\+/Fortran functions. The builtin
+work is done by <em>leaf functions</em> that are <em>composed</em> together with
+Swift code. Leaf functions may be extension or app functions.</p></div>
+<div class="paragraph"><p>The Swift runtime, Turbine, is built on Tcl, a language which intends
+to makes it easy to call C/C++/Fortran functions. The builtin
functions mentioned above are implemented as extension functions in
-Tcl, which may wrap C/C++/Fortran functions.
-
-=== Swift extension functions
-
-Currently we support Tcl extension functions, where a function is
+Tcl, which may wrap C/C++/Fortran functions.</p></div>
+<div class="sect2">
+<h3 id="_swift_extension_functions">13.1. Swift extension functions</h3>
+<div class="paragraph"><p>Currently we support Tcl extension functions, where a function is
implemented as a Tcl function. Tcl has good support for wrapping
-native C/C\++ functions, so this provides an indirect way to call
-C/C++ functions from Swift.
-
-Several components are required to implement a Swift native code function:
-
-- Tcl bindings to your function.
-- The requisite files required to build a Tcl package
- (e.g +pkgIndex.tcl+)
-- Swift declarations for the function that specify the type of the
+native C/C++ functions, so this provides an indirect way to call
+C/C++ functions from Swift.</p></div>
+<div class="paragraph"><p>Several components are required to implement a Swift native code function:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+Tcl bindings to your function.
+</p>
+</li>
+<li>
+<p>
+The requisite files required to build a Tcl package
+ (e.g <tt>pkgIndex.tcl</tt>)
+</p>
+</li>
+<li>
+<p>
+Swift declarations for the function that specify the type of the
function and the Tcl implementation.
-
-==== Simple Tcl fragment example
-
-In this example, the Swift program will simply use Tcl to output a
-string:
-
-----
-() my_output (string s) "turbine" "0.0" [
- "puts <<s>>"
+</p>
+</li>
+</ul></div>
+<div class="sect3">
+<h4 id="_simple_tcl_fragment_example">13.1.1. Simple Tcl fragment example</h4>
+<div class="paragraph"><p>In this example, the Swift program will simply use Tcl to output a
+string:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>() my_output (string s) "turbine" "0.0" [
+ "puts <<s>>"
];
main {
my_output("HELLO");
-}
-----
-
-+puts+ is the Tcl builtin for screen output, like +puts()+ in C.
-
-The above definition has, from left to right, the output arguments
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p><tt>puts</tt> is the Tcl builtin for screen output, like <tt>puts()</tt> in C.</p></div>
+<div class="paragraph"><p>The above definition has, from left to right, the output arguments
(none), the name of the new Swift function, input arguments, the name
of the Tcl package containing the file (here, none, so we use
-+turbine+), and the minimum version of that package (here, 0.0).
-
-We tell the compiler how to call our Tcl function using inline
-Tcl code as a template with variable names surrounded by +<< >>+
-indicating where variables should be substituted.
-
-==== Simple Tcl package example
-
-In this first example we will implement a trivial Tcl extension function
+<tt>turbine</tt>), and the minimum version of that package (here, 0.0).</p></div>
+<div class="paragraph"><p>We tell the compiler how to call our Tcl function using inline
+Tcl code as a template with variable names surrounded by <tt><< >></tt>
+indicating where variables should be substituted.</p></div>
+</div>
+<div class="sect3">
+<h4 id="_simple_tcl_package_example">13.1.2. Simple Tcl package example</h4>
+<div class="paragraph"><p>In this first example we will implement a trivial Tcl extension function
that doubles an integer. Here is the Tcl code that will go in
-+myextension.tcl+:
-
-----
-namespace eval myextension {
+<tt>myextension.tcl</tt>:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>namespace eval myextension {
proc double { x } {
return [ expr $x * 2 ]
}
-}
-----
-
-Here is the Swift function definition that will go in +myextension.swift+:
-----
- at pure
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>Here is the Swift function definition that will go in <tt>myextension.swift</tt>:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>@pure
(int o) double (int i) "myextension" "0.0.1" [
- "set <<o>> [ myextension::double <<i>> ]"
-];
-----
-
-We can also tell the Swift compiler a little about the function so
-that it can better optimize your programs. For example, +double+ has
+ "set <<o>> [ myextension::double <<i>> ]"
+];</tt></pre>
+</div></div>
+<div class="paragraph"><p>We can also tell the Swift compiler a little about the function so
+that it can better optimize your programs. For example, <tt>double</tt> has
no side-effects and produces the same result each time for the same
-arguments (i.e. is deterministic), so we can annotate it as a + at pure+
-function.
-
-If your function has a long running time and should be dispatched to a
+arguments (i.e. is deterministic), so we can annotate it as a <tt>@pure</tt>
+function.</p></div>
+<div class="paragraph"><p>If your function has a long running time and should be dispatched to a
worker process for execution, then you need to label the function as a
-worker function, for example:
-
-----
- at dispatch=WORKER
+worker function, for example:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>@dispatch=WORKER
(int o) process (int i) "pkg" "0.0.1" [
- "set <<o>> [ pkg::process <<i>> ]"
-];
-----
-
-Tcl code is conventionally placed into _packages_. In this example,
-+myextension.tcl+ would be part of the package.
-
-More information about building Tcl packages may be found
-http://www.tcl.tk/man/tcl8.5/TclCmd/pkgMkIndex.htm[here]. Ultimately,
-you produce a +pkgIndex.tcl+ file that contains necessary information
-about the package.
-
-To ensure that Swift can find your package, use
-----
-stc -r <package directory> ...
-----
-or set +TURBINE_USER_LIB+ at run time.
-
-* *Tip:* advanced users can also create <<mkstatic,standalone executables>>
+ "set <<o>> [ pkg::process <<i>> ]"
+];</tt></pre>
+</div></div>
+<div class="paragraph"><p>Tcl code is conventionally placed into <em>packages</em>. In this example,
+<tt>myextension.tcl</tt> would be part of the package.</p></div>
+<div class="paragraph"><p>More information about building Tcl packages may be found
+<a href="http://www.tcl.tk/man/tcl8.5/TclCmd/pkgMkIndex.htm">here</a>. Ultimately,
+you produce a <tt>pkgIndex.tcl</tt> file that contains necessary information
+about the package.</p></div>
+<div class="paragraph"><p>To ensure that Swift can find your package, use</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>stc -r <package directory> ...</tt></pre>
+</div></div>
+<div class="paragraph"><p>or set <tt>TURBINE_USER_LIB</tt> at run time.</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+<strong>Tip:</strong> advanced users can also create <a href="#mkstatic">standalone executables</a>
with compiled code and Tcl code for the extension directly linked in.
-
-==== Swift/Tcl data type mapping
-
-If you are defining Tcl functions in the way above with inline
-Tcl code, Swift types are mapped to Tcl types in the following way:
-
-* +int+/+float+/+string+/+bool+ are converted to the standard
+</p>
+</li>
+</ul></div>
+</div>
+<div class="sect3">
+<h4 id="_swift_tcl_data_type_mapping">13.1.3. Swift/Tcl data type mapping</h4>
+<div class="paragraph"><p>If you are defining Tcl functions in the way above with inline
+Tcl code, Swift types are mapped to Tcl types in the following way:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+<tt>int</tt>/<tt>float</tt>/<tt>string</tt>/<tt>bool</tt> are converted to the standard
Tcl representations.
-* blobs are represented as a Tcl list with first element a pointer
+</p>
+</li>
+<li>
+<p>
+blobs are represented as a Tcl list with first element a pointer
to the data, the second element the length of the data, and if
the blob was loaded from the ADLB data store, a third element
which is the ADLB ID of the blob.
-* files are represented as a list, with the first element the
+</p>
+</li>
+<li>
+<p>
+files are represented as a list, with the first element the
file path, and the second element a reference count
-* arrays are represented by Tcl dictionaries with keys and values
+</p>
+</li>
+<li>
+<p>
+arrays are represented by Tcl dictionaries with keys and values
represented according to their type.
-* bags are represented by Tcl lists with elements in an arbitrary
+</p>
+</li>
+<li>
+<p>
+bags are represented by Tcl lists with elements in an arbitrary
order.
-* output voids are set automatically.
-
-==== Calling native libraries from Swift
-
-The first step is to test that you can successfully call your
+</p>
+</li>
+<li>
+<p>
+output voids are set automatically.
+</p>
+</li>
+</ul></div>
+</div>
+<div class="sect3">
+<h4 id="_calling_native_libraries_from_swift">13.1.4. Calling native libraries from Swift</h4>
+<div class="paragraph"><p>The first step is to test that you can successfully call your
C/C++/Fortran function from a test Tcl script. If so, you will then
-be able to use the Swift->Tcl techniques to call it from Swift.
-
-A popular tool to automate Tcl->C bindings is
-http://www.swig.org[SWIG], which will wrap your C/C++ functions and
-help you produce a Tcl package suitable for use by Swift.
-
-To call Fortran functions, first wrap your code with
-http://fortwrap.sourceforge.net[FortWrap]. Then, use SWIG to produce
-Tcl bindings.
-
-==== Writing custom Tcl interfaces
-
-It is possible to write a Tcl wrapper function that is
-directly passed references to data in Swift's global data store. In
+be able to use the Swift→Tcl techniques to call it from Swift.</p></div>
+<div class="paragraph"><p>A popular tool to automate Tcl→C bindings is
+<a href="http://www.swig.org">SWIG</a>, which will wrap your C/C++ functions and
+help you produce a Tcl package suitable for use by Swift.</p></div>
+<div class="paragraph"><p>To call Fortran functions, first wrap your code with
+<a href="http://fortwrap.sourceforge.net">FortWrap</a>. Then, use SWIG to produce
+Tcl bindings.</p></div>
+</div>
+<div class="sect3">
+<h4 id="_writing_custom_tcl_interfaces">13.1.5. Writing custom Tcl interfaces</h4>
+<div class="paragraph"><p>It is possible to write a Tcl wrapper function that is
+directly passed references to data in Swift’s global data store. In
this case your function must manually retrieve/store data from/to the
global distributed data store. In this case, you do not use the STC
-Tcl argument substitution syntax (+<<++i++>>+).
-
-Consider this custom Swift->Tcl binding:
-----
-(int o) complex_function (int arr[]) "pkg" "0.0.1" "complex";
-----
-
-This function jumps into Tcl function +complex+, which must
-perform its own data dependency management.
-
-See the link:leaf.html[Swift/T Leaf Function Guide] for more
-information about this process.
-
-[[app_functions]]
-=== App functions
-
-App functions are functions that are implemented as command-line
+Tcl argument substitution syntax (<tt><<<tt>i</tt>>></tt>).</p></div>
+<div class="paragraph"><p>Consider this custom Swift→Tcl binding:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>(int o) complex_function (int arr[]) "pkg" "0.0.1" "complex";</tt></pre>
+</div></div>
+<div class="paragraph"><p>This function jumps into Tcl function <tt>complex</tt>, which must
+perform its own data dependency management.</p></div>
+<div class="paragraph"><p>See the <a href="leaf.html">Swift/T Leaf Function Guide</a> for more
+information about this process.</p></div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="app_functions">13.2. App functions</h3>
+<div class="paragraph"><p>App functions are functions that are implemented as command-line
programs. These command-line programs can be brought into a Swift
program as functions with typed inputs and outputs.
-An app function definition comprises:
-
-* The standard components of a Swift function declaration: input and
+An app function definition comprises:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+The standard components of a Swift function declaration: input and
output arguments and the function name. Note that the output
- variable types are restricted to individual +file+#s#.
-* The command line, which comprises an initial string which is the
+ variable types are restricted to individual <tt>file</tt>s.
+</p>
+</li>
+<li>
+<p>
+The command line, which comprises an initial string which is the
executable to run, and then a series of arguments which are
the command-line arguments to pass to the program.
-
-App arguments can be:
-
-* Literals such as numbers or strings.
-* File variables (passed as file paths).
-* Other variables, which are converted to string arguments.
+</p>
+</li>
+</ul></div>
+<div class="paragraph"><p>App arguments can be:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+Literals such as numbers or strings.
+</p>
+</li>
+<li>
+<p>
+File variables (passed as file paths).
+</p>
+</li>
+<li>
+<p>
+Other variables, which are converted to string arguments.
Arrays (including multi-dimensional arrays) are expanded to
multiple arguments.
-* Arbitrary expressions surrounded by parentheses.
+</p>
+</li>
+<li>
+<p>
+Arbitrary expressions surrounded by parentheses.
+</p>
+</li>
+</ul></div>
+<div class="paragraph"><p>Standard input, output and error can be redirected to files via
+<tt>@stdin=</tt>, <tt>@stdout=</tt>, and <tt>@stderr=</tt> expressions. If used, these should point
+to a <tt>file</tt>.</p></div>
+<div class="paragraph"><p>Here is an example of an app function that joins multiple files
+with the <tt>cat</tt> utility:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>import files;
-Standard input, output and error can be redirected to files via
-+ at stdin=+, + at stdout=+, and + at stderr=+ expressions. If used, these should point
-to a +file+.
-
-Here is an example of an app function that joins multiple files
-with the +cat+ utility:
-----
-import files;
-
app (file out) cat (file inputs[]) {
"/bin/cat" inputs @stdout=out
}
main {
- file joined <"joined.txt"> = cat(glob("*.txt"));
-}
-----
-
-Here is an example of an app function that sleeps for an arbitrary
-amount of time:
-----
-
-app (void signal) sleep (int secs) {
+ file joined <"joined.txt"> = cat(glob("*.txt"));
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>Here is an example of an app function that sleeps for an arbitrary
+amount of time:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>app (void signal) sleep (int secs) {
"/bin/sleep" secs
}
@@ -1382,48 +2772,44 @@
trace("Slept " + fromint(time));
}
}
-}
-----
-
-=== External scripting support
-
-==== Calling Python
-
-You can evaluate arbitrary Python code from within Swift/T. For
+}</tt></pre>
+</div></div>
+</div>
+<div class="sect2">
+<h3 id="_external_scripting_support">13.3. External scripting support</h3>
+<div class="sect3">
+<h4 id="_calling_python">13.3.1. Calling Python</h4>
+<div class="paragraph"><p>You can evaluate arbitrary Python code from within Swift/T. For
example, you can perform processing with a Python library.
Once you have that working, you can use Swift/T to coordinate
-concurrent calls to that library.
-
-Consider the following Swift script:
-
-----
-import io;
+concurrent calls to that library.</p></div>
+<div class="paragraph"><p>Consider the following Swift script:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>import io;
import python;
main {
i = python("print(\"python works\")\nrepr(2+2)");
printf("i: %s", i);
-}
-----
-
-This simply evaluates the Python code line by line. The last line must
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>This simply evaluates the Python code line by line. The last line must
return a Python string to Swift, in this case, the Python string
-+'4'+. The expected output is shown below:
-
-----
-python works
-i: 4
-----
-
-Swift multi-line strings may be used to enter more complex Python code
-without the explicit use of +\n+.
-
-Additionally, you can call Python libraries such as
-http://www.numpy.org[Numpy] if available on your system. The
-following code adds matrices _I_~3~ + _I_~3~ using Numpy arrays.
-
-----
-import io;
+<tt>'4'</tt>. The expected output is shown below:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>python works
+i: 4</tt></pre>
+</div></div>
+<div class="paragraph"><p>Swift multi-line strings may be used to enter more complex Python code
+without the explicit use of <tt>\n</tt>.</p></div>
+<div class="paragraph"><p>Additionally, you can call Python libraries such as
+<a href="http://www.numpy.org">Numpy</a> if available on your system. The
+following code adds matrices <em>I</em><sub>3</sub> + <em>I</em><sub>3</sub> using Numpy arrays.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>import io;
import python;
import string;
@@ -1453,42 +2839,48 @@
matrix A2 = eye(3);
matrix sum = add(A1, A2);
printf("2*eye(3)=%s", sum);
-}
-----
-
-An Python script template is created that imports Numpy and performs
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>An Python script template is created that imports Numpy and performs
some simple calculations. This code is represented in a Swift string.
-The template is filled in by the Swift call to +sprintf()+. Then, the
-code is passed to Python for evaluation. The output is:
-
-----
-2*eye(3)=array([[ 2., 0., 0.],
+The template is filled in by the Swift call to <tt>sprintf()</tt>. Then, the
+code is passed to Python for evaluation. The output is:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>2*eye(3)=array([[ 2., 0., 0.],
[ 0., 2., 0.],
- [ 0., 0., 2.]])
-----
-
-NOTE: To use this, Turbine must be configured with Python enabled
- before compiling, by setting +ENABLE_PYTHON=1+
- in +exm-settings.sh+, or by providing the +--enable-python+ argument
- to +configure+. This feature is implemented by linking to Python
+ [ 0., 0., 2.]])</tt></pre>
+</div></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">To use this, Turbine must be configured with Python enabled
+ before compiling, by setting <tt>ENABLE_PYTHON=1</tt>
+ in <tt>exm-settings.sh</tt>, or by providing the <tt>--enable-python</tt> argument
+ to <tt>configure</tt>. This feature is implemented by linking to Python
as a shared library, enabling better performance than calling the
- +python+ program (which may be done by using a normal Swift
- <<app_functions,app function>>). Error messages for minor coding
+ <tt>python</tt> program (which may be done by using a normal Swift
+ <a href="#app_functions">app function</a>). Error messages for minor coding
mistakes may be badly mangled and refer to missing Python symbols-
- refer to the first error in the Python stack trace.
-
-==== Calling R
-
-Consider the following Swift script:
-----
-import io;
+ refer to the first error in the Python stack trace.</td>
+</tr></table>
+</div>
+</div>
+<div class="sect3">
+<h4 id="_calling_r">13.3.2. Calling R</h4>
+<div class="paragraph"><p>Consider the following Swift script:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>import io;
import string;
import R;
global const string template =
"""
- x <- %i
- a <- x+100
+ x <- %i
+ a <- x+100
cat("the answer is: ", a, "\\n")
a
""";
@@ -1498,38 +2890,42 @@
code = sprintf(template, 4);
s = R(code);
printf("the answer was: %i", s);
-}
-----
-
-An http://www.r-project.org[R language] script template is placed in a
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>An <a href="http://www.r-project.org">R language</a> script template is placed in a
Swift string. The template is filled in with the value 4 by the Swift
-call to +sprintf()+ (note the +%i+ conversion specifier). Then, the
-code is passed to R for evaluation. The output is:
-
-----
-the answer is: 104
-the answer was: 104
-----
-
-As coded here, both R and Swift report the value of +a+.
-
-NOTE: To use this, Turbine must be configured with R enabled
- before compiling, by setting +ENABLE_R=1+
- in +exm-settings.sh+, or by providing the +--enable-r+ argument
- to +configure+. This feature is implemented by linking to R as a shared
- library, enabling better performance than calling the +R+ program
- (which may be done by using a normal Swift <<app_functions,app
- function>>). When installing R, be sure to include the +devel+
+call to <tt>sprintf()</tt> (note the <tt>%i</tt> conversion specifier). Then, the
+code is passed to R for evaluation. The output is:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>the answer is: 104
+the answer was: 104</tt></pre>
+</div></div>
+<div class="paragraph"><p>As coded here, both R and Swift report the value of <tt>a</tt>.</p></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">To use this, Turbine must be configured with R enabled
+ before compiling, by setting <tt>ENABLE_R=1</tt>
+ in <tt>exm-settings.sh</tt>, or by providing the <tt>--enable-r</tt> argument
+ to <tt>configure</tt>. This feature is implemented by linking to R as a shared
+ library, enabling better performance than calling the <tt>R</tt> program
+ (which may be done by using a normal Swift <a href="#app_functions">app function</a>). When installing R, be sure to include the <tt>devel</tt>
package. When installing R from source, configure with
- +--enable-R-shlib+. You may need to set the environment variable
- +R_HOME+ to the directory containing the R installation. For the APT
- package, this is +/usr/lib/R+.
-
-==== Calling Julia
-
-Consider the following Swift script:
-----
-import io;
+ <tt>--enable-R-shlib</tt>. You may need to set the environment variable
+ <tt>R_HOME</tt> to the directory containing the R installation. For the APT
+ package, this is <tt>/usr/lib/R</tt>.</td>
+</tr></table>
+</div>
+</div>
+<div class="sect3">
+<h4 id="_calling_julia">13.3.3. Calling Julia</h4>
+<div class="paragraph"><p>Consider the following Swift script:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>import io;
import julia;
import string;
import sys;
@@ -1553,108 +2949,103 @@
wait (s1, s2, s3) {
printf("duration: %0.2f", clock()-start);
}
-}
-----
-
-In this example, a http://julialang.org[Julia] script is placed in
-string +f+. It is parameterized three times by +sprintf()+. Each
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>In this example, a <a href="http://julialang.org">Julia</a> script is placed in
+string <tt>f</tt>. It is parameterized three times by <tt>sprintf()</tt>. Each
Julia invocation runs concurrently (if enough processes are provided
-to Swift/T).
-
-NOTE: To use this, Turbine must be configured with Julia enabled
- before compiling, by providing the +--enable-julia+ argument
- to +configure+. This feature is implemented by linking to Julia
+to Swift/T).</p></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">To use this, Turbine must be configured with Julia enabled
+ before compiling, by providing the <tt>--enable-julia</tt> argument
+ to <tt>configure</tt>. This feature is implemented by linking to Julia
as a shared library, enabling better performance than calling the
- +julia+ program (which may be done by using a normal Swift
- <<app_functions,app function>>).
-
-[[annotations]]
-== Annotations
-
-Swift/T supports many annotations to influence the behavior of the
-run.
-
-=== Priority
-
-Leaf tasks resulting from Swift dataflow may be prioritized by using
-the + at prio+ annotation:
-
-----
-foreach i in [0:n-1] {
+ <tt>julia</tt> program (which may be done by using a normal Swift
+ <a href="#app_functions">app function</a>).</td>
+</tr></table>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="annotations">14. Annotations</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Swift/T supports many annotations to influence the behavior of the
+run.</p></div>
+<div class="sect2">
+<h3 id="_priority">14.1. Priority</h3>
+<div class="paragraph"><p>Leaf tasks resulting from Swift dataflow may be prioritized by using
+the <tt>@prio</tt> annotation:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>foreach i in [0:n-1] {
@prio=i f(i);
-}
-----
-
-In this case, +f()+ will operate on higher values of +i+ first.
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>In this case, <tt>f()</tt> will operate on higher values of <tt>i</tt> first.
Priority is best-effort; it is local to the ADLB server. The values
-of +i+ may be any Swift integer.
-
-This annotation is applied to the leaf task call.
-
-[[location]]
-=== Location
-
-Leaf tasks resulting from Swift dataflow may be assigned to a given
-processor by using the + at location+ annotation:
-
-----
-foreach i in [0:n-1] {
+of <tt>i</tt> may be any Swift integer.</p></div>
+<div class="paragraph"><p>This annotation is applied to the leaf task call.</p></div>
+</div>
+<div class="sect2">
+<h3 id="location">14.2. Location</h3>
+<div class="paragraph"><p>Leaf tasks resulting from Swift dataflow may be assigned to a given
+processor by using the <tt>@location</tt> annotation:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>foreach i in [0:n-1] {
location L = location_from_rank(i);
@location=L f(i);
-}
-----
-
-In this case, each +f(i)+ will execute on a different worker.
-
-This annotation is applied to the leaf task call.
-
-==== Hostmap
-
-At startup, by default, Turbine obtains all hostnames used in the run
+}</tt></pre>
+</div></div>
+<div class="paragraph"><p>In this case, each <tt>f(i)</tt> will execute on a different worker.</p></div>
+<div class="paragraph"><p>This annotation is applied to the leaf task call.</p></div>
+<div class="sect3">
+<h4 id="_hostmap">14.2.1. Hostmap</h4>
+<div class="paragraph"><p>At startup, by default, Turbine obtains all hostnames used in the run
and builds up a data structure called the hostmap to map hostnames to
ranks. You may combine the location features with the hostmap
features to send work to assigned hostnames. See the
-<<library_location,Location library>> for usage. The hostmap may be
-<<env_hostmap_debug,debugged>> or <<env_hostmap_disable,disabled>>.
-
-=== Dispatch
-
-This simply dispatches tasks to the given process type: +WORKER+ or
-+SERVER+. By default, work executes on a +SERVER+.
-
-----
- at dispatch=WORKER
+<a href="#library_location">Location library</a> for usage. The hostmap may be
+<a href="#env_hostmap_debug">debugged</a> or <a href="#env_hostmap_disable">disabled</a>.</p></div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_dispatch">14.3. Dispatch</h3>
+<div class="paragraph"><p>This simply dispatches tasks to the given process type: <tt>WORKER</tt> or
+<tt>SERVER</tt>. By default, work executes on a <tt>SERVER</tt>.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>@dispatch=WORKER
(int o) process (int i) "pkg" "0.0.1" [
- "set <<o>> [ pkg::process <<i>> ]"
-];
-----
-
-Swift/T builtin functions (+strcat()+, arithmetic, etc.) are typically
+ "set <<o>> [ pkg::process <<i>> ]"
+];</tt></pre>
+</div></div>
+<div class="paragraph"><p>Swift/T builtin functions (<tt>strcat()</tt>, arithmetic, etc.) are typically
implemented in this way as tasks that execute on the server. User
work should be performed on workers to keep servers free to process
-dataflow.
-
-This annotation is applied to the leaf task definition.
-
-////
-
-=== Work types
-
-Tim?
-
-////
-
-[[Optimizations]]
-== Optimizations
-STC performs a range of compiler optimizations that can significantly
+dataflow.</p></div>
+<div class="paragraph"><p>This annotation is applied to the leaf task definition.</p></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="Optimizations">15. Optimizations</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>STC performs a range of compiler optimizations that can significantly
speed up most Swift programs. The optimization level can be controlled
-by the +-O+ command line option. The default optimization
-level +-O2+, or the increased optimization level +-O3+ are usually
-the best choices. Some applications benefit markedly from +-O3+,
-while others do not, and compile times can increase slightly.
-
-----
-# No optimizations at all (not recommended)
+by the <tt>-O</tt> command line option. The default optimization
+level <tt>-O2</tt>, or the increased optimization level <tt>-O3</tt> are usually
+the best choices. Some applications benefit markedly from <tt>-O3</tt>,
+while others do not, and compile times can increase slightly.</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt># No optimizations at all (not recommended)
stc -O0 example.swift example.tcl
# Basic optimizations (not recommended)
@@ -1666,200 +3057,382 @@
stc -O2 example.swift example.tcl
# All optimizations (also recommended)
-stc -O3 example.swift example.tcl
-----
-
-Individual optimizations can be toggled on using +-T <opt name>+
-or off with +-t <opt name>+, but this typically is only useful for
+stc -O3 example.swift example.tcl</tt></pre>
+</div></div>
+<div class="paragraph"><p>Individual optimizations can be toggled on using <tt>-T <opt name></tt>
+or off with <tt>-t <opt name></tt>, but this typically is only useful for
debugging. You can find an up-to-date list of optimizations in
-the stc command-line help:
-
-----
-stc -h
-----
-
-[[Turbine]]
-== Running in Turbine
-
-The following describes how to run Turbine programs.
-
-=== Architecture
-
-Turbine runs as an MPI program consisting of many processes. Turbine
+the stc command-line help:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>stc -h</tt></pre>
+</div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="Turbine">16. Running in Turbine</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The following describes how to run Turbine programs.</p></div>
+<div class="sect2">
+<h3 id="_architecture">16.1. Architecture</h3>
+<div class="paragraph"><p>Turbine runs as an MPI program consisting of many processes. Turbine
programs are ADLB programs. Thus, they produce and execute discrete
-tasks that are distributed and load balanced at run time.
-
-Each process runs in a _mode_: _worker_, or _server_.
-
-Workers:: Evaluate the Swift logic. Produce tasks. Execute tasks.
-Servers:: Distributes tasks. Manages data.
-
-Typical Swift programs perform compute-intensive work in leaf
+tasks that are distributed and load balanced at run time.</p></div>
+<div class="paragraph"><p>Each process runs in a <em>mode</em>: <em>worker</em>, or <em>server</em>.</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+Workers
+</dt>
+<dd>
+<p>
+Evaluate the Swift logic. Produce tasks. Execute tasks.
+</p>
+</dd>
+<dt class="hdlist1">
+Servers
+</dt>
+<dd>
+<p>
+Distributes tasks. Manages data.
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>Typical Swift programs perform compute-intensive work in leaf
functions that execute on workers.
-Execution of the Swift logic is split and distributed among workers.
-
-Servers distribute tasks in a scalable, load balanced manner. They
-also store Swift data (integers, strings, etc.).
-
-=== Concurrency
-
-The available concurrency and efficiency in your Swift script is
-limited by the following factors:
-
-* The available concurrency in the Swift logic. Sequential
- dependencies will be evaluated sequentially. +foreach+ loops and
+Execution of the Swift logic is split and distributed among workers.</p></div>
+<div class="paragraph"><p>Servers distribute tasks in a scalable, load balanced manner. They
+also store Swift data (integers, strings, etc.).</p></div>
+</div>
+<div class="sect2">
+<h3 id="_concurrency">16.2. Concurrency</h3>
+<div class="paragraph"><p>The available concurrency and efficiency in your Swift script is
+limited by the following factors:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+The available concurrency in the Swift logic. Sequential
+ dependencies will be evaluated sequentially. <tt>foreach</tt> loops and
branching function calls may be evaluated concurrently
-* The number of workers available to process leaf functions
+</p>
+</li>
+<li>
+<p>
+The number of workers available to process leaf functions
concurrently
-* The number of servers available to control the Turbine run.
+</p>
+</li>
+<li>
+<p>
+The number of servers available to control the Turbine run.
Adding more servers can improve performance for applications with
small tasks or complex data dependencies but ties up processes
-
-=== Invocation
-
-The form of a Turbine invocation for STC-generated
-+program.tcl+ is:
-
-----
-turbine <turbine arguments> <program.tcl> <program arguments>
-----
-
-The program arguments are available to Swift (<<argv>>).
-
-Turbine accepts the following arguments:
-
-+-f <file>+:: Provide a machine file to +mpiexec+
-+-h+:: Print a help message
-+-l+:: Enable +mpiexec -l+ ranked output formatting
-+-n <procs>+:: The total number of Turbine MPI processes
-+-v+:: Report the Turbine version number
-+-V+:: Make the Turbine launch script verbose
-+-x+:: Use turbine_sh launcher with compiled-in libraries instead of tclsh
+</p>
+</li>
+</ul></div>
+</div>
+<div class="sect2">
+<h3 id="_invocation">16.3. Invocation</h3>
+<div class="paragraph"><p>The form of a Turbine invocation for STC-generated
+<tt>program.tcl</tt> is:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>turbine <turbine arguments> <program.tcl> <program arguments></tt></pre>
+</div></div>
+<div class="paragraph"><p>The program arguments are available to Swift (<a href="#argv">[argv]</a>).</p></div>
+<div class="paragraph"><p>Turbine accepts the following arguments:</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>-f <file></tt>
+</dt>
+<dd>
+<p>
+Provide a machine file to <tt>mpiexec</tt>
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-h</tt>
+</dt>
+<dd>
+<p>
+Print a help message
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-l</tt>
+</dt>
+<dd>
+<p>
+Enable <tt>mpiexec -l</tt> ranked output formatting
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-n <procs></tt>
+</dt>
+<dd>
+<p>
+The total number of Turbine MPI processes
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-v</tt>
+</dt>
+<dd>
+<p>
+Report the Turbine version number
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-V</tt>
+</dt>
+<dd>
+<p>
+Make the Turbine launch script verbose
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-x</tt>
+</dt>
+<dd>
+<p>
+Use turbine_sh launcher with compiled-in libraries instead of tclsh
(reduces number of files that must be read from file system)
-+-X+:: In place of of program.tcl, run standalone Turbine executable
- (e.g. created by <<mkstatic,mkstatic.tcl>>)
-
-The user controls the Turbine run time configuration through
-environment variables:
-
-+ADLB_SERVERS+:: Number of ADLB servers
-
-The remaining processes are workers. These values are available to
-Swift (<<Turbine_information, Turbine information>>).
-
-+TURBINE_LOG=0+:: Disable logging. +TURBINE_LOG=1+ or unset enables
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-X</tt>
+</dt>
+<dd>
+<p>
+In place of of program.tcl, run standalone Turbine executable
+ (e.g. created by <a href="#mkstatic">mkstatic.tcl</a>)
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>The user controls the Turbine run time configuration through
+environment variables:</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>ADLB_SERVERS</tt>
+</dt>
+<dd>
+<p>
+Number of ADLB servers
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p>The remaining processes are workers. These values are available to
+Swift (<a href="#Turbine_information">Turbine information</a>).</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>TURBINE_LOG=0</tt>
+</dt>
+<dd>
+<p>
+Disable logging. <tt>TURBINE_LOG=1</tt> or unset enables
logging, assuming logging was not disabled at configure time. Logging
goes to tandard output by default.
-
-+TURBINE_LOG_FILE=<file>+:: Set log file location. Defaults to
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>TURBINE_LOG_FILE=<file></tt>
+</dt>
+<dd>
+<p>
+Set log file location. Defaults to
standard output.
-
-+TURBINE_LOG_RANKS=1+:: Using +turbine -l+ or equivalent prepend the
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>TURBINE_LOG_RANKS=1</tt>
+</dt>
+<dd>
+<p>
+Using <tt>turbine -l</tt> or equivalent prepend the
MPI rank number to each output line. This works with typical MPICH or
OpenMPI systems, however, this is not available on some systems, so
set this to emulate the rank output on such systems.
-
-+ADLB_PRINT_TIME=1+:: Enable a short report of total elapsed time (via
-+MPI_Wtime()+)
-
-+ADLB_PERF_COUNTERS=1+::
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>ADLB_PRINT_TIME=1</tt>
+</dt>
+<dd>
+<p>
+Enable a short report of total elapsed time (via
+<tt>MPI_Wtime()</tt>)
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>ADLB_PERF_COUNTERS=1</tt>
+</dt>
+<dd>
+<p>
Enable performance counters (printed at end of execution). The
-link:internals.html[Swift/T internals guide] has information
+<a href="internals.html">Swift/T internals guide</a> has information
about interpreting the output.
-
-+ADLB_EXHAUST_TIME+::
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>ADLB_EXHAUST_TIME</tt>
+</dt>
+<dd>
+<p>
Time in seconds taken by ADLB task servers to shut down. May include
a decimal point. Default 0.1 . Setting this lower will reduce
delay in detection exhaustion. Setting this higher will reduce
overhead due to failed exhaust checks. The default setting is
almost always adequate.
-
-+ADLB_REPORT_LEAKS=1+::
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>ADLB_REPORT_LEAKS=1</tt>
+</dt>
+<dd>
+<p>
Enable reporting of any unfreed data in ADLB data store at end of
execution.
-
-+ADLB_TRACE=true+::
-+ADLB_DEBUG=true+::
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>ADLB_TRACE=true</tt>
+</dt>
+<dt class="hdlist1">
+<tt>ADLB_DEBUG=true</tt>
+</dt>
+<dd>
+<p>
To print DEBUG/TRACE level information for ADLB (if ADLB was compiled
with it enabled)
-
-+TURBINE_LAUNCH_OPTIONS+::
-Provide other arguments to +mpiexec+, such as a machine file, etc.
-
-+TURBINE_SRAND+::
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>TURBINE_LAUNCH_OPTIONS</tt>
+</dt>
+<dd>
+<p>
+Provide other arguments to <tt>mpiexec</tt>, such as a machine file, etc.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>TURBINE_SRAND</tt>
+</dt>
+<dd>
+<p>
If unset or empty, the random number generator seed will be set to the
process rank for each process, giving reproducible results. If set to
-an integer +seed+, the random number generator seed for each process
-will be set to +seed+ + +rank+.
-+
-For non-reproducible random results, use the following shell commands:
-+
-----
-export TURBINE_SRAND=$( date +%s )
-turbine ...
-----
-+
-The seed is recorded in the log.
-
-+ADLB_DEBUG_RANKS=1+:: Enable a report showing the rank and hostname
+an integer <tt>seed</tt>, the random number generator seed for each process
+will be set to <tt>seed</tt> + <tt>rank</tt>.
+</p>
+<div class="paragraph"><p>For non-reproducible random results, use the following shell commands:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>export TURBINE_SRAND=$( date +%s )
+turbine ...</tt></pre>
+</div></div>
+<div class="paragraph"><p>The seed is recorded in the log.</p></div>
+</dd>
+<dt class="hdlist1">
+<tt>ADLB_DEBUG_RANKS=1</tt>
+</dt>
+<dd>
+<p>
+Enable a report showing the rank and hostname
of each process. This allows you to determine whether your process
layout on a given machine is as intended.
-
-anchor:env_hostmap_debug[]
-
-+ADLB_DEBUG_HOSTMAP=1+:: Enable a report showing the hostmap, which
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p><a id="env_hostmap_debug"></a></p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>ADLB_DEBUG_HOSTMAP=1</tt>
+</dt>
+<dd>
+<p>
+Enable a report showing the hostmap, which
maps hostnames to ranks for use with the location functionality.
-
-anchor:env_hostmap_disable[]
-
-+ADLB_DISABLE_HOSTMAP=1+:: Prevent the hostmap from being constructed
+</p>
+</dd>
+</dl></div>
+<div class="paragraph"><p><a id="env_hostmap_disable"></a></p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>ADLB_DISABLE_HOSTMAP=1</tt>
+</dt>
+<dd>
+<p>
+Prevent the hostmap from being constructed
(avoiding some communication overhead).
-
-+VALGRIND+:: Enable valgrind debugging. Cf. <<valgrind,valgrind>>.
-
-+GDB_RANK+:: Enable GDB debugging. Cf. <<gdb,GDB>>.
-
-[[Build_configuration]]
-=== Build configuration
-
-The following describes how to run Swift/T programs in Turbine
-on more complex systems.
-
-==== Build troubleshooting
-
-If +exm-setup.zsh+ does not succeed, you may need to change how it
-tries to configure and compile Swift/T.
-
-Troubleshooting a build problem can require a few steps. The first
-step is to determine why the build failed. +exm-setup.zsh+ will usually
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>VALGRIND</tt>
+</dt>
+<dd>
+<p>
+Enable valgrind debugging. Cf. <a href="#valgrind">valgrind</a>.
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>GDB_RANK</tt>
+</dt>
+<dd>
+<p>
+Enable GDB debugging. Cf. <a href="#gdb">GDB</a>.
+</p>
+</dd>
+</dl></div>
+</div>
+<div class="sect2">
+<h3 id="Build_configuration">16.4. Build configuration</h3>
+<div class="paragraph"><p>The following describes how to run Swift/T programs in Turbine
+on more complex systems.</p></div>
+<div class="sect3">
+<h4 id="_build_troubleshooting">16.4.1. Build troubleshooting</h4>
+<div class="paragraph"><p>If <tt>exm-setup.zsh</tt> does not succeed, you may need to change how it
+tries to configure and compile Swift/T.</p></div>
+<div class="paragraph"><p>Troubleshooting a build problem can require a few steps. The first
+step is to determine why the build failed. <tt>exm-setup.zsh</tt> will usually
report the step at which configuration failed. For example, if it was unable
to locate a valid Tcl install, it will report this. Then you can try
-these steps to resolve the problem:
-
-1. If your system is covered by the link:turbine-sites.html[Sites Guide],
+these steps to resolve the problem:</p></div>
+<div class="olist arabic"><ol class="arabic">
+<li>
+<p>
+If your system is covered by the <a href="turbine-sites.html">Sites Guide</a>,
check to see if the problem and solution are described there.
-2. Inspect +exm-settings.sh+ settings related to the reported problem.
+</p>
+</li>
+<li>
+<p>
+Inspect <tt>exm-settings.sh</tt> settings related to the reported problem.
For example, if locating a Tcl install failed, setting
- the +TCL_INSTALL+ and +TCL_VERSION+ variables to the correct location
+ the <tt>TCL_INSTALL</tt> and <tt>TCL_VERSION</tt> variables to the correct location
and version may help.
-3. If the options in +exm-settings.sh+ do not give sufficient control to
+</p>
+</li>
+<li>
+<p>
+If the options in <tt>exm-settings.sh</tt> do not give sufficient control to
fix the problem, you may need to manually configure some components
of Swift/T, as described in the next section.
-
-[[Manual_build_configuration]]
-==== Manual configuration
-+exm-setup.zsh+ and +exm-settings.sh+ provide a convenient way to install
+</p>
+</li>
+</ol></div>
+</div>
+<div class="sect3">
+<h4 id="Manual_build_configuration">16.4.2. Manual configuration</h4>
+<div class="paragraph"><p><tt>exm-setup.zsh</tt> and <tt>exm-settings.sh</tt> provide a convenient way to install
Swift/T. However, this method does not allow full control over
the configuration. Swift/T is built with standard Ant (Java) and
Autotools/Makefile (C,Tcl) techniques. You can more directly control
-the configuration when building through the arguments to +ant+ or
-+configure+.
-
-To perform the installation using +configure+/+make+, simply untar the
-distribution package and do:
-
-----
-cd c-utils
+the configuration when building through the arguments to <tt>ant</tt> or
+<tt>configure</tt>.</p></div>
+<div class="paragraph"><p>To perform the installation using <tt>configure</tt>/<tt>make</tt>, simply untar the
+distribution package and do:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>cd c-utils
./configure ...
make install
@@ -1872,215 +3445,339 @@
make install
cd ../stc
-ant install -Ddist.dir=... -Dturbine.home=...
-----
-
-* You may use +./configure --help+ and the
- link:turbine-sites.html[Sites Guide] for further options.
-
-==== Non-standard MPI locations
-Sometimes simply specifying the MPI directory is not enough to
-configure Swift/T.
-
-You can modify these settings in +exm-settings.sh+ to more precisely
-define locations of MPI resources:
-
-----
-EXM_CUSTOM_MPI=1
+ant install -Ddist.dir=... -Dturbine.home=...</tt></pre>
+</div></div>
+<div class="ulist"><ul>
+<li>
+<p>
+You may use <tt>./configure --help</tt> and the
+ <a href="turbine-sites.html">Sites Guide</a> for further options.
+</p>
+</li>
+</ul></div>
+</div>
+<div class="sect3">
+<h4 id="_non_standard_mpi_locations">16.4.3. Non-standard MPI locations</h4>
+<div class="paragraph"><p>Sometimes simply specifying the MPI directory is not enough to
+configure Swift/T.</p></div>
+<div class="paragraph"><p>You can modify these settings in <tt>exm-settings.sh</tt> to more precisely
+define locations of MPI resources:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>EXM_CUSTOM_MPI=1
MPI_INCLUDE=/path/to/mpi.h/include
MPI_LIB_DIR=/path/to/mpi_lib/lib
-MPI_LIB_NAME=funny.mpi.a
-----
-
-If you are following the manual build process, configure Turbine with:
-----
- --enable-custom --with-mpi-include=/path/to/mpi.h/include
+MPI_LIB_NAME=funny.mpi.a</tt></pre>
+</div></div>
+<div class="paragraph"><p>If you are following the manual build process, configure Turbine with:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt> --enable-custom --with-mpi-include=/path/to/mpi.h/include
--with-mpi-lib-dir=/path/to/mpi_lib/lib
- --with-mpi-lib-name=funny.mpi.a
-----
-
-
-=== Performance enhancements
-
-1. Disable logging/debugging via environment
-2. Disable logging/debugging at configure/compile time
-+
-** Configure c-utils with +--disable-log+
-+
-3. Specify +EXM_OPT_BUILD=1+ in +exm-settings.sh+ or configure everything
- with +--enable-fast+. This disables assertions and other checks
-4. When making performance measurements, always subtract 0.1 seconds
- (or the value of +ADLB_EXHAUST_TIME+) from the Turbine run time
+ --with-mpi-lib-name=funny.mpi.a</tt></pre>
+</div></div>
+</div>
+</div>
+<div class="sect2">
+<h3 id="_performance_enhancements">16.5. Performance enhancements</h3>
+<div class="olist arabic"><ol class="arabic">
+<li>
+<p>
+Disable logging/debugging via environment
+</p>
+</li>
+<li>
+<p>
+Disable logging/debugging at configure/compile time
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+Configure c-utils with <tt>--disable-log</tt>
+</p>
+</li>
+</ul></div>
+</li>
+<li>
+<p>
+Specify <tt>EXM_OPT_BUILD=1</tt> in <tt>exm-settings.sh</tt> or configure everything
+ with <tt>--enable-fast</tt>. This disables assertions and other checks
+</p>
+</li>
+<li>
+<p>
+When making performance measurements, always subtract 0.1 seconds
+ (or the value of <tt>ADLB_EXHAUST_TIME</tt>) from the Turbine run time
due to the ADLB shutdown protocol, which does not start until the
system is idle for that amount of time.
-5. Reduce the number of program files that must be read off the
+</p>
+</li>
+<li>
+<p>
+Reduce the number of program files that must be read off the
filesystem. This is particularly useful for parallel file systems
and large scale applications. In increasing order of effectiveness,
you can:
-** use the turbine_sh launcher in place of tclsh in submit script,
- or by specifying the +-x+ argument to +turbine+
-** Use <<mkstatic,mkstatic.tcl>> to create a standalone executable with
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+use the turbine_sh launcher in place of tclsh in submit script,
+ or by specifying the <tt>-x</tt> argument to <tt>turbine</tt>
+</p>
+</li>
+<li>
+<p>
+Use <a href="#mkstatic">mkstatic.tcl</a> to create a standalone executable with
the Tcl main script and Tcl library code compiled in, and compiled
code statically linked.
-
-[[mkstatic]]
-=== Building standalone executables with mkstatic.tcl
-It is possible to build a fully self-contained executable, including
+</p>
+</li>
+</ul></div>
+</li>
+</ol></div>
+</div>
+<div class="sect2">
+<h3 id="mkstatic">16.6. Building standalone executables with mkstatic.tcl</h3>
+<div class="paragraph"><p>It is possible to build a fully self-contained executable, including
all Tcl scripts and compiled code, provided that all dependencies support
static linking. If not, it is also possible to build an executable with
a subset of Tcl scripts and code linked in, providing some performance
-benefits.
-
-The provided +mkstatic.tcl+ utility can produce a C source
+benefits.</p></div>
+<div class="paragraph"><p>The provided <tt>mkstatic.tcl</tt> utility can produce a C source
file with Tcl scripts bundled in, which can then be compiled and linked
with a C compiler. This is a multi-step process that can be automated
-as part of your build process.
-
-NOTE: Ensure that static versions of the +c-utils+, +lb+, and +turbine+ libraries
- were built, typically with a +.a+ suffix, e.g. +libadlb.a+. These
- are created by default, unless you specified +DISABLE_STATIC=0+ or
- +--disable-static+. To build a fully standalone
+as part of your build process.</p></div>
+<div class="admonitionblock">
+<table><tr>
+<td class="icon">
+<div class="title">Note</div>
+</td>
+<td class="content">Ensure that static versions of the <tt>c-utils</tt>, <tt>lb</tt>, and <tt>turbine</tt> libraries
+ were built, typically with a <tt>.a</tt> suffix, e.g. <tt>libadlb.a</tt>. These
+ are created by default, unless you specified <tt>DISABLE_STATIC=0</tt> or
+ <tt>--disable-static</tt>. To build a fully standalone
executable, you will also need to build a static version of Tcl
- (with the +--disable-shared+ configure option), and static versions
+ (with the <tt>--disable-shared</tt> configure option), and static versions
of any other libraries your own code needs to link with, such
- as your MPI distribution or application code.
-
-1. Compile your Swift script
-+
-----
-stc my.swift
-----
-+
-producing the Turbine Tcl script +my.tcl+.
-
-2. Create a manifest file, e.g. +my.manifest+. This file describes the
+ as your MPI distribution or application code.</td>
+</tr></table>
+</div>
+<div class="olist arabic"><ol class="arabic">
+<li>
+<p>
+Compile your Swift script
+</p>
+<div class="listingblock">
+<div class="content">
+<pre><tt>stc my.swift</tt></pre>
+</div></div>
+<div class="paragraph"><p>producing the Turbine Tcl script <tt>my.tcl</tt>.</p></div>
+</li>
+<li>
+<p>
+Create a manifest file, e.g. <tt>my.manifest</tt>. This file describes the
resources to be bundled, including the STC-generated code and any
user libraries.
-+
-To do this, make a copy of +scripts/mkstatic/example.manifest+ from
+</p>
+<div class="paragraph"><p>To do this, make a copy of <tt>scripts/mkstatic/example.manifest</tt> from
the Turbine installation directory. This file contains examples and
descriptions of all the the possible settings.
Note that an empty
-manifest file corresponds to the +turbine_sh+ utility, which is a
-replacement for +tclsh+ with required Turbine libraries statically
+manifest file corresponds to the <tt>turbine_sh</tt> utility, which is a
+replacement for <tt>tclsh</tt> with required Turbine libraries statically
linked in.
For a simple Swift program with no user Tcl libraries,
-you only need to set +main_script = my.tcl+.
-
-3. Invoke +mkstatic.tcl+ (found under +scripts/mkstatic/mkstatic.tcl+ in
+you only need to set <tt>main_script = my.tcl</tt>.</p></div>
+</li>
+<li>
+<p>
+Invoke <tt>mkstatic.tcl</tt> (found under <tt>scripts/mkstatic/mkstatic.tcl</tt> in
the Turbine installation) to translate your Tcl script to a C main
- program (e.g., +my_main.c+) with Tcl source code included.
+ program (e.g., <tt>my_main.c</tt>) with Tcl source code included.
The minimal invocation is
-+
-----
-mkstatic.tcl my.manifest -c my_main.c
-----
-+
-You will likely wish to include Tcl system libraries with
-+--include-sys-lib /home/example/tcl-install/lib --tcl-version 8.6+.
+</p>
+<div class="listingblock">
+<div class="content">
+<pre><tt>mkstatic.tcl my.manifest -c my_main.c</tt></pre>
+</div></div>
+<div class="paragraph"><p>You will likely wish to include Tcl system libraries with
+<tt>--include-sys-lib /home/example/tcl-install/lib --tcl-version 8.6</tt>.
The Tcl system library directory can be identified by the fact that
-it contains the file +init.tcl+. This directory must be specified
-with a special flag so that +mkstatic.tcl+ can correctly replace
-the regular Tcl initialization process.
-+
-You can include additional libraries and packages with
-+--include-lib /home/example/tcl-lib/+. Any +.tcl+ or +.tm+ source files
+it contains the file <tt>init.tcl</tt>. This directory must be specified
+with a special flag so that <tt>mkstatic.tcl</tt> can correctly replace
+the regular Tcl initialization process.</p></div>
+<div class="paragraph"><p>You can include additional libraries and packages with
+<tt>--include-lib /home/example/tcl-lib/</tt>. Any <tt>.tcl</tt> or <tt>.tm</tt> source files
in the directory will be included. Source-only packages can
generally be completely linked into the executable, but if a package
-loads shared libraries, only the +pkgIndex.tcl+ file will be linked
+loads shared libraries, only the <tt>pkgIndex.tcl</tt> file will be linked
into the executable. A package with compiled code can be converted to
support static linking by specifying a package init function, plus
-static library or object files in the manifest file.
-+
-4. Link together the compiled C main program with user libraries and
+static library or object files in the manifest file.</p></div>
+</li>
+<li>
+<p>
+Link together the compiled C main program with user libraries and
Swift/T libraries to produce a final executable. The details of the
process vary depending on the compiler and system: we assume GCC.
You will need to provide the correct flags to link in all libraries
required by Swift/T or your own user code.
-** *User code:* you must identify the libraries used by your application
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+<strong>User code:</strong> you must identify the libraries used by your application
and ensure link flags are provided. If linking static libraries, ensure
that any indirect dependencies of these libraries are also linked.
-** *Swift/T system:* The Turbine distribution includes a helper script,
- +turbine-build-config.sh+, that can be sourced to obtain linker flags
+</p>
+</li>
+<li>
+<p>
+<strong>Swift/T system:</strong> The Turbine distribution includes a helper script,
+ <tt>turbine-build-config.sh</tt>, that can be sourced to obtain linker flags
for Swift/T dependencies.
-** *Link order:* In the case of static linking, if *libA* depends on *libB*,
- then the +-lA+ flag must precede +-lB+ on the command line. To
+</p>
+</li>
+<li>
+<p>
+<strong>Link order:</strong> In the case of static linking, if <strong>libA</strong> depends on <strong>libB</strong>,
+ then the <tt>-lA</tt> flag must precede <tt>-lB</tt> on the command line. To
actually do the linking, there are two further cases to consider:
-*** If building a fully static executable, you can
- provide the +-static+ flag, plus all object files, plus +-L+
- and +-l+ flags for all required library directories and libraries.
-+
-----
-gcc -static script_main.c file1.o file2.o -L/path/to/lib/dir -lsomething ...
-----
-+
-*** If you are building an executable that depends on one or more shared
- libraries, you will need to provide the +-dynamic+ flag, and then
+</p>
+<div class="ulist"><ul>
+<li>
+<p>
+If building a fully static executable, you can
+ provide the <tt>-static</tt> flag, plus all object files, plus <tt>-L</tt>
+ and <tt>-l</tt> flags for all required library directories and libraries.
+</p>
+<div class="listingblock">
+<div class="content">
+<pre><tt>gcc -static script_main.c file1.o file2.o -L/path/to/lib/dir -lsomething ...</tt></pre>
+</div></div>
+</li>
+<li>
+<p>
+If you are building an executable that depends on one or more shared
+ libraries, you will need to provide the <tt>-dynamic</tt> flag, and then
ensure that static libraries are linked statically. If a shared
- version of a library is available, +gcc+ will use that in preference
+ version of a library is available, <tt>gcc</tt> will use that in preference
to a static version. You can override this behaviour by specifying
- +-Wl,-Bstatic+ on the command line before the flags for the libraries
- you wish to statically link, then +-Wl,-Bdynamic+ to reset to
+ <tt>-Wl,-Bstatic</tt> on the command line before the flags for the libraries
+ you wish to statically link, then <tt>-Wl,-Bdynamic</tt> to reset to
dynamic linking for any libraries after those.
-
-We have described the most commonly-used options. A full list of options
-and descriptions can be obtained by invoking +mkstatic.tcl -h+.
-Additional options include:
-
-+--main-script+:: Specify Tcl main script (overrides manifest file)
-+-r+:: Specify non-standard variable prefix for C code
-+-v+:: Print verbose messages
-+--deps+:: Generate Makefile include for generating C file
-+--ignore-no-manifest+:: Pretend empty manifest present
-
-[[debugging]]
-=== Debugging Swift/T runs
-
-Applying the debugger allows you to debug native code linked to Swift/T
+</p>
+</li>
+</ul></div>
+</li>
+</ul></div>
+</li>
+</ol></div>
+<div class="paragraph"><p>We have described the most commonly-used options. A full list of options
+and descriptions can be obtained by invoking <tt>mkstatic.tcl -h</tt>.
+Additional options include:</p></div>
+<div class="dlist"><dl>
+<dt class="hdlist1">
+<tt>--main-script</tt>
+</dt>
+<dd>
+<p>
+Specify Tcl main script (overrides manifest file)
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-r</tt>
+</dt>
+<dd>
+<p>
+Specify non-standard variable prefix for C code
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>-v</tt>
+</dt>
+<dd>
+<p>
+Print verbose messages
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>--deps</tt>
+</dt>
+<dd>
+<p>
+Generate Makefile include for generating C file
+</p>
+</dd>
+<dt class="hdlist1">
+<tt>--ignore-no-manifest</tt>
+</dt>
+<dd>
+<p>
+Pretend empty manifest present
+</p>
+</dd>
+</dl></div>
+</div>
+<div class="sect2">
+<h3 id="debugging">16.7. Debugging Swift/T runs</h3>
+<div class="paragraph"><p>Applying the debugger allows you to debug native code linked to Swift/T
from a normal debugger. This will allow you to step through your code
-(and the Swift/T run time libraries).
-
-* When using Swift/T dynamically with Tcl packages (the default), you
- need to attach to the +tclsh+ process. This process loads your
+(and the Swift/T run time libraries).</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+When using Swift/T dynamically with Tcl packages (the default), you
+ need to attach to the <tt>tclsh</tt> process. This process loads your
native code and calls into it.
-* When using +mkstatic+, you generate a complete executable. You can
+</p>
+</li>
+<li>
+<p>
+When using <tt>mkstatic</tt>, you generate a complete executable. You can
debug this in the normal method for debugging MPI programs.
-
-[[valgrind]]
-==== Valgrind
-
-The Swift/T launcher scripts support http://valgrind.org[valgrind].
-Simply set the environment variable +VALGRIND+ to the valgrind command
+</p>
+</li>
+</ul></div>
+<div class="sect3">
+<h4 id="valgrind">16.7.1. Valgrind</h4>
+<div class="paragraph"><p>The Swift/T launcher scripts support <a href="http://valgrind.org">valgrind</a>.
+Simply set the environment variable <tt>VALGRIND</tt> to the valgrind command
you wish to use. A suppressions file is distributed with Turbine to
ignore known issues. (Swift/T is valgrind-clean but there are some
-issues in Tcl.)
-
-----
-export VALGRIND="valgrind --suppressions=$HOME/turbine/turbine.supp"
-turbine program.tcl
-----
-
-[[gdb]]
-==== GDB
-
-The Turbine library provides a convenient attachment mechanism
+issues in Tcl.)</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>export VALGRIND="valgrind --suppressions=$HOME/turbine/turbine.supp"
+turbine program.tcl</tt></pre>
+</div></div>
+</div>
+<div class="sect3">
+<h4 id="gdb">16.7.2. GDB</h4>
+<div class="paragraph"><p>The Turbine library provides a convenient attachment mechanism
compatible with debuggers like GDB, Eclipse, etc. You attach to a
-Turbine execution by using the +GDB_RANK+ variable:
-
-----
-$ export GDB_RANK=0
+Turbine execution by using the <tt>GDB_RANK</tt> variable:</p></div>
+<div class="listingblock">
+<div class="content">
+<pre><tt>$ export GDB_RANK=0
$ turbine program.tcl
Waiting for gdb: rank: 0 pid: 23274
-...
-----
-
-Rank 0, running in process +23274+, has blocked (in a loop) and is
+...</tt></pre>
+</div></div>
+<div class="paragraph"><p>Rank 0, running in process <tt>23274</tt>, has blocked (in a loop) and is
waiting for the debugger to attach. When you attach, set the variable
-+t=1+ to break out of the loop. Then you can debug normally.
-
-////
-Local Variables:
-mode: doc
-eval: (auto-fill-mode 1)
-End:
-////
+<tt>t=1</tt> to break out of the loop. Then you can debug normally.</p></div>
+</div>
+</div>
+</div>
+</div>
+</div>
+<div id="footnotes"><hr /></div>
+<div id="footer">
+<div id="footer-text">
+Last updated 2014-08-22 15:14:23 RDT
+</div>
+</div>
+</body>
+</html>
More information about the Swift-commit
mailing list