Manual Patch: Fix Typos and Some Indexing

Jeffrey D. Oldham oldham at codesourcery.com
Fri Mar 15 23:12:11 UTC 2002


2002-Mar-15  Jeffrey D. Oldham  <oldham at codesourcery.com>

	Minor manual formatting changes.

	* starting.xml: s/the the/the/.  Change formatting of comment.
	* template.xml: Merge indexterms and text to avoid unwanted spaces
	in output.
	* tutorial.xml: Fix typos.
	* figures/distributed-101.png: Changes reflecting distributed.mp.
	* figures/distributed.mp: Avoid ligature problem.

Approved by me!
Applied to mainline

Thanks,
Jeffrey D. Oldham
oldham at codesourcery.com
-------------- next part --------------
Index: starting.xml
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/starting.xml,v
retrieving revision 1.2
diff -c -p -r1.2 starting.xml
*** starting.xml	2002/03/04 23:48:09	1.2
--- starting.xml	2002/03/15 23:07:20
***************
*** 80,95 ****
     <para>&pooma; is open-source software, freely available via the
     Internet or perhaps packaged with this &book;.  <ulink
     url="http://www.codesourcery.com/">CodeSourcery, LLC,</ulink>
!    currently hosts the &poomatoolkit; source code.  Download the the
     &pooma; source code <filename
     path="http://www.codesourcery.com/pooma/downloads_folder/">&poomasourcefile;</filename>
     from the &pooma; download page (&poomadownloadpage;) available off
     the &pooma; home page (&poomahomepage;).  The <quote>tgz</quote>
     indicates this is a compressed tar archive file.  For a UNIX
     operating system, one can extract the source files using the
!    command <command>tar xzvf &poomasourcefile;</command>.
! <!-- FIXME: Make source code available for Windows and Mac users.
!    Describe how to unpack the files. --></para>
  
     <!-- FIXME: Add a dangerous bend section describing how to download
     sources from CVS. -->
--- 80,95 ----
     <para>&pooma; is open-source software, freely available via the
     Internet or perhaps packaged with this &book;.  <ulink
     url="http://www.codesourcery.com/">CodeSourcery, LLC,</ulink>
!    currently hosts the &poomatoolkit; source code.  Download the
     &pooma; source code <filename
     path="http://www.codesourcery.com/pooma/downloads_folder/">&poomasourcefile;</filename>
     from the &pooma; download page (&poomadownloadpage;) available off
     the &pooma; home page (&poomahomepage;).  The <quote>tgz</quote>
     indicates this is a compressed tar archive file.  For a UNIX
     operating system, one can extract the source files using the
!    command <command>tar xzvf &poomasourcefile;</command>.  <!-- FIXME:
!    Make source code available for Windows and Mac users.  Describe how
!    to unpack the files. --></para>
  
     <!-- FIXME: Add a dangerous bend section describing how to download
     sources from CVS. -->
Index: template.xml
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/template.xml,v
retrieving revision 1.8
diff -c -p -r1.8 template.xml
*** template.xml	2002/03/04 23:48:09	1.8
--- template.xml	2002/03/15 23:07:21
***************
*** 22,39 ****
        compiler, not when a program runs.</para>
       </listitem>
       <listitem>
!       <para id="template_programming-introduction-main_uses-type_polymorphism">Templates permit declaring families of classes using a
!       single declaration.  For example, the &array;
!       <indexterm>
!        <primary>&array;</primary>
!       </indexterm>
!       <indexterm zone="template_programming-introduction-main_uses-type_polymorphism">
!        <primary>type polymorphism</primary>
!       </indexterm>
!       template
!       declaration permits using &array;s with many different value
!       types, e.g., arrays of integers, arrays of floating point
!       numbers, and arrays of arrays.</para>
      </listitem>
     </itemizedlist>
     For those interested in the implementation of &pooma;, we close the
--- 22,37 ----
        compiler, not when a program runs.</para>
       </listitem>
       <listitem>
!       <para
!       id="template_programming-introduction-main_uses-type_polymorphism">Templates
!       permit declaring families of classes using a single declaration.
!       For example, the
!       &array;<indexterm><primary>&array;</primary></indexterm><indexterm
!       zone="template_programming-introduction-main_uses-type_polymorphism"><primary>type
!       polymorphism</primary></indexterm>template declaration permits
!       using &array;s with many different value types, e.g., arrays of
!       integers, arrays of floating point numbers, and arrays of
!       arrays.</para>
      </listitem>
     </itemizedlist>
     For those interested in the implementation of &pooma;, we close the
***************
*** 61,99 ****
      program's interesting computation occurred when it was executed.
      When writing the program, the programmer, at <glossterm
      linkend="glossary-programming_time"><firstterm>programming
!     time</firstterm></glossterm>,
!     <indexterm>
!      <primary>programming time</primary>
!     </indexterm>
!     would specify which statements and expressions will occur and
!     which types to use.  At <glossterm
      linkend="glossary-compile_time"><firstterm>compile
      time</firstterm></glossterm>, the compiler would convert the
      program's source code into an executable program.  Even though the
      compiler uses the types to produce the executable, no interesting
      computation would occur.  At <glossterm
      linkend="glossary-run_time"><firstterm>run
!     time</firstterm></glossterm>,
!     <indexterm>
!      <primary>run time</primary>
!     </indexterm>
!     the resulting executable program
!     would actually perform the operations.</para>
  
      <para>The introduction of templates permits interesting
      computation to occur while the compiler produces the executable.
!     Most interesting is template instantiation,
!     <indexterm>
!      <primary>template</primary>
!      <secondary>instantiation</secondary>
!     </indexterm>
!     which produces a type
!     at compile time.  For example, the &array; <quote>type</quote>
!     definition requires template parameters <varname>Dim</varname>,
!     <varname>T</varname>, and <varname>EngineTag</varname>, specifying
!     its dimension, the type of its values, and its &engine; type.  To
!     use this, a programmer specifies values for the template
!     parameters:
      <literal><type>Array<2,double,Brick></type></literal>
      specifies a dimension of 2, a value type of &double;, and the
      &brick; &engine; type.  At compile time, the compiler creates a
--- 59,87 ----
      program's interesting computation occurred when it was executed.
      When writing the program, the programmer, at <glossterm
      linkend="glossary-programming_time"><firstterm>programming
!     time</firstterm></glossterm>,<indexterm><primary>programming
!     time</primary></indexterm> would specify which statements and
!     expressions will occur and which types to use.  At <glossterm
      linkend="glossary-compile_time"><firstterm>compile
      time</firstterm></glossterm>, the compiler would convert the
      program's source code into an executable program.  Even though the
      compiler uses the types to produce the executable, no interesting
      computation would occur.  At <glossterm
      linkend="glossary-run_time"><firstterm>run
!     time</firstterm></glossterm>,<indexterm><primary>run
!     time</primary></indexterm> the resulting executable program would
!     actually perform the operations.</para>
  
      <para>The introduction of templates permits interesting
      computation to occur while the compiler produces the executable.
!     Most interesting is template
!     instantiation,<indexterm><primary>template</primary><secondary>instantiation</secondary></indexterm>
!     which produces a type at compile time.  For example, the &array;
!     <quote>type</quote> definition requires template parameters
!     <varname>Dim</varname>, <varname>T</varname>, and
!     <varname>EngineTag</varname>, specifying its dimension, the type
!     of its values, and its &engine; type.  To use this, a programmer
!     specifies values for the template parameters:
      <literal><type>Array<2,double,Brick></type></literal>
      specifies a dimension of 2, a value type of &double;, and the
      &brick; &engine; type.  At compile time, the compiler creates a
***************
*** 110,135 ****
      computable.  Unfortunately, syntax for compile-time computation is
      more difficult than for run-time computation.  Also current
      compilers are not as efficient as code executed by hardware.
!     Run-time &cc; constructs are Turing-complete
!     <indexterm>
!      <primary>Turing complete</primary>
!     </indexterm>
!     so using templates is
!     unnecessary.  Thus, we can shift computation to the time which
!     best trades off the ease of expressing syntax with the speed of
!     computation by programmer, compiler, or computer chip.  For
!     example, &pooma; uses expression template technology
!     <indexterm>
!      <primary>expression templates</primary>
!     </indexterm>
!     to speed
!     run-time execution of data-parallel statements.  The &pooma;
!     developers decided to shift some of the computation from run-time
!     to compile-time using template computations.  The resulting
!     run-time code runs more quickly, but compiling the code takes
!     longer.  Also, programming time for the &pooma; developers
!     increased significantly, but, most users, who are usually most
!     concerned about decreasing run times, benefited.</para>
     </section>
  
  
--- 98,118 ----
      computable.  Unfortunately, syntax for compile-time computation is
      more difficult than for run-time computation.  Also current
      compilers are not as efficient as code executed by hardware.
!     Run-time &cc; constructs are
!     Turing-complete<indexterm><primary>Turing
!     complete</primary></indexterm> so using templates is unnecessary.
!     Thus, we can shift computation to the time which best trades off
!     the ease of expressing syntax with the speed of computation by
!     programmer, compiler, or computer chip.  For example, &pooma; uses
!     expression template technology<indexterm><primary>expression
!     templates</primary></indexterm> to speed run-time execution of
!     data-parallel statements.  The &pooma; developers decided to shift
!     some of the computation from run-time to compile-time using
!     template computations.  The resulting run-time code runs more
!     quickly, but compiling the code takes longer.  Also, programming
!     time for the &pooma; developers increased significantly, but, most
!     users, who are usually most concerned about decreasing run times,
!     benefited.</para>
     </section>
  
  
***************
*** 145,169 ****
         parameters, both of which are used in this book.</para>
        </listitem>
        <listitem>
!        <para>template instantiation,
!        <indexterm>
! 	<primary>template</primary>
! 	<secondary>instantiation</secondary>
!        </indexterm>
         i.e., specifying a particular type by specifying values for
         template parameters.</para>
        </listitem>
        <listitem>
!        <para>nested type names,
!        <indexterm>
! 	<primary>nested type</primary>
! 	<see>type, nested.</see>
!        </indexterm>
!        <indexterm>
! 	<primary>type</primary>
! 	<secondary>nested</secondary>
!        </indexterm>
!        which are types specified within a class definition.</para>
        </listitem>
       </itemizedlist>
      We discuss each of these below.</para>
--- 128,143 ----
         parameters, both of which are used in this book.</para>
        </listitem>
        <listitem>
!        <para>template
!        instantiation,<indexterm><primary>template</primary><secondary>instantiation</secondary></indexterm>
         i.e., specifying a particular type by specifying values for
         template parameters.</para>
        </listitem>
        <listitem>
!        <para>nested type names, <indexterm><primary>nested
! 	type</primary><see>type,
! 	nested.</see></indexterm><indexterm><primary>type</primary><secondary>nested</secondary></indexterm>
! 	which are types specified within a class definition.</para>
        </listitem>
       </itemizedlist>
      We discuss each of these below.</para>
***************
*** 231,241 ****
      follow the class name surrounded by angle
      brackets (<literal><></literal>).  For example,
      <type>pair<int></type> <glossterm
!     linkend="glossary-template_instantiation"><firstterm>instantiates</firstterm></glossterm>
!     <indexterm>
!      <primary>template</primary>
!      <secondary>instantiation</secondary>
!     </indexterm>
      the <classname>pair</classname> template class definition with
      <varname>T</varname> equal to ∫.  That is, the compiler
      creates a definition for <type>pair<int></type> by copying
--- 205,211 ----
      follow the class name surrounded by angle
      brackets (<literal><></literal>).  For example,
      <type>pair<int></type> <glossterm
!     linkend="glossary-template_instantiation"><firstterm>instantiates</firstterm></glossterm><indexterm><primary>template</primary><secondary>instantiation</secondary></indexterm>
      the <classname>pair</classname> template class definition with
      <varname>T</varname> equal to ∫.  That is, the compiler
      creates a definition for <type>pair<int></type> by copying
***************
*** 246,261 ****
      The result is a definition exactly the same as
      <classname>pairOfInts</classname>.</para>
  
!     <para>As we mentioned above, template instantiation
!     <indexterm>
!      <primary>template</primary>
!      <secondary>instantiation</secondary>
!     </indexterm>
!     is analogous to function application.
!     <indexterm>
!      <primary>function</primary>
!      <secondary>application</secondary>
!     </indexterm>
      A template class is analogous to a function; it is a function from
      types and constants to classes.  The analogy between compile-time
      and run-time programming constructs can be extended.  <xref
--- 216,225 ----
      The result is a definition exactly the same as
      <classname>pairOfInts</classname>.</para>
  
!     <para>As we mentioned above, template
!     instantiation<indexterm><primary>template</primary><secondary>instantiation</secondary></indexterm>
!     is analogous to function
!     application.<indexterm><primary>function</primary><secondary>application</secondary></indexterm>
      A template class is analogous to a function; it is a function from
      types and constants to classes.  The analogy between compile-time
      and run-time programming constructs can be extended.  <xref
***************
*** 263,278 ****
      lists these correspondences.  For example, at run time, values
      consist of things such as integers, floating point numbers,
      pointers, functions, and objects.  Programs compute by operating
!     on these values.  The compile-time values
!     <indexterm>
!      <primary>compile time</primary>
!      <secondary>value</secondary>
!     </indexterm>
!     include types, and
!     compile-time operations use these types.  For both run-time and
!     compile-time programming, &cc; defines default sets of values that
!     all conforming compilers must support.  For example,
!     <literal>3</literal> and <literal>6.022e+23</literal> are
      run-time values that any &cc; compiler must accept.  It must also
      accept the ∫, &bool;, and <type>int*</type> types.</para>
  
--- 227,239 ----
      lists these correspondences.  For example, at run time, values
      consist of things such as integers, floating point numbers,
      pointers, functions, and objects.  Programs compute by operating
!     on these values.  The compile-time
!     values<indexterm><primary>compile
!     time</primary><secondary>value</secondary></indexterm> include
!     types, and compile-time operations use these types.  For both
!     run-time and compile-time programming, &cc; defines default sets
!     of values that all conforming compilers must support.  For
!     example, <literal>3</literal> and <literal>6.022e+23</literal> are
      run-time values that any &cc; compiler must accept.  It must also
      accept the ∫, &bool;, and <type>int*</type> types.</para>
  
***************
*** 313,341 ****
  	 <entry>template argument, e.g., <quote>any type</quote></entry>
  	</row>
  	<row>
! 	 <entry>packaging repeated operations</entry>
! 	 <entry>A function
!          <indexterm>
!           <primary>function</primary>
!          </indexterm>
!          generalizes a particular operation applied to different
!          values.  The function parameters are placeholders for
!          particular values.</entry>
!          <entry>A template class generalizes a particular class
!          definition using different types.  The template parameters
!          are placeholders for particular values.</entry>
  	</row>
  	<row>
! 	 <entry>application
!          <indexterm>
!           <primary>function</primary>
!           <secondary>application</secondary>
!          </indexterm>
!          <indexterm>
!           <primary>application</primary>
!           <see>function, application.</see>
!          </indexterm>
!          </entry>
  	 <entry>Use a function by appending function arguments
  	surrounded by parentheses.</entry>
  	 <entry>Use a template class by appending template arguments
--- 274,290 ----
  	 <entry>template argument, e.g., <quote>any type</quote></entry>
  	</row>
  	<row>
! 	 <entry>packaging repeated operations</entry> <entry>A
! 	 function<indexterm><primary>function</primary></indexterm>
! 	 generalizes a particular operation applied to different
! 	 values.  The function parameters are placeholders for
! 	 particular values.</entry> <entry>A template class
! 	 generalizes a particular class definition using different
! 	 types.  The template parameters are placeholders for
! 	 particular values.</entry>
  	</row>
  	<row>
! 	 <entry>application <indexterm><primary>function</primary><secondary>application</secondary></indexterm><indexterm><primary>application</primary><see>function, application.</see></indexterm></entry>
  	 <entry>Use a function by appending function arguments
  	surrounded by parentheses.</entry>
  	 <entry>Use a template class by appending template arguments
*************** maxOut(0, 3);
*** 467,492 ****
      and the latter stores named values, nested type names are values,
      i.e., types, stored within class definitions.  For example, the
      template class &array; has an nested type name for the type of its
!     domain:
! <programlisting>
  typedef typename Engine_t::Domain_t Domain_t;
! </programlisting> This <literal>typedef</literal>,
!     <indexterm>
!      <primary><literal>typedef</literal></primary>
!      <see>type, definition.</see>
!     </indexterm>
!     <indexterm>
!      <primary>type</primary>
!      <secondary>definition</secondary>
!     </indexterm>
!     i.e., type
!     definition, defines the type <type>Domain_t</type> as equivalent
!     to <type>Engine_t::Domain_t</type>.  The
!     <literal>::</literal> operator
!     <indexterm>
!      <primary><literal>::</literal> operator</primary>
!     </indexterm>
!     selects the <type>Domain_t</type> nested type from inside the
      <type>Engine_t</type> type.  This illustrates how to access
      &array;'s <type>Domain_t</type> when not within &array;'s scope:
      <type>Array<Dim, T, EngineTag>::Domain_t</type>.  The
--- 416,429 ----
      and the latter stores named values, nested type names are values,
      i.e., types, stored within class definitions.  For example, the
      template class &array; has an nested type name for the type of its
!     domain:<programlisting>
  typedef typename Engine_t::Domain_t Domain_t;
! </programlisting> This
!     <literal>typedef</literal>,<indexterm><primary><literal>typedef</literal></primary><see>type,
!     definition.</see></indexterm><indexterm><primary>type</primary><secondary>definition</secondary></indexterm>
!     i.e., type definition, defines the type <type>Domain_t</type> as
!     equivalent to <type>Engine_t::Domain_t</type>.  The
!     <literal>::</literal> operator<indexterm><primary><literal>::</literal> operator</primary></indexterm> selects the <type>Domain_t</type> nested type from inside the
      <type>Engine_t</type> type.  This illustrates how to access
      &array;'s <type>Domain_t</type> when not within &array;'s scope:
      <type>Array<Dim, T, EngineTag>::Domain_t</type>.  The
*************** typedef typename Engine_t::Domain_t Doma
*** 554,596 ****
  	operations on code.</entry>
         </row>
         <row>
! 	<entry>values stored in a collection</entry>
! 	<entry>An object stores values.</entry>
! 	<entry>A <glossterm linkend="glossary-traits_class">traits
! 	class</glossterm>
!         <indexterm>
!          <primary>traits class</primary>
!         </indexterm>
!         <indexterm>
!          <primary>class</primary>
!          <secondary>traits</secondary>
!          <see>traits class</see>
!         </indexterm>
!         contains values describing a type.</entry>
         </row>
         <row>
! 	<entry>extracting values from collections</entry>
! 	<entry>An object's named values are extracted using the
! 	<literal>.</literal> operator.
!         <indexterm>
!          <primary><literal>.</literal> operator</primary>
!         </indexterm>
!         </entry>
  	<entry>A class's nested types and classes are extracted using
! 	the <literal>::</literal> operator.
!         <indexterm>
!          <primary><literal>::</literal> operator</primary>
!         </indexterm>
!         </entry>
         </row>
         <row>
! 	<entry>control flow
!         <indexterm>
!          <primary>control flow</primary>
!         </indexterm>
!         to choose among operations</entry>
! 	<entry><literal>if</literal>, <literal>while</literal>, <literal>goto</literal>, …</entry>
! 	<entry>template class specializations with pattern matching</entry>
         </row>
        </tbody>
       </tgroup>
--- 491,518 ----
  	operations on code.</entry>
         </row>
         <row>
! 	<entry>values stored in a collection</entry> <entry>An object
! 	stores values.</entry> <entry>A <glossterm
! 	linkend="glossary-traits_class">traits
! 	class</glossterm><indexterm><primary>traits
! 	class</primary></indexterm><indexterm><primary>class</primary><secondary>traits</secondary><see>traits
! 	class</see></indexterm> contains values describing a
! 	type.</entry>
         </row>
         <row>
! 	<entry>extracting values from collections</entry> <entry>An
! 	object's named values are extracted using the
! 	<literal>.</literal> operator.<indexterm><primary><literal>.</literal> operator</primary></indexterm></entry>
  	<entry>A class's nested types and classes are extracted using
! 	the
! 	<literal>::</literal> operator.<indexterm><primary><literal>::</literal> operator</primary></indexterm></entry>
         </row>
         <row>
! 	<entry>control flow<indexterm><primary>control
! 	flow</primary></indexterm> to choose among operations</entry>
! 	<entry><literal>if</literal>, <literal>while</literal>,
! 	<literal>goto</literal>, …</entry> <entry>template
! 	class specializations with pattern matching</entry>
         </row>
        </tbody>
       </tgroup>
*************** enum { dimensionPlusRank = dimensions + 
*** 654,701 ****
       </listitem>
      </itemizedlist>
      The use of non-integral constant values such as floating-point
!     numbers at compile time is restricted.
!     <indexterm class="endofrange"
! 	       startref="template_programming-pooma_implementation-index-enumeration">
!     </indexterm>
!     </para>
! 
!     <para>Other compile-time values include pointers
!     <indexterm>
!      <primary>pointer</primary>
!     </indexterm>
!     to objects and
!     functions, references
!     <indexterm>
!      <primary>reference</primary>
!     </indexterm>
!     to objects and functions, and executable
!     code.  For example, a pointer to a function
!     <indexterm>
!      <primary>pointer</primary>
!      <secondary>function</secondary>
!     </indexterm>
!     <indexterm>
!      <primary>function pointer</primary>
!      <see>pointer, function.</see>
!     </indexterm>
!     sometimes is passed to
!     a template function to perform a specific task.  Even though
!     executable code
!     <indexterm>
!      <primary>executable code</primary>
!     </indexterm>
!     cannot be directly represented in a program, it is
!     a compile-time value which the compiler uses.  A simple example is
!     a class that is created by template instantiation,
!     <indexterm>
!      <primary>template</primary>
!      <secondary>instantiation</secondary>
!     </indexterm>
!     e.g., <type>pair<int></type>.  Conceptually, the ∫ template
!     argument is substituted throughout the <type>pair</type> template
!     class to produce a class definition.  Although neither the
!     programmer nor the user sees this class definition, it is
      represented inside the compiler, which can use and manipulate the
      code.</para>
      <indexterm class="endofrange"
--- 576,603 ----
       </listitem>
      </itemizedlist>
      The use of non-integral constant values such as floating-point
!     numbers at compile time is restricted.<indexterm
!     class="endofrange"
!     startref="template_programming-pooma_implementation-index-enumeration"></indexterm></para>
! 
!     <para>Other compile-time values include
!     pointers<indexterm><primary>pointer</primary></indexterm> to
!     objects and functions,
!     references<indexterm><primary>reference</primary></indexterm> to
!     objects and functions, and executable code.  For example, a
!     pointer to a
!     function<indexterm><primary>pointer</primary><secondary>function</secondary></indexterm><indexterm><primary>function
!     pointer</primary><see>pointer, function.</see></indexterm>
!     sometimes is passed to a template function to perform a specific
!     task.  Even though executable code<indexterm><primary>executable
!     code</primary></indexterm> cannot be directly represented in a
!     program, it is a compile-time value which the compiler uses.  A
!     simple example is a class that is created by template
!     instantiation,<indexterm><primary>template</primary><secondary>instantiation</secondary></indexterm>
!     e.g., <type>pair<int></type>.  Conceptually, the ∫
!     template argument is substituted throughout the <type>pair</type>
!     template class to produce a class definition.  Although neither
!     the programmer nor the user sees this class definition, it is
      represented inside the compiler, which can use and manipulate the
      code.</para>
      <indexterm class="endofrange"
*************** enum { dimensionPlusRank = dimensions + 
*** 703,723 ****
      </indexterm>
  
      <para id="template_programming-pooma_implementation-optimization">
!     Through template programming, the compiler's optimizer
!     <indexterm>
!      <primary>optimizer</primary>
!      <see>compiler, optimizer.</see>
!     </indexterm>
!     <indexterm>
!      <primary>optimization</primary>
!      <see>compiler, optimizer.</see>
!     </indexterm>
!     <indexterm zone="template_programming-pooma_implementation-optimization">
!      <primary>compiler</primary>
!      <secondary>optimizer</secondary>
!     </indexterm>
!     can
!     transform complicated code into much simpler code.  In <xref
      linkend="data_parallel-implementation"></xref>, we describe the
      complicated template code used to implement efficiently
      data-parallel operations.  Although the template code is
--- 605,616 ----
      </indexterm>
  
      <para id="template_programming-pooma_implementation-optimization">
!     Through template programming, the compiler's
!     optimizer<indexterm><primary>optimizer</primary><see>compiler,
!     optimizer.</see></indexterm><indexterm><primary>optimization</primary><see>compiler,
!     optimizer.</see></indexterm><indexterm
!     zone="template_programming-pooma_implementation-optimization"><primary>compiler</primary><secondary>optimizer</secondary></indexterm>
!     can transform complicated code into much simpler code.  In <xref
      linkend="data_parallel-implementation"></xref>, we describe the
      complicated template code used to implement efficiently
      data-parallel operations.  Although the template code is
*************** struct usuallySimpleClass<false> {
*** 757,827 ****
      compilers that translate &cc; code into &c; code may permit
      inspecting the resulting code.  For example, using the
      <option>&dashdash;keep_gen_c</option> command-line option with the
!     <application class="software">KAI &cc; compiler</application>
!     <!-- FIXME: Reference or link? -->
!     <indexterm>
!      <primary>compiler</primary>
!      <secondary>KAI</secondary>
!     </indexterm>
!     <indexterm>
!      <primary><application class="software">KAI &cc; compiler</application></primary>
!      <see>compiler, KAI.</see>
!     </indexterm>
!     creates a file
!     containing the intermediate code.  Unfortunately,
!     reading and understanding the code is frequently difficult.</para>
  
      <para>Each category<firstterm></firstterm> of values supports a
      distinct set of operations.  For example, the run-time category of
!     integer values supports combination using <literal>+</literal>
!     and <literal>-</literal> and comparison using
!     <literal>></literal> and <literal>==</literal>.  At run
!     time, the category of strings can be compared using
!     <literal>==</literal> and characters can be extracted using
!     subscripts with the <literal>[]</literal> operator.  Compile-time
!     operations are more limited.  Types may be declared and used.  The
!     <literal>sizeof</literal> operator yields the number of
!     bytes to represent an object of the specified type.  Enumerations,
!     constant integers, <literal>sizeof</literal> expressions,
!     and simple arithmetic and comparison operators such as
!     <literal>+</literal> and <literal>==</literal> can form
      constant expressions that can be used at compile time.  These
      values can initialize enumerations and integer constants and be
      used as template arguments.  At compile time, pointers and
      references to objects and functions can be used as template
      arguments, while the category of executable code supports no
!     operations.  (The compiler's optimizer
!     <indexterm>
!      <primary>compiler</primary>
!      <secondary>optimizer</secondary>
!     </indexterm>
      may simplify it, though.)</para>
  
      <para id="template_programming-pooma_implementation-traits_class">
      <indexterm zone="template_programming-pooma_implementation-traits_class">
       <primary>traits class</primary>
-     </indexterm>
-     At run time, an object
-     <indexterm>
-      <primary>object</primary>
      </indexterm>
!     can store multiple values, each
!     having its own name.  For example, a <type>pair<int></type>
!     object <varname>p</varname> stores two ∫s named
!     <literal>left_</literal> and
      <literal>right_</literal>.  The <literal>.</literal>
!     operator
!     <indexterm>
!      <primary><literal>.</literal> operator</primary>
!     </indexterm>
      extracts a named member from an object:
!     <literal>p.left_</literal>.  At compile time, a class can
!     store multiple values, each having its own name.  These are
!     sometimes called <glossterm
      linkend="glossary-traits_class"><firstterm>traits
      classes</firstterm></glossterm>.  For example, implementing
!     data-parallel operations requiring storing a tree of types.
!     The <type>ExpressionTraits<BinaryNode<Op, Left,
      Right&closeclose;</type> traits class stores the types of a binary
      node representing the operation of <varname>Op</varname> on left
      and right children.  Its definition
--- 650,704 ----
      compilers that translate &cc; code into &c; code may permit
      inspecting the resulting code.  For example, using the
      <option>&dashdash;keep_gen_c</option> command-line option with the
!     <application class="software">KAI &cc;
!     compiler</application><indexterm><primary>compiler</primary><secondary>KAI</secondary></indexterm><indexterm><primary><application
!     class="software">KAI &cc;
!     compiler</application></primary><see>compiler,
!     KAI.</see></indexterm> creates a file containing the intermediate
!     code.  Unfortunately, reading and understanding the code is
!     frequently difficult.</para>
  
      <para>Each category<firstterm></firstterm> of values supports a
      distinct set of operations.  For example, the run-time category of
!     integer values supports combination using <literal>+</literal> and
!     <literal>-</literal> and comparison using <literal>></literal>
!     and <literal>==</literal>.  At run time, the category of strings
!     can be compared using <literal>==</literal> and characters can be
!     extracted using subscripts with the <literal>[]</literal>
!     operator.  Compile-time operations are more limited.  Types may be
!     declared and used.  The <literal>sizeof</literal> operator yields
!     the number of bytes to represent an object of the specified type.
!     Enumerations, constant integers, <literal>sizeof</literal>
!     expressions, and simple arithmetic and comparison operators such
!     as <literal>+</literal> and <literal>==</literal> can form
      constant expressions that can be used at compile time.  These
      values can initialize enumerations and integer constants and be
      used as template arguments.  At compile time, pointers and
      references to objects and functions can be used as template
      arguments, while the category of executable code supports no
!     operations.  (The compiler's
!     optimizer<indexterm><primary>compiler</primary><secondary>optimizer</secondary></indexterm>
      may simplify it, though.)</para>
  
      <para id="template_programming-pooma_implementation-traits_class">
      <indexterm zone="template_programming-pooma_implementation-traits_class">
       <primary>traits class</primary>
      </indexterm>
!     At run time, an
!     object<indexterm><primary>object</primary></indexterm> can store
!     multiple values, each having its own name.  For example, a
!     <type>pair<int></type> object <varname>p</varname>
!     stores two ∫s named <literal>left_</literal> and
      <literal>right_</literal>.  The <literal>.</literal>
!     operator<indexterm><primary><literal>.</literal> operator</primary></indexterm>
      extracts a named member from an object:
!     <literal>p.left_</literal>.  At compile time, a class can store
!     multiple values, each having its own name.  These are sometimes
!     called <glossterm
      linkend="glossary-traits_class"><firstterm>traits
      classes</firstterm></glossterm>.  For example, implementing
!     data-parallel operations requiring storing a tree of types.  The
!     <type>ExpressionTraits<BinaryNode<Op, Left,
      Right&closeclose;</type> traits class stores the types of a binary
      node representing the operation of <varname>Op</varname> on left
      and right children.  Its definition
*************** struct ExpressionTraits<BinaryNode&lt
*** 869,889 ****
      </indexterm>
      Control flow determines which code is used.  At run time,
      control-flow statements such as <literal>if</literal>,
!     <literal>while</literal>, and
!     <literal>goto</literal> determine which statements to
!     execute.  Template programming uses two mechanisms: template class
!     specializations and pattern matching.  These are similar to
!     control flow in functional programming languages.  A <glossterm
      linkend="glossary-traits_class"><firstterm>template class
      specialization</firstterm></glossterm> is a class definition
      specific to one or more template arguments.  For example, the
!     implementation for data-parallel operations
!     <indexterm>
!      <primary>data-parallel operation</primary>
!     </indexterm>
!     uses the templated <type>CreateLeaf</type>.  The default
!     definition works for any template
!     argument <varname>T</varname>:
  <programlisting>
  template<class T>
  struct CreateLeaf
--- 746,764 ----
      </indexterm>
      Control flow determines which code is used.  At run time,
      control-flow statements such as <literal>if</literal>,
!     <literal>while</literal>, and <literal>goto</literal> determine
!     which statements to execute.  Template programming uses two
!     mechanisms: template class specializations and pattern matching.
!     These are similar to control flow in functional programming
!     languages.  A <glossterm
      linkend="glossary-traits_class"><firstterm>template class
      specialization</firstterm></glossterm> is a class definition
      specific to one or more template arguments.  For example, the
!     implementation for data-parallel
!     operations<indexterm><primary>data-parallel
!     operation</primary></indexterm> uses the templated
!     <type>CreateLeaf</type>.  The default definition works for any
!     template argument <varname>T</varname>:
  <programlisting>
  template<class T>
  struct CreateLeaf
*************** struct CreateLeaf<Expression<T&clo
*** 932,944 ****
  
      <para>Control flow using template specializations and pattern
      matching is similar to <literal>switch</literal>
!     statements.
!     <indexterm>
!      <primary><literal>switch</literal></primary>
!     </indexterm>
      A <literal>switch</literal> statement has a
      condition and one or more pairs of case labels and associated
!     code.  The code associated with the the case label whose value
      matches the condition is executed.  If no case label matches the
      condition, the default code, if present, is used.  In template
      programming, instantiating a template, e.g.,
--- 807,816 ----
  
      <para>Control flow using template specializations and pattern
      matching is similar to <literal>switch</literal>
!     statements.<indexterm><primary><literal>switch</literal></primary></indexterm>
      A <literal>switch</literal> statement has a
      condition and one or more pairs of case labels and associated
!     code.  The code associated with the case label whose value
      matches the condition is executed.  If no case label matches the
      condition, the default code, if present, is used.  In template
      programming, instantiating a template, e.g.,
*************** CreateLeaf<Expression<int&closeclo
*** 956,964 ****
      default label since it matches any arguments.  If no set of
      template parameters match (which is impossible for our example) or
      if more than one set are best matches, the code is
!     incorrect.
!     <indexterm class="endofrange" startref="template_programming-pooma_implementation-index-control_flow">
!     </indexterm></para>
  
      <para>
      <indexterm class="startofrange" id="template_programming-pooma_implementation-function_template">
--- 828,834 ----
      default label since it matches any arguments.  If no set of
      template parameters match (which is impossible for our example) or
      if more than one set are best matches, the code is
!     incorrect.<indexterm class="endofrange" startref="template_programming-pooma_implementation-index-control_flow"></indexterm></para>
  
      <para>
      <indexterm class="startofrange" id="template_programming-pooma_implementation-function_template">
*************** void f(const T& t) { … }
*** 983,1008 ****
      functions equivalent to <function>f(const int&amp)</function>,
      <function>f(const bool&amp)</function>, <function>f(const
      int*&amp)</function>, ….  Using a templated class
!     definition with a static member function,
!     <indexterm>
!      <primary>function</primary>
!      <secondary>static member</secondary>
!     </indexterm>
!     <indexterm>
!      <primary>static member function</primary>
!      <see>function, static member</see>
!     </indexterm>
!     we can define an equivalent function:
!     <indexterm>
!      <primary>function</primary>
!      <secondary>static member</secondary>
!      <tertiary>equivalence with function template</tertiary>
!     </indexterm>
!     <indexterm>
!      <primary>template</primary>
!      <secondary>function</secondary>
!      <tertiary>equivalence with static member function</tertiary>
!     </indexterm>
  <programlisting>
  template <typename T>
  class F {
--- 853,859 ----
      functions equivalent to <function>f(const int&amp)</function>,
      <function>f(const bool&amp)</function>, <function>f(const
      int*&amp)</function>, ….  Using a templated class
!     definition with a static member function,<indexterm><primary>function</primary><secondary>static member</secondary></indexterm><indexterm><primary>static member function</primary><see>function, static member</see></indexterm> we can define an equivalent function:<indexterm><primary>function</primary><secondary>static member</secondary><tertiary>equivalence with function template</tertiary></indexterm><indexterm><primary>template</primary><secondary>function</secondary><tertiary>equivalence with static member function</tertiary></indexterm>
  <programlisting>
  template <typename T>
  class F {
*************** operator+(const Array<D1,T1,E1> & 
*** 1036,1079 ****
      possible to write expressions such as <literal>a1 +
      a2</literal>.  Member functions can also be templated.  This
      permits, for example, overloading of assignment operators defined
!     within templated classes.
!     <indexterm class="endofrange" startref="template_programming-pooma_implementation-function_template">
!     </indexterm>
!     </para>
  
!     <para>Function objects
!     <indexterm>
!      <primary>function</primary>
!      <secondary>object</secondary>
!     </indexterm>
!     are frequently useful in run-time code.
      They consist of a function plus some additional storage and are
      usually implemented as structures with data members and a function
!     call operator.
!     <indexterm>
!      <primary>function</primary>
!      <secondary>call operator</secondary>
!     </indexterm>
!     Analogous classes can be used at compile time.
!     Using the transformation
!     <indexterm>
!      <primary>function</primary>
!      <secondary>static member</secondary>
!      <tertiary>equivalence with function template</tertiary>
!     </indexterm>
!     <indexterm>
!      <primary>template</primary>
!      <secondary>function</secondary>
!      <tertiary>equivalence with static member function</tertiary>
!     </indexterm>
!     introduced in the previous paragraph, we
      see that any function can be transformed into a class containing a
!     static member function.
!     <indexterm>
!      <primary>function</primary>
!      <secondary>static member</secondary>
!     </indexterm>
!     Internal type definitions, enumerations,
      and static constant values can be added to the class.  The static
      member function can use these values during its computation.  The
      <type>CreateLeaf</type> structure, introduced above, illustrates this.
--- 887,901 ----
      possible to write expressions such as <literal>a1 +
      a2</literal>.  Member functions can also be templated.  This
      permits, for example, overloading of assignment operators defined
!     within templated classes.<indexterm class="endofrange" startref="template_programming-pooma_implementation-function_template"></indexterm></para>
  
!     <para>Function objects<indexterm><primary>function</primary><secondary>object</secondary></indexterm> are frequently useful in run-time code.
      They consist of a function plus some additional storage and are
      usually implemented as structures with data members and a function
!     call operator.<indexterm><primary>function</primary><secondary>call operator</secondary></indexterm> Analogous classes can be used at compile time.
!     Using the transformation<indexterm><primary>function</primary><secondary>static member</secondary><tertiary>equivalence with function template</tertiary></indexterm><indexterm><primary>template</primary><secondary>function</secondary><tertiary>equivalence with static member function</tertiary></indexterm> introduced in the previous paragraph, we
      see that any function can be transformed into a class containing a
!     static member function.<indexterm><primary>function</primary><secondary>static member</secondary></indexterm> Internal type definitions, enumerations,
      and static constant values can be added to the class.  The static
      member function can use these values during its computation.  The
      <type>CreateLeaf</type> structure, introduced above, illustrates this.
Index: tutorial.xml
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/tutorial.xml,v
retrieving revision 1.12
diff -c -p -r1.12 tutorial.xml
*** tutorial.xml	2002/02/27 03:51:53	1.12
--- tutorial.xml	2002/03/15 23:07:22
***************
*** 690,696 ****
    each context.  Regardless, the containers' domains are now
    distributed among the contexts so the program can run.  When a patch
    needs data from another patch, the &poomatoolkit; sends messages to
!   the desired patch uses the message-passing library.  All such
    communication is automatically performed by the &toolkit; with no
    need for programmer or user input.</para>
  
--- 690,696 ----
    each context.  Regardless, the containers' domains are now
    distributed among the contexts so the program can run.  When a patch
    needs data from another patch, the &poomatoolkit; sends messages to
!   the designated patch uses the message-passing library.  All such
    communication is automatically performed by the &toolkit; with no
    need for programmer or user input.</para>
  
*************** MultiPatch<UniformTag, Remote<Bric
*** 737,743 ****
  </programlisting> or
  <programlisting>
  MultiPatch<UniformTag, Remote<CompressibleBrick&closeclose;
! </programlisting> or &engine;s.</para>
  
    <para>The computations for a distributed implementation are exactly
    the same as for a sequential implementation.  The &poomatoolkit; and
--- 737,743 ----
  </programlisting> or
  <programlisting>
  MultiPatch<UniformTag, Remote<CompressibleBrick&closeclose;
! </programlisting> &engine;s.</para>
  
    <para>The computations for a distributed implementation are exactly
    the same as for a sequential implementation.  The &poomatoolkit; and
Index: figures/distributed-101.png
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/figures/distributed-101.png,v
retrieving revision 1.2
diff -c -p -r1.2 distributed-101.png
Binary files /tmp/cvsQn19cB and distributed-101.png differ
Index: figures/distributed.mp
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/figures/distributed.mp,v
retrieving revision 1.4
diff -c -p -r1.4 distributed.mp
*** figures/distributed.mp	2002/01/31 21:29:58	1.4
--- figures/distributed.mp	2002/03/15 23:07:23
*************** beginfig(101)
*** 184,190 ****
    foo = thelabel.bot(btex \begin{tabular}{c} Each context has memory and\\ processors to execute a program. \end{tabular} etex, c[1].s);
    unfill bbox foo;
    draw foo;
!   label.top(btex Computer Configuration etex, configurationBoundary.n);
  
    %% Draw the Computer Computation structures.
    for t = 0 upto 5:
--- 184,190 ----
    foo = thelabel.bot(btex \begin{tabular}{c} Each context has memory and\\ processors to execute a program. \end{tabular} etex, c[1].s);
    unfill bbox foo;
    draw foo;
!   label.top(btex Computer Con\avoidfi guration etex, configurationBoundary.n);
  
    %% Draw the Computer Computation structures.
    for t = 0 upto 5:


More information about the pooma-dev mailing list