Manual: Move Program Annotation Files
Jeffrey
oldham at mail.codesourcery.com
Fri Jan 25 03:31:18 UTC 2002
This patch deals with patches to convert executable code into
annotated programs suitable for DocBook. The files are
1) moved
2) revised to varying extents.
2002-Jan-24 Jeffrey D. Oldham <oldham at codesourcery.com>
* Doof2d-Array-distributed-annotated.patch: Move this file to
examples/Doof2d/.
* Doof2d-Array-element-annotated.patch: Likewise.
* Doof2d-Array-parallel-annotated.patch: Likewise.
* Doof2d-Array-stencil-annotated.patch: Likewise.
* Doof2d-C-element-annotated.patch: Likewise.
* Doof2d-Field-distributed-annotated.patch: Likewise.
* Doof2d-Field-parallel-annotated.patch: Likewise.
* Makefile: Likewise.
* initialize-finalize-annotated.patch: Likewise.
* pairs-templated-annotated.patch: Likewise.
* pairs-untemplated-annotated.patch: Likewise.
* examples/Doof2d-Array-distributed-annotated.patch: Likewise.
* examples/Doof2d-Array-element-annotated.patch: Likewise.
* examples/Doof2d-Array-parallel-annotated.patch: Likewise.
* examples/Doof2d-Array-stencil-annotated.patch: Likewise.
* examples/Doof2d-C-element-annotated.patch: Likewise.
* examples/Doof2d-Field-distributed-annotated.patch: Likewise.
* examples/Doof2d-Field-parallel-annotated.patch: Likewise.
* examples/Makefile: Likewise.
* examples/initialize-finalize-annotated.patch: Likewise.
* examples/pairs-templated-annotated.patch: Likewise.
* examples/pairs-untemplated-annotated.patch: Likewise.
* examples/Doof2d/Doof2d-Array-distributed-annotated.patch: Most
recent version of this file. Also moved here.
* examples/Doof2d/Doof2d-Array-element-annotated.patch: Likewise.
* examples/Doof2d/Doof2d-Array-parallel-annotated.patch: Likewise.
* examples/Doof2d/Doof2d-Array-stencil-annotated.patch: Likewise.
* examples/Doof2d/Doof2d-C-element-annotated.patch: Likewise.
* examples/Doof2d/Doof2d-Field-distributed-annotated.patch: Likewise.
* examples/Doof2d/Doof2d-Field-parallel-annotated.patch: Likewise.
* examples/Sequential/array-copy-annotated.patch: Likewise.
* examples/Sequential/array-size-annotated.patch: Likewise.
* examples/Sequential/dynamicarray-annotated.patch: Likewise.
* examples/Sequential/initialize-finalize-annotated.patch: Likewise.
* examples/Templates/pairs-templated-annotated.patch: Likewise.
Applied to mainline.
Approved by no one.
Thanks,
Jeffrey D. Oldham
oldham at codesourcery.com
-------------- next part --------------
Index: Doof2d-Array-distributed-annotated.patch
===================================================================
RCS file: Doof2d-Array-distributed-annotated.patch
diff -N Doof2d-Array-distributed-annotated.patch
*** /tmp/cvsQs5Bce Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,184 ****
- *** Doof2d-Array-distributed.cpp Wed Dec 5 14:04:36 2001
- --- Doof2d-Array-distributed-annotated.cpp Wed Dec 5 14:07:56 2001
- ***************
- *** 1,3 ****
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Arrays.h" // has Pooma's Array
-
- --- 1,5 ----
- ! <programlisting id="tutorial-array_distributed-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Arrays.h" // has Pooma's Array
-
- ***************
- *** 14,18 ****
- // (i,j). The "C" template parameter permits use of this stencil
- // operator with both Arrays and Fields.
- ! template <class C>
- inline
- typename C::Element_t
- --- 16,20 ----
- // (i,j). The "C" template parameter permits use of this stencil
- // operator with both Arrays and Fields.
- ! template <class C>
- inline
- typename C::Element_t
- ***************
- *** 42,46 ****
- // canot use standard input and output. Instead we use command-line
- // arguments, which are replicated, for input, and we use an Inform
- ! // stream for output.
- Inform output;
-
- --- 44,48 ----
- // canot use standard input and output. Instead we use command-line
- // arguments, which are replicated, for input, and we use an Inform
- ! // stream for output. <co id="tutorial-array_distributed-doof2d-io"></co>
- Inform output;
-
- ***************
- *** 48,52 ****
- if (argc != 4) {
- // Incorrect number of command-line arguments.
- ! output << argv[0] << ": number-of-processors number-of-averagings number-of-values" << std::endl;
- return EXIT_FAILURE;
- }
- --- 50,54 ----
- if (argc != 4) {
- // Incorrect number of command-line arguments.
- ! output &openopen; argv[0] &openopen; ": number-of-processors number-of-averagings number-of-values" &openopen; std::endl;
- return EXIT_FAILURE;
- }
- ***************
- *** 55,63 ****
- // Determine the number of processors.
- long nuProcessors;
- ! nuProcessors = strtol(argv[1], &tail, 0);
-
- // Determine the number of averagings.
- long nuAveragings, nuIterations;
- ! nuAveragings = strtol(argv[2], &tail, 0);
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- --- 57,65 ----
- // Determine the number of processors.
- long nuProcessors;
- ! nuProcessors = strtol(argv[1], &tail, 0);
-
- // Determine the number of averagings.
- long nuAveragings, nuIterations;
- ! nuAveragings = strtol(argv[2], &tail, 0);
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ***************
- *** 65,69 ****
- // the grid.
- long n;
- ! n = strtol(argv[3], &tail, 0);
- // The dimension must be a multiple of the number of processors
- // since we are using a UniformGridLayout.
- --- 67,71 ----
- // the grid.
- long n;
- ! n = strtol(argv[3], &tail, 0);
- // The dimension must be a multiple of the number of processors
- // since we are using a UniformGridLayout.
- ***************
- *** 71,80 ****
-
- // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<2> interiorDomain(I,I);
-
- // Create the distributed arrays.
- --- 73,82 ----
-
- // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<2> interiorDomain(I,I);
-
- // Create the distributed arrays.
- ***************
- *** 83,98 ****
- // dimension. Guard layers optimize communication between patches.
- // Internal guards surround each patch. External guards surround
- ! // the entire array domain.
- ! UniformGridPartition<2> partition(Loc<2>(nuProcessors, nuProcessors),
- ! GuardLayers<2>(1), // internal
- ! GuardLayers<2>(0)); // external
- ! UniformGridLayout<2> layout(vertDomain, partition, DistributedTag());
-
- // The template parameters indicate 2 dimensions and a 'double'
- // element type. MultiPatch indicates multiple computation patches,
- // i.e., distributed computation. The UniformTag indicates the
- ! // patches should have the same size. Each patch has Brick type.
- ! Array<2, double, MultiPatch<UniformTag, Remote<Brick> > > a(layout);
- ! Array<2, double, MultiPatch<UniformTag, Remote<Brick> > > b(layout);
-
- // Set up the initial conditions.
- --- 85,100 ----
- // dimension. Guard layers optimize communication between patches.
- // Internal guards surround each patch. External guards surround
- ! // the entire array domain. <co id="tutorial-array_distributed-doof2d-layout"></co>
- ! UniformGridPartition<2> partition(Loc<2>(nuProcessors, nuProcessors),
- ! GuardLayers<2>(1), // internal
- ! GuardLayers<2>(0)); // external
- ! UniformGridLayout<2> layout(vertDomain, partition, DistributedTag());
-
- // The template parameters indicate 2 dimensions and a 'double'
- // element type. MultiPatch indicates multiple computation patches,
- // i.e., distributed computation. The UniformTag indicates the
- ! // patches should have the same size. Each patch has Brick type. <co id="tutorial-array_distributed-doof2d-remote"></co>
- ! Array<2, double, MultiPatch<UniformTag, Remote<Brick> > > a(layout);
- ! Array<2, double, MultiPatch<UniformTag, Remote<Brick> > > b(layout);
-
- // Set up the initial conditions.
- ***************
- *** 104,112 ****
-
- // Create the stencil performing the computation.
- ! Stencil<DoofNinePt> stencil;
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a.
- a(interiorDomain) = stencil(b, interiorDomain);
-
- --- 106,114 ----
-
- // Create the stencil performing the computation.
- ! Stencil<DoofNinePt> stencil;
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a. <co id="tutorial-array_distributed-doof2d-first_write"></co>
- a(interiorDomain) = stencil(b, interiorDomain);
-
- ***************
- *** 117,121 ****
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! output << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
-
- // The arrays are automatically deallocated.
- --- 119,123 ----
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! output &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
-
- // The arrays are automatically deallocated.
- ***************
- *** 125,126 ****
- --- 127,129 ----
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: Doof2d-Array-element-annotated.patch
===================================================================
RCS file: Doof2d-Array-element-annotated.patch
diff -N Doof2d-Array-element-annotated.patch
*** /tmp/cvsW8TBRh Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,143 ****
- *** Doof2d-Array-element.cpp Tue Dec 4 12:02:10 2001
- --- Doof2d-Array-element-annotated.cpp Tue Dec 4 12:24:25 2001
- ***************
- *** 1,5 ****
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- ! #include "Pooma/Arrays.h" // has Pooma's Array
-
- // Doof2d: Pooma Arrays, element-wise implementation
- --- 1,6 ----
- ! <programlisting id="tutorial-array_elementwise-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- ! #include "Pooma/Arrays.h" // has Pooma's Array <co id="tutorial-array_elementwise-doof2d-header"></co>
-
- // Doof2d: Pooma Arrays, element-wise implementation
- ***************
- *** 7,17 ****
- int main(int argc, char *argv[])
- {
- ! // Prepare the Pooma library for execution.
- Pooma::initialize(argc,argv);
-
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout << "Please enter the number of averagings: ";
- ! std::cin >> nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- --- 8,18 ----
- int main(int argc, char *argv[])
- {
- ! // Prepare the Pooma library for execution. <co id="tutorial-array_elementwise-doof2d-pooma_initialize"></co>
- Pooma::initialize(argc,argv);
-
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout &openopen; "Please enter the number of averagings: ";
- ! std::cin &closeclose; nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ***************
- *** 19,37 ****
- // the grid.
- long n;
- ! std::cout << "Please enter the array size: ";
- ! std::cin >> n;
-
- ! // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- ! // Create the arrays.
- // The template parameters indicate 2 dimensions, a 'double' element
- // type, and ordinary 'Brick' storage.
- ! Array<2, double, Brick> a(vertDomain);
- ! Array<2, double, Brick> b(vertDomain);
-
- // Set up the initial conditions.
- ! // All grid values should be zero except for the central value.
- for (int j = 1; j < n-1; j++)
- for (int i = 1; i < n-1; i++)
- --- 20,38 ----
- // the grid.
- long n;
- ! std::cout &openopen; "Please enter the array size: ";
- ! std::cin &closeclose; n;
-
- ! // Specify the arrays' domains [0,n) x [0,n). <co id="tutorial-array_elementwise-doof2d-domain"></co>
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- ! // Create the arrays. <co id="tutorial-array_elementwise-doof2d-array_creation"></co>
- // The template parameters indicate 2 dimensions, a 'double' element
- // type, and ordinary 'Brick' storage.
- ! Array<2, double, Brick> a(vertDomain);
- ! Array<2, double, Brick> b(vertDomain);
-
- // Set up the initial conditions.
- ! // All grid values should be zero except for the central value. <co id="tutorial-array_elementwise-doof2d-initialization"></co>
- for (int j = 1; j < n-1; j++)
- for (int i = 1; i < n-1; i++)
- ***************
- *** 43,51 ****
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- // Read from b. Write to a.
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- ! a(i,j) = weight *
- (b(i+1,j+1) + b(i+1,j ) + b(i+1,j-1) +
- b(i ,j+1) + b(i ,j ) + b(i ,j-1) +
- --- 44,52 ----
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- // Read from b. Write to a.
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- ! a(i,j) = weight * <co id="tutorial-array_elementwise-doof2d-first_write"></co>
- (b(i+1,j+1) + b(i+1,j ) + b(i+1,j-1) +
- b(i ,j+1) + b(i ,j ) + b(i ,j-1) +
- ***************
- *** 53,58 ****
-
- // Read from a. Write to b.
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- b(i,j) = weight *
- (a(i+1,j+1) + a(i+1,j ) + a(i+1,j-1) +
- --- 54,59 ----
-
- // Read from a. Write to b.
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- b(i,j) = weight *
- (a(i+1,j+1) + a(i+1,j ) + a(i+1,j-1) +
- ***************
- *** 62,71 ****
-
- // Print out the final central value.
- ! std::cout << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
-
- ! // The arrays are automatically deallocated.
-
- ! // Tell the Pooma library execution has finished.
- Pooma::finalize();
- return EXIT_SUCCESS;
- }
- --- 63,74 ----
-
- // Print out the final central value.
- ! Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
-
- ! // The arrays are automatically deallocated. <co id="tutorial-array_elementwise-doof2d-deallocation"></co>
-
- ! // Tell the Pooma library execution has finished. <co id="tutorial-array_elementwise-doof2d-pooma_finish"></co>
- Pooma::finalize();
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: Doof2d-Array-parallel-annotated.patch
===================================================================
RCS file: Doof2d-Array-parallel-annotated.patch
diff -N Doof2d-Array-parallel-annotated.patch
*** /tmp/cvs0nlUsn Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,116 ****
- *** Doof2d-Array-parallel.cpp Tue Dec 4 11:49:43 2001
- --- Doof2d-Array-parallel-annotated.cpp Tue Dec 4 12:24:36 2001
- ***************
- *** 1,4 ****
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Arrays.h" // has Pooma's Array
-
- --- 1,5 ----
- ! <programlisting id="tutorial-array_parallel-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Arrays.h" // has Pooma's Array
-
- ***************
- *** 12,17 ****
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout << "Please enter the number of averagings: ";
- ! std::cin >> nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- --- 13,18 ----
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout &openopen; "Please enter the number of averagings: ";
- ! std::cin &closeclose; nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ***************
- *** 19,43 ****
- // the grid.
- long n;
- ! std::cout << "Please enter the array size: ";
- ! std::cin >> n;
-
- // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- ! // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<1> J(1,n-2);
-
- // Create the arrays.
- // The template parameters indicate 2 dimensions, a 'double' element
- // type, and ordinary 'Brick' storage.
- ! Array<2, double, Brick> a(vertDomain);
- ! Array<2, double, Brick> b(vertDomain);
-
- // Set up the initial conditions.
- // All grid values should be zero except for the central value.
- a = b = 0.0;
- ! // Ensure all data-parallel computation finishes before accessing a value.
- Pooma::blockAndEvaluate();
- b(n/2,n/2) = 1000.0;
- --- 20,44 ----
- // the grid.
- long n;
- ! std::cout &openopen; "Please enter the array size: ";
- ! std::cin &closeclose; n;
-
- // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- ! // Set up interior domains [1,n-1) x [1,n-1) for computation. <co id="tutorial-array_parallel-doof2d-innerdomain"></co>
- ! Interval<1> I(1,n-2);
- ! Interval<1> J(1,n-2);
-
- // Create the arrays.
- // The template parameters indicate 2 dimensions, a 'double' element
- // type, and ordinary 'Brick' storage.
- ! Array<2, double, Brick> a(vertDomain);
- ! Array<2, double, Brick> b(vertDomain);
-
- // Set up the initial conditions.
- // All grid values should be zero except for the central value.
- a = b = 0.0;
- ! // Ensure all data-parallel computation finishes before accessing a value. <co id="tutorial-array_parallel-doof2d-blockAndEvaluate"></co>
- Pooma::blockAndEvaluate();
- b(n/2,n/2) = 1000.0;
- ***************
- *** 47,52 ****
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a.
- a(I,J) = weight *
- (b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
- --- 48,53 ----
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a. <co id="tutorial-array_parallel-doof2d-first_write"></co>
- a(I,J) = weight *
- (b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
- ***************
- *** 63,67 ****
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
-
- // The arrays are automatically deallocated.
- --- 64,68 ----
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
-
- // The arrays are automatically deallocated.
- ***************
- *** 71,72 ****
- --- 72,74 ----
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: Doof2d-Array-stencil-annotated.patch
===================================================================
RCS file: Doof2d-Array-stencil-annotated.patch
diff -N Doof2d-Array-stencil-annotated.patch
*** /tmp/cvsERegQs Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,152 ****
- *** Doof2d-Array-stencil.cpp Tue Dec 4 11:49:39 2001
- --- Doof2d-Array-stencil-annotated.cpp Tue Dec 4 12:26:46 2001
- ***************
- *** 1,9 ****
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Arrays.h" // has Pooma's Array
-
- // Doof2d: Pooma Arrays, stencil implementation
-
- ! // Define the stencil class performing the computation.
- class DoofNinePt
- {
- --- 1,10 ----
- ! <programlisting id="tutorial-array_stencil-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Arrays.h" // has Pooma's Array
-
- // Doof2d: Pooma Arrays, stencil implementation
-
- ! // Define the stencil class performing the computation. <co id="tutorial-array_stencil-doof2d-stencil"></co>
- class DoofNinePt
- {
- ***************
- *** 14,19 ****
- // This stencil operator is applied to each interior domain position
- // (i,j). The "C" template parameter permits use of this stencil
- ! // operator with both Arrays and Fields.
- ! template <class C>
- inline
- typename C::Element_t
- --- 15,20 ----
- // This stencil operator is applied to each interior domain position
- // (i,j). The "C" template parameter permits use of this stencil
- ! // operator with both Arrays and Fields. <co id="tutorial-array_stencil-doof2d-stencil_operator"></co>
- ! template <class C>
- inline
- typename C::Element_t
- ***************
- *** 26,30 ****
- }
-
- ! inline int lowerExtent(int) const { return 1; }
- inline int upperExtent(int) const { return 1; }
-
- --- 27,31 ----
- }
-
- ! inline int lowerExtent(int) const { return 1; } <co id="tutorial-array_stencil-doof2d-stencil_extent"></co>
- inline int upperExtent(int) const { return 1; }
-
- ***************
- *** 42,47 ****
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout << "Please enter the number of averagings: ";
- ! std::cin >> nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- --- 43,48 ----
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout &openopen; "Please enter the number of averagings: ";
- ! std::cin &closeclose; nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ***************
- *** 49,68 ****
- // the grid.
- long n;
- ! std::cout << "Please enter the array size: ";
- ! std::cin >> n;
-
- // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<2> interiorDomain(I,I);
-
- // Create the arrays.
- // The template parameters indicate 2 dimensions, a 'double' element
- // type, and ordinary 'Brick' storage.
- ! Array<2, double, Brick> a(vertDomain);
- ! Array<2, double, Brick> b(vertDomain);
-
- // Set up the initial conditions.
- --- 50,69 ----
- // the grid.
- long n;
- ! std::cout &openopen; "Please enter the array size: ";
- ! std::cin &closeclose; n;
-
- // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<2> interiorDomain(I,I);
-
- // Create the arrays.
- // The template parameters indicate 2 dimensions, a 'double' element
- // type, and ordinary 'Brick' storage.
- ! Array<2, double, Brick> a(vertDomain);
- ! Array<2, double, Brick> b(vertDomain);
-
- // Set up the initial conditions.
- ***************
- *** 73,82 ****
- b(n/2,n/2) = 1000.0;
-
- ! // Create the stencil performing the computation.
- ! Stencil<DoofNinePt> stencil;
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a.
- a(interiorDomain) = stencil(b, interiorDomain);
-
- --- 74,83 ----
- b(n/2,n/2) = 1000.0;
-
- ! // Create the stencil performing the computation. <co id="tutorial-array_stencil-doof2d-stencil_creation"></co>
- ! Stencil<DoofNinePt> stencil;
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a. <co id="tutorial-array_stencil-doof2d-first_write"></co>
- a(interiorDomain) = stencil(b, interiorDomain);
-
- ***************
- *** 87,91 ****
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
-
- // The arrays are automatically deallocated.
- --- 88,92 ----
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
-
- // The arrays are automatically deallocated.
- ***************
- *** 95,96 ****
- --- 96,98 ----
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: Doof2d-C-element-annotated.patch
===================================================================
RCS file: Doof2d-C-element-annotated.patch
diff -N Doof2d-C-element-annotated.patch
*** /tmp/cvsgKf9Vx Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,150 ****
- *** Doof2d-C-element.cpp Tue Nov 27 08:36:38 2001
- --- Doof2d-C-element-annotated.cpp Tue Nov 27 12:08:03 2001
- ***************
- *** 1,4 ****
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
-
- // Doof2d: C-like, element-wise implementation
- --- 1,5 ----
- ! <programlisting id="tutorial-hand_coded-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
-
- // Doof2d: C-like, element-wise implementation
- ***************
- *** 6,30 ****
- int main()
- {
- ! // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout << "Please enter the number of averagings: ";
- ! std::cin >> nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ! // Use two-dimensional grids of values.
- double **a;
- double **b;
-
- // Ask the user for the number n of elements along one dimension of
- ! // the grid.
- long n;
- ! std::cout << "Please enter the array size: ";
- ! std::cin >> n;
-
- ! // Allocate the arrays.
- typedef double* doublePtr;
- a = new doublePtr[n];
- b = new doublePtr[n];
- ! for (int i = 0; i < n; i++) {
- a[i] = new double[n];
- b[i] = new double[n];
- --- 7,31 ----
- int main()
- {
- ! // Ask the user for the number of averagings. <co id="tutorial-hand_coded-doof2d-nuaveragings"></co>
- long nuAveragings, nuIterations;
- ! std::cout &openopen; "Please enter the number of averagings: ";
- ! std::cin &closeclose; nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ! // Use two-dimensional grids of values. <co id="tutorial-hand_coded-doof2d-array_storage"></co>
- double **a;
- double **b;
-
- // Ask the user for the number n of elements along one dimension of
- ! // the grid. <co id="tutorial-hand_coded-doof2d-grid_size"></co>
- long n;
- ! std::cout &openopen; "Please enter the array size: ";
- ! std::cin &closeclose; n;
-
- ! // Allocate the arrays. <co id="tutorial-hand_coded-doof2d-allocation"></co>
- typedef double* doublePtr;
- a = new doublePtr[n];
- b = new doublePtr[n];
- ! for (int i = 0; i < n; i++) {
- a[i] = new double[n];
- b[i] = new double[n];
- ***************
- *** 32,49 ****
-
- // Set up the initial conditions.
- ! // All grid values should be zero except for the central value.
- ! for (int j = 0; j < n; j++)
- ! for (int i = 0; i < n; i++)
- a[i][j] = b[i][j] = 0.0;
- b[n/2][n/2] = 1000.0;
-
- ! // In the average, weight elements with this value.
- const double weight = 1.0/9.0;
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a.
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- a[i][j] = weight *
- (b[i+1][j+1] + b[i+1][j ] + b[i+1][j-1] +
- --- 33,50 ----
-
- // Set up the initial conditions.
- ! // All grid values should be zero except for the central value. <co id="tutorial-hand_coded-doof2d-initialization"></co>
- ! for (int j = 0; j < n; j++)
- ! for (int i = 0; i < n; i++)
- a[i][j] = b[i][j] = 0.0;
- b[n/2][n/2] = 1000.0;
-
- ! // In the average, weight elements with this value. <co id="tutorial-hand_coded-doof2d-constants"></co>
- const double weight = 1.0/9.0;
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a. <co id="tutorial-hand_coded-doof2d-first_write"></co>
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- a[i][j] = weight *
- (b[i+1][j+1] + b[i+1][j ] + b[i+1][j-1] +
- ***************
- *** 51,57 ****
- b[i-1][j+1] + b[i-1][j ] + b[i-1][j-1]);
-
- ! // Read from a. Write to b.
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- b[i][j] = weight *
- (a[i+1][j+1] + a[i+1][j ] + a[i+1][j-1] +
- --- 52,58 ----
- b[i-1][j+1] + b[i-1][j ] + b[i-1][j-1]);
-
- ! // Read from a. Write to b. <co id="tutorial-hand_coded-doof2d-second_write"></co>
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- b[i][j] = weight *
- (a[i+1][j+1] + a[i+1][j ] + a[i+1][j-1] +
- ***************
- *** 60,68 ****
- }
-
- ! // Print out the final central value.
- ! std::cout << (nuAveragings % 2 ? a[n/2][n/2] : b[n/2][n/2]) << std::endl;
-
- ! // Deallocate the arrays.
- ! for (int i = 0; i < n; i++) {
- delete [] a[i];
- delete [] b[i];
- --- 61,69 ----
- }
-
- ! // Print out the final central value. <co id="tutorial-hand_coded-doof2d-answer"></co>
- ! std::cout &openopen; (nuAveragings % 2 ? a[n/2][n/2] : b[n/2][n/2]) &openopen; std::endl;
-
- ! // Deallocate the arrays. <co id="tutorial-hand_coded-doof2d-deallocation"></co>
- ! for (int i = 0; i < n; i++) {
- delete [] a[i];
- delete [] b[i];
- ***************
- *** 73,74 ****
- --- 74,76 ----
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: Doof2d-Field-distributed-annotated.patch
===================================================================
RCS file: Doof2d-Field-distributed-annotated.patch
diff -N Doof2d-Field-distributed-annotated.patch
*** /tmp/cvsg1eoJC Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,176 ****
- *** Doof2d-Field-distributed.cpp Wed Dec 5 14:05:10 2001
- --- Doof2d-Field-distributed-annotated.cpp Wed Dec 5 14:41:24 2001
- ***************
- *** 1,3 ****
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Fields.h" // has Pooma's Field
-
- --- 1,4 ----
- ! <programlisting id="tutorial-field_distributed-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Fields.h" // has Pooma's Field
-
- ***************
- *** 12,16 ****
- // canot use standard input and output. Instead we use command-line
- // arguments, which are replicated, for input, and we use an Inform
- ! // stream for output.
- Inform output;
-
- --- 13,17 ----
- // canot use standard input and output. Instead we use command-line
- // arguments, which are replicated, for input, and we use an Inform
- ! // stream for output. <co id="tutorial-field_distributed-doof2d-io"></co>
- Inform output;
-
- ***************
- *** 18,22 ****
- if (argc != 4) {
- // Incorrect number of command-line arguments.
- ! output << argv[0] << ": number-of-processors number-of-averagings number-of-values" << std::endl;
- return EXIT_FAILURE;
- }
- --- 19,23 ----
- if (argc != 4) {
- // Incorrect number of command-line arguments.
- ! output &openopen; argv[0] &openopen; ": number-of-processors number-of-averagings number-of-values" &openopen; std::endl;
- return EXIT_FAILURE;
- }
- ***************
- *** 25,33 ****
- // Determine the number of processors.
- long nuProcessors;
- ! nuProcessors = strtol(argv[1], &tail, 0);
-
- // Determine the number of averagings.
- long nuAveragings, nuIterations;
- ! nuAveragings = strtol(argv[2], &tail, 0);
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- --- 26,34 ----
- // Determine the number of processors.
- long nuProcessors;
- ! nuProcessors = strtol(argv[1], &tail, 0);
-
- // Determine the number of averagings.
- long nuAveragings, nuIterations;
- ! nuAveragings = strtol(argv[2], &tail, 0);
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ***************
- *** 35,39 ****
- // the grid.
- long n;
- ! n = strtol(argv[3], &tail, 0);
- // The dimension must be a multiple of the number of processors
- // since we are using a UniformGridLayout.
- --- 36,40 ----
- // the grid.
- long n;
- ! n = strtol(argv[3], &tail, 0);
- // The dimension must be a multiple of the number of processors
- // since we are using a UniformGridLayout.
- ***************
- *** 41,50 ****
-
- // Specify the fields' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<1> J(1,n-2);
-
- // Partition the fields' domains uniformly, i.e., each patch has the
- --- 42,51 ----
-
- // Specify the fields' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<1> J(1,n-2);
-
- // Partition the fields' domains uniformly, i.e., each patch has the
- ***************
- *** 52,74 ****
- // dimension. Guard layers optimize communication between patches.
- // Internal guards surround each patch. External guards surround
- ! // the entire field domain.
- ! UniformGridPartition<2> partition(Loc<2>(nuProcessors, nuProcessors),
- ! GuardLayers<2>(1), // internal
- ! GuardLayers<2>(0)); // external
- ! UniformGridLayout<2> layout(vertDomain, partition, DistributedTag());
-
- // Specify the fields' mesh, i.e., its spatial extent, and its
- ! // centering type.
- ! UniformRectilinearMesh<2> mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
- ! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
-
- // The template parameters indicate a mesh and a 'double'
- // element type. MultiPatch indicates multiple computation patches,
- // i.e., distributed computation. The UniformTag indicates the
- ! // patches should have the same size. Each patch has Brick type.
- ! Field<UniformRectilinearMesh<2>, double, MultiPatch<UniformTag,
- ! Remote<Brick> > > a(cell, layout, mesh);
- ! Field<UniformRectilinearMesh<2>, double, MultiPatch<UniformTag,
- ! Remote<Brick> > > b(cell, layout, mesh);
-
- // Set up the initial conditions.
- --- 53,75 ----
- // dimension. Guard layers optimize communication between patches.
- // Internal guards surround each patch. External guards surround
- ! // the entire field domain. <co id="tutorial-field_distributed-doof2d-layout"></co>
- ! UniformGridPartition<2> partition(Loc<2>(nuProcessors, nuProcessors),
- ! GuardLayers<2>(1), // internal
- ! GuardLayers<2>(0)); // external
- ! UniformGridLayout<2> layout(vertDomain, partition, DistributedTag());
-
- // Specify the fields' mesh, i.e., its spatial extent, and its
- ! // centering type. <co id="tutorial-field_distributed-doof2d-mesh"></co>
- ! UniformRectilinearMesh<2> mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
- ! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
-
- // The template parameters indicate a mesh and a 'double'
- // element type. MultiPatch indicates multiple computation patches,
- // i.e., distributed computation. The UniformTag indicates the
- ! // patches should have the same size. Each patch has Brick type. <co id="tutorial-field_distributed-doof2d-remote"></co>
- ! Field<UniformRectilinearMesh<2>, double, MultiPatch<UniformTag,
- ! Remote<Brick> > > a(cell, layout, mesh);
- ! Field<UniformRectilinearMesh<2>, double, MultiPatch<UniformTag,
- ! Remote<Brick> > > b(cell, layout, mesh);
-
- // Set up the initial conditions.
- ***************
- *** 83,87 ****
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- // Read from b. Write to a.
- a(I,J) = weight *
- --- 84,88 ----
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- // Read from b. Write to a.
- a(I,J) = weight *
- ***************
- *** 99,103 ****
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! output << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
-
- // The fields are automatically deallocated.
- --- 100,104 ----
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! output &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
-
- // The fields are automatically deallocated.
- ***************
- *** 107,108 ****
- --- 108,110 ----
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: Doof2d-Field-parallel-annotated.patch
===================================================================
RCS file: Doof2d-Field-parallel-annotated.patch
diff -N Doof2d-Field-parallel-annotated.patch
*** /tmp/cvsq9uXsJ Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,120 ****
- *** Doof2d-Field-parallel.cpp Tue Dec 4 10:01:28 2001
- --- Doof2d-Field-parallel-annotated.cpp Tue Dec 4 11:04:26 2001
- ***************
- *** 1,5 ****
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- ! #include "Pooma/Fields.h" // has Pooma's Field
-
- // Doof2d: Pooma Fields, data-parallel implementation
- --- 1,6 ----
- ! <programlisting id="tutorial-field_parallel-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- ! #include "Pooma/Fields.h" // has Pooma's Field <co id="tutorial-field_parallel-doof2d-header"></co>
-
- // Doof2d: Pooma Fields, data-parallel implementation
- ***************
- *** 12,17 ****
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout << "Please enter the number of averagings: ";
- ! std::cin >> nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- --- 13,18 ----
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout &openopen; "Please enter the number of averagings: ";
- ! std::cin &closeclose; nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ***************
- *** 19,44 ****
- // the grid.
- long n;
- ! std::cout << "Please enter the field size: ";
- ! std::cin >> n;
-
- // Specify the fields' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<1> J(1,n-2);
-
- // Specify the fields' mesh, i.e., its spatial extent, and its
- ! // centering type.
- ! DomainLayout<2> layout(vertDomain);
- ! UniformRectilinearMesh<2> mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
- ! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
-
- // Create the fields.
- // The template parameters indicate a mesh, a 'double' element
- ! // type, and ordinary 'Brick' storage.
- ! Field<UniformRectilinearMesh<2>, double, Brick> a(cell, layout, mesh);
- ! Field<UniformRectilinearMesh<2>, double, Brick> b(cell, layout, mesh);
-
- // Set up the initial conditions.
- --- 20,45 ----
- // the grid.
- long n;
- ! std::cout &openopen; "Please enter the field size: ";
- ! std::cin &closeclose; n;
-
- // Specify the fields' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<1> J(1,n-2);
-
- // Specify the fields' mesh, i.e., its spatial extent, and its
- ! // centering type. <co id="tutorial-field_parallel-doof2d-mesh"></co>
- ! DomainLayout<2> layout(vertDomain);
- ! UniformRectilinearMesh<2> mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
- ! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
-
- // Create the fields.
- // The template parameters indicate a mesh, a 'double' element
- ! // type, and ordinary 'Brick' storage. <co id="tutorial-field_parallel-doof2d-field_creation"></co>
- ! Field<UniformRectilinearMesh<2>, double, Brick> a(cell, layout, mesh);
- ! Field<UniformRectilinearMesh<2>, double, Brick> b(cell, layout, mesh);
-
- // Set up the initial conditions.
- ***************
- *** 51,56 ****
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a.
- a(I,J) = weight *
- (b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
- --- 52,57 ----
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a. <co id="tutorial-field_parallel-doof2d-first_write"></co>
- a(I,J) = weight *
- (b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
- ***************
- *** 67,71 ****
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
-
- // The fields are automatically deallocated.
- --- 68,72 ----
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
-
- // The fields are automatically deallocated.
- ***************
- *** 75,76 ****
- --- 76,78 ----
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
*** /tmp/cvsgROIRP Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,13 ****
- ### Oldham, Jeffrey D.
- ### 2001Nov27
- ### Pooma
- ###
- ### Produce Annotated Source Code
-
- all: Doof2d-C-element-annotated.cpp Doof2d-Array-element-annotated.cpp \
- Doof2d-Array-parallel-annotated.cpp Doof2d-Array-stencil-annotated.cpp \
- Doof2d-Array-distributed-annotated.cpp \
- Doof2d-Field-parallel-annotated.cpp Doof2d-Field-distributed-annotated.cpp
-
- %-annotated.cpp: %-annotated.patch %.cpp
- patch -o $@ < $<
--- 0 ----
Index: initialize-finalize-annotated.patch
===================================================================
RCS file: initialize-finalize-annotated.patch
diff -N initialize-finalize-annotated.patch
*** /tmp/cvs6U9YaW Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,14 ****
- *** initialize-finalize.cpp Sat Dec 15 15:35:57 2001
- --- initialize-finalize-annotated.cpp Sun Dec 16 14:24:43 2001
- ***************
- *** 1,2 ****
- --- 1,3 ----
- + <programlisting id="initialize-finalize-program" linenumbering="numbered" format="linespecific">
- #include "Pooma/Pooma.h"
-
- ***************
- *** 10,11 ****
- --- 11,13 ----
- return 0;
- }
- + </programlisting>
--- 0 ----
Index: pairs-templated-annotated.patch
===================================================================
RCS file: pairs-templated-annotated.patch
diff -N pairs-templated-annotated.patch
*** /tmp/cvsucf6o2 Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,37 ****
- *** pairs-templated.cpp Wed Dec 26 14:01:38 2001
- --- pairs-templated-annotated.cpp Wed Dec 26 14:12:51 2001
- ***************
- *** 1,15 ****
- ! // Declare a template class storing a pair of values with the same type.
- ! template <typename T>
- struct pair {
- ! pair(const int& left, const int& right)
- : left_(left), right_(right) {}
-
- ! T left_;
- T right_;
- };
-
- ! // Use a class storing a pair of integers.
- ! pair<int> pair1;
-
- // Use a class storing a pair of doubles;
- ! pair<double> pair2;
- --- 1,17 ----
- ! <programlisting id="template_programming-template_use-templated_pair_program" linenumbering="numbered" format="linespecific">
- ! // Declare a template class storing a pair of values with the same type. <co id="template_programming-template_use-templated_pair_program-template_declaration"></co>
- ! template <typename T>
- struct pair {
- ! pair(const T& left, const T& right) // <co id="template_programming-template_use-templated_pair_program-constructor"></co>
- : left_(left), right_(right) {}
-
- ! T left_; // <co id="template_programming-template_use-templated_pair_program-members"></co>
- T right_;
- };
-
- ! // Use a class storing a pair of integers. <co id="template_programming-template_use-templated_pair_program-use"></co>
- ! pair<int> pair1;
-
- // Use a class storing a pair of doubles;
- ! pair<double> pair2;
- ! </programlisting>
--- 0 ----
Index: pairs-untemplated-annotated.patch
===================================================================
RCS file: pairs-untemplated-annotated.patch
diff -N pairs-untemplated-annotated.patch
*** /tmp/cvsqR3av8 Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,35 ****
- *** pairs-untemplated.cpp Wed Dec 26 13:48:10 2001
- --- pairs-untemplated-annotated.cpp Wed Dec 26 14:02:58 2001
- ***************
- *** 1,5 ****
- // Declare a class storing a pair of integers.
- struct pairOfInts {
- ! pairOfInts(const int& left, const int& right)
- : left_(left), right_(right) {}
-
- --- 1,6 ----
- + <programlisting id="template_programming-template_use-untemplated_pair_program" linenumbering="numbered" format="linespecific">
- // Declare a class storing a pair of integers.
- struct pairOfInts {
- ! pairOfInts(const int& left, const int& right)
- : left_(left), right_(right) {}
-
- ***************
- *** 10,14 ****
- // Declare a class storing a pair of doubles.
- struct pairOfDoubles {
- ! pairOfDoubles(const double& left, const double& right)
- : left_(left), right_(right) {}
-
- --- 11,15 ----
- // Declare a class storing a pair of doubles.
- struct pairOfDoubles {
- ! pairOfDoubles(const double& left, const double& right)
- : left_(left), right_(right) {}
-
- ***************
- *** 16,17 ****
- --- 17,19 ----
- double right_;
- };
- + </programlisting>
--- 0 ----
Index: examples/Doof2d-Array-distributed-annotated.patch
===================================================================
RCS file: Doof2d-Array-distributed-annotated.patch
diff -N Doof2d-Array-distributed-annotated.patch
*** /tmp/cvsSYg3pe Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,184 ****
- *** Doof2d-Array-distributed.cpp Wed Dec 5 14:04:36 2001
- --- Doof2d-Array-distributed-annotated.cpp Wed Dec 5 14:07:56 2001
- ***************
- *** 1,3 ****
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Arrays.h" // has Pooma's Array
-
- --- 1,5 ----
- ! <programlisting id="tutorial-array_distributed-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Arrays.h" // has Pooma's Array
-
- ***************
- *** 14,18 ****
- // (i,j). The "C" template parameter permits use of this stencil
- // operator with both Arrays and Fields.
- ! template <class C>
- inline
- typename C::Element_t
- --- 16,20 ----
- // (i,j). The "C" template parameter permits use of this stencil
- // operator with both Arrays and Fields.
- ! template <class C>
- inline
- typename C::Element_t
- ***************
- *** 42,46 ****
- // canot use standard input and output. Instead we use command-line
- // arguments, which are replicated, for input, and we use an Inform
- ! // stream for output.
- Inform output;
-
- --- 44,48 ----
- // canot use standard input and output. Instead we use command-line
- // arguments, which are replicated, for input, and we use an Inform
- ! // stream for output. <co id="tutorial-array_distributed-doof2d-io"></co>
- Inform output;
-
- ***************
- *** 48,52 ****
- if (argc != 4) {
- // Incorrect number of command-line arguments.
- ! output << argv[0] << ": number-of-processors number-of-averagings number-of-values" << std::endl;
- return EXIT_FAILURE;
- }
- --- 50,54 ----
- if (argc != 4) {
- // Incorrect number of command-line arguments.
- ! output &openopen; argv[0] &openopen; ": number-of-processors number-of-averagings number-of-values" &openopen; std::endl;
- return EXIT_FAILURE;
- }
- ***************
- *** 55,63 ****
- // Determine the number of processors.
- long nuProcessors;
- ! nuProcessors = strtol(argv[1], &tail, 0);
-
- // Determine the number of averagings.
- long nuAveragings, nuIterations;
- ! nuAveragings = strtol(argv[2], &tail, 0);
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- --- 57,65 ----
- // Determine the number of processors.
- long nuProcessors;
- ! nuProcessors = strtol(argv[1], &tail, 0);
-
- // Determine the number of averagings.
- long nuAveragings, nuIterations;
- ! nuAveragings = strtol(argv[2], &tail, 0);
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ***************
- *** 65,69 ****
- // the grid.
- long n;
- ! n = strtol(argv[3], &tail, 0);
- // The dimension must be a multiple of the number of processors
- // since we are using a UniformGridLayout.
- --- 67,71 ----
- // the grid.
- long n;
- ! n = strtol(argv[3], &tail, 0);
- // The dimension must be a multiple of the number of processors
- // since we are using a UniformGridLayout.
- ***************
- *** 71,80 ****
-
- // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<2> interiorDomain(I,I);
-
- // Create the distributed arrays.
- --- 73,82 ----
-
- // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<2> interiorDomain(I,I);
-
- // Create the distributed arrays.
- ***************
- *** 83,98 ****
- // dimension. Guard layers optimize communication between patches.
- // Internal guards surround each patch. External guards surround
- ! // the entire array domain.
- ! UniformGridPartition<2> partition(Loc<2>(nuProcessors, nuProcessors),
- ! GuardLayers<2>(1), // internal
- ! GuardLayers<2>(0)); // external
- ! UniformGridLayout<2> layout(vertDomain, partition, DistributedTag());
-
- // The template parameters indicate 2 dimensions and a 'double'
- // element type. MultiPatch indicates multiple computation patches,
- // i.e., distributed computation. The UniformTag indicates the
- ! // patches should have the same size. Each patch has Brick type.
- ! Array<2, double, MultiPatch<UniformTag, Remote<Brick> > > a(layout);
- ! Array<2, double, MultiPatch<UniformTag, Remote<Brick> > > b(layout);
-
- // Set up the initial conditions.
- --- 85,100 ----
- // dimension. Guard layers optimize communication between patches.
- // Internal guards surround each patch. External guards surround
- ! // the entire array domain. <co id="tutorial-array_distributed-doof2d-layout"></co>
- ! UniformGridPartition<2> partition(Loc<2>(nuProcessors, nuProcessors),
- ! GuardLayers<2>(1), // internal
- ! GuardLayers<2>(0)); // external
- ! UniformGridLayout<2> layout(vertDomain, partition, DistributedTag());
-
- // The template parameters indicate 2 dimensions and a 'double'
- // element type. MultiPatch indicates multiple computation patches,
- // i.e., distributed computation. The UniformTag indicates the
- ! // patches should have the same size. Each patch has Brick type. <co id="tutorial-array_distributed-doof2d-remote"></co>
- ! Array<2, double, MultiPatch<UniformTag, Remote<Brick> > > a(layout);
- ! Array<2, double, MultiPatch<UniformTag, Remote<Brick> > > b(layout);
-
- // Set up the initial conditions.
- ***************
- *** 104,112 ****
-
- // Create the stencil performing the computation.
- ! Stencil<DoofNinePt> stencil;
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a.
- a(interiorDomain) = stencil(b, interiorDomain);
-
- --- 106,114 ----
-
- // Create the stencil performing the computation.
- ! Stencil<DoofNinePt> stencil;
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a. <co id="tutorial-array_distributed-doof2d-first_write"></co>
- a(interiorDomain) = stencil(b, interiorDomain);
-
- ***************
- *** 117,121 ****
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! output << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
-
- // The arrays are automatically deallocated.
- --- 119,123 ----
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! output &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
-
- // The arrays are automatically deallocated.
- ***************
- *** 125,126 ****
- --- 127,129 ----
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: examples/Doof2d-Array-element-annotated.patch
===================================================================
RCS file: Doof2d-Array-element-annotated.patch
diff -N Doof2d-Array-element-annotated.patch
*** /tmp/cvs0NfShm Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,143 ****
- *** Doof2d-Array-element.cpp Tue Dec 4 12:02:10 2001
- --- Doof2d-Array-element-annotated.cpp Tue Dec 4 12:24:25 2001
- ***************
- *** 1,5 ****
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- ! #include "Pooma/Arrays.h" // has Pooma's Array
-
- // Doof2d: Pooma Arrays, element-wise implementation
- --- 1,6 ----
- ! <programlisting id="tutorial-array_elementwise-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- ! #include "Pooma/Arrays.h" // has Pooma's Array <co id="tutorial-array_elementwise-doof2d-header"></co>
-
- // Doof2d: Pooma Arrays, element-wise implementation
- ***************
- *** 7,17 ****
- int main(int argc, char *argv[])
- {
- ! // Prepare the Pooma library for execution.
- Pooma::initialize(argc,argv);
-
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout << "Please enter the number of averagings: ";
- ! std::cin >> nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- --- 8,18 ----
- int main(int argc, char *argv[])
- {
- ! // Prepare the Pooma library for execution. <co id="tutorial-array_elementwise-doof2d-pooma_initialize"></co>
- Pooma::initialize(argc,argv);
-
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout &openopen; "Please enter the number of averagings: ";
- ! std::cin &closeclose; nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ***************
- *** 19,37 ****
- // the grid.
- long n;
- ! std::cout << "Please enter the array size: ";
- ! std::cin >> n;
-
- ! // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- ! // Create the arrays.
- // The template parameters indicate 2 dimensions, a 'double' element
- // type, and ordinary 'Brick' storage.
- ! Array<2, double, Brick> a(vertDomain);
- ! Array<2, double, Brick> b(vertDomain);
-
- // Set up the initial conditions.
- ! // All grid values should be zero except for the central value.
- for (int j = 1; j < n-1; j++)
- for (int i = 1; i < n-1; i++)
- --- 20,38 ----
- // the grid.
- long n;
- ! std::cout &openopen; "Please enter the array size: ";
- ! std::cin &closeclose; n;
-
- ! // Specify the arrays' domains [0,n) x [0,n). <co id="tutorial-array_elementwise-doof2d-domain"></co>
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- ! // Create the arrays. <co id="tutorial-array_elementwise-doof2d-array_creation"></co>
- // The template parameters indicate 2 dimensions, a 'double' element
- // type, and ordinary 'Brick' storage.
- ! Array<2, double, Brick> a(vertDomain);
- ! Array<2, double, Brick> b(vertDomain);
-
- // Set up the initial conditions.
- ! // All grid values should be zero except for the central value. <co id="tutorial-array_elementwise-doof2d-initialization"></co>
- for (int j = 1; j < n-1; j++)
- for (int i = 1; i < n-1; i++)
- ***************
- *** 43,51 ****
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- // Read from b. Write to a.
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- ! a(i,j) = weight *
- (b(i+1,j+1) + b(i+1,j ) + b(i+1,j-1) +
- b(i ,j+1) + b(i ,j ) + b(i ,j-1) +
- --- 44,52 ----
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- // Read from b. Write to a.
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- ! a(i,j) = weight * <co id="tutorial-array_elementwise-doof2d-first_write"></co>
- (b(i+1,j+1) + b(i+1,j ) + b(i+1,j-1) +
- b(i ,j+1) + b(i ,j ) + b(i ,j-1) +
- ***************
- *** 53,58 ****
-
- // Read from a. Write to b.
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- b(i,j) = weight *
- (a(i+1,j+1) + a(i+1,j ) + a(i+1,j-1) +
- --- 54,59 ----
-
- // Read from a. Write to b.
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- b(i,j) = weight *
- (a(i+1,j+1) + a(i+1,j ) + a(i+1,j-1) +
- ***************
- *** 62,71 ****
-
- // Print out the final central value.
- ! std::cout << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
-
- ! // The arrays are automatically deallocated.
-
- ! // Tell the Pooma library execution has finished.
- Pooma::finalize();
- return EXIT_SUCCESS;
- }
- --- 63,74 ----
-
- // Print out the final central value.
- ! Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
-
- ! // The arrays are automatically deallocated. <co id="tutorial-array_elementwise-doof2d-deallocation"></co>
-
- ! // Tell the Pooma library execution has finished. <co id="tutorial-array_elementwise-doof2d-pooma_finish"></co>
- Pooma::finalize();
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: examples/Doof2d-Array-parallel-annotated.patch
===================================================================
RCS file: Doof2d-Array-parallel-annotated.patch
diff -N Doof2d-Array-parallel-annotated.patch
*** /tmp/cvsaOFKTt Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,116 ****
- *** Doof2d-Array-parallel.cpp Tue Dec 4 11:49:43 2001
- --- Doof2d-Array-parallel-annotated.cpp Tue Dec 4 12:24:36 2001
- ***************
- *** 1,4 ****
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Arrays.h" // has Pooma's Array
-
- --- 1,5 ----
- ! <programlisting id="tutorial-array_parallel-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Arrays.h" // has Pooma's Array
-
- ***************
- *** 12,17 ****
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout << "Please enter the number of averagings: ";
- ! std::cin >> nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- --- 13,18 ----
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout &openopen; "Please enter the number of averagings: ";
- ! std::cin &closeclose; nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ***************
- *** 19,43 ****
- // the grid.
- long n;
- ! std::cout << "Please enter the array size: ";
- ! std::cin >> n;
-
- // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- ! // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<1> J(1,n-2);
-
- // Create the arrays.
- // The template parameters indicate 2 dimensions, a 'double' element
- // type, and ordinary 'Brick' storage.
- ! Array<2, double, Brick> a(vertDomain);
- ! Array<2, double, Brick> b(vertDomain);
-
- // Set up the initial conditions.
- // All grid values should be zero except for the central value.
- a = b = 0.0;
- ! // Ensure all data-parallel computation finishes before accessing a value.
- Pooma::blockAndEvaluate();
- b(n/2,n/2) = 1000.0;
- --- 20,44 ----
- // the grid.
- long n;
- ! std::cout &openopen; "Please enter the array size: ";
- ! std::cin &closeclose; n;
-
- // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- ! // Set up interior domains [1,n-1) x [1,n-1) for computation. <co id="tutorial-array_parallel-doof2d-innerdomain"></co>
- ! Interval<1> I(1,n-2);
- ! Interval<1> J(1,n-2);
-
- // Create the arrays.
- // The template parameters indicate 2 dimensions, a 'double' element
- // type, and ordinary 'Brick' storage.
- ! Array<2, double, Brick> a(vertDomain);
- ! Array<2, double, Brick> b(vertDomain);
-
- // Set up the initial conditions.
- // All grid values should be zero except for the central value.
- a = b = 0.0;
- ! // Ensure all data-parallel computation finishes before accessing a value. <co id="tutorial-array_parallel-doof2d-blockAndEvaluate"></co>
- Pooma::blockAndEvaluate();
- b(n/2,n/2) = 1000.0;
- ***************
- *** 47,52 ****
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a.
- a(I,J) = weight *
- (b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
- --- 48,53 ----
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a. <co id="tutorial-array_parallel-doof2d-first_write"></co>
- a(I,J) = weight *
- (b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
- ***************
- *** 63,67 ****
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
-
- // The arrays are automatically deallocated.
- --- 64,68 ----
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
-
- // The arrays are automatically deallocated.
- ***************
- *** 71,72 ****
- --- 72,74 ----
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: examples/Doof2d-Array-stencil-annotated.patch
===================================================================
RCS file: Doof2d-Array-stencil-annotated.patch
diff -N Doof2d-Array-stencil-annotated.patch
*** /tmp/cvs4b053A Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,152 ****
- *** Doof2d-Array-stencil.cpp Tue Dec 4 11:49:39 2001
- --- Doof2d-Array-stencil-annotated.cpp Tue Dec 4 12:26:46 2001
- ***************
- *** 1,9 ****
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Arrays.h" // has Pooma's Array
-
- // Doof2d: Pooma Arrays, stencil implementation
-
- ! // Define the stencil class performing the computation.
- class DoofNinePt
- {
- --- 1,10 ----
- ! <programlisting id="tutorial-array_stencil-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Arrays.h" // has Pooma's Array
-
- // Doof2d: Pooma Arrays, stencil implementation
-
- ! // Define the stencil class performing the computation. <co id="tutorial-array_stencil-doof2d-stencil"></co>
- class DoofNinePt
- {
- ***************
- *** 14,19 ****
- // This stencil operator is applied to each interior domain position
- // (i,j). The "C" template parameter permits use of this stencil
- ! // operator with both Arrays and Fields.
- ! template <class C>
- inline
- typename C::Element_t
- --- 15,20 ----
- // This stencil operator is applied to each interior domain position
- // (i,j). The "C" template parameter permits use of this stencil
- ! // operator with both Arrays and Fields. <co id="tutorial-array_stencil-doof2d-stencil_operator"></co>
- ! template <class C>
- inline
- typename C::Element_t
- ***************
- *** 26,30 ****
- }
-
- ! inline int lowerExtent(int) const { return 1; }
- inline int upperExtent(int) const { return 1; }
-
- --- 27,31 ----
- }
-
- ! inline int lowerExtent(int) const { return 1; } <co id="tutorial-array_stencil-doof2d-stencil_extent"></co>
- inline int upperExtent(int) const { return 1; }
-
- ***************
- *** 42,47 ****
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout << "Please enter the number of averagings: ";
- ! std::cin >> nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- --- 43,48 ----
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout &openopen; "Please enter the number of averagings: ";
- ! std::cin &closeclose; nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ***************
- *** 49,68 ****
- // the grid.
- long n;
- ! std::cout << "Please enter the array size: ";
- ! std::cin >> n;
-
- // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<2> interiorDomain(I,I);
-
- // Create the arrays.
- // The template parameters indicate 2 dimensions, a 'double' element
- // type, and ordinary 'Brick' storage.
- ! Array<2, double, Brick> a(vertDomain);
- ! Array<2, double, Brick> b(vertDomain);
-
- // Set up the initial conditions.
- --- 50,69 ----
- // the grid.
- long n;
- ! std::cout &openopen; "Please enter the array size: ";
- ! std::cin &closeclose; n;
-
- // Specify the arrays' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<2> interiorDomain(I,I);
-
- // Create the arrays.
- // The template parameters indicate 2 dimensions, a 'double' element
- // type, and ordinary 'Brick' storage.
- ! Array<2, double, Brick> a(vertDomain);
- ! Array<2, double, Brick> b(vertDomain);
-
- // Set up the initial conditions.
- ***************
- *** 73,82 ****
- b(n/2,n/2) = 1000.0;
-
- ! // Create the stencil performing the computation.
- ! Stencil<DoofNinePt> stencil;
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a.
- a(interiorDomain) = stencil(b, interiorDomain);
-
- --- 74,83 ----
- b(n/2,n/2) = 1000.0;
-
- ! // Create the stencil performing the computation. <co id="tutorial-array_stencil-doof2d-stencil_creation"></co>
- ! Stencil<DoofNinePt> stencil;
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a. <co id="tutorial-array_stencil-doof2d-first_write"></co>
- a(interiorDomain) = stencil(b, interiorDomain);
-
- ***************
- *** 87,91 ****
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
-
- // The arrays are automatically deallocated.
- --- 88,92 ----
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
-
- // The arrays are automatically deallocated.
- ***************
- *** 95,96 ****
- --- 96,98 ----
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: examples/Doof2d-C-element-annotated.patch
===================================================================
RCS file: Doof2d-C-element-annotated.patch
diff -N Doof2d-C-element-annotated.patch
*** /tmp/cvsCww7hK Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,150 ****
- *** Doof2d-C-element.cpp Tue Nov 27 08:36:38 2001
- --- Doof2d-C-element-annotated.cpp Tue Nov 27 12:08:03 2001
- ***************
- *** 1,4 ****
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
-
- // Doof2d: C-like, element-wise implementation
- --- 1,5 ----
- ! <programlisting id="tutorial-hand_coded-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
-
- // Doof2d: C-like, element-wise implementation
- ***************
- *** 6,30 ****
- int main()
- {
- ! // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout << "Please enter the number of averagings: ";
- ! std::cin >> nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ! // Use two-dimensional grids of values.
- double **a;
- double **b;
-
- // Ask the user for the number n of elements along one dimension of
- ! // the grid.
- long n;
- ! std::cout << "Please enter the array size: ";
- ! std::cin >> n;
-
- ! // Allocate the arrays.
- typedef double* doublePtr;
- a = new doublePtr[n];
- b = new doublePtr[n];
- ! for (int i = 0; i < n; i++) {
- a[i] = new double[n];
- b[i] = new double[n];
- --- 7,31 ----
- int main()
- {
- ! // Ask the user for the number of averagings. <co id="tutorial-hand_coded-doof2d-nuaveragings"></co>
- long nuAveragings, nuIterations;
- ! std::cout &openopen; "Please enter the number of averagings: ";
- ! std::cin &closeclose; nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ! // Use two-dimensional grids of values. <co id="tutorial-hand_coded-doof2d-array_storage"></co>
- double **a;
- double **b;
-
- // Ask the user for the number n of elements along one dimension of
- ! // the grid. <co id="tutorial-hand_coded-doof2d-grid_size"></co>
- long n;
- ! std::cout &openopen; "Please enter the array size: ";
- ! std::cin &closeclose; n;
-
- ! // Allocate the arrays. <co id="tutorial-hand_coded-doof2d-allocation"></co>
- typedef double* doublePtr;
- a = new doublePtr[n];
- b = new doublePtr[n];
- ! for (int i = 0; i < n; i++) {
- a[i] = new double[n];
- b[i] = new double[n];
- ***************
- *** 32,49 ****
-
- // Set up the initial conditions.
- ! // All grid values should be zero except for the central value.
- ! for (int j = 0; j < n; j++)
- ! for (int i = 0; i < n; i++)
- a[i][j] = b[i][j] = 0.0;
- b[n/2][n/2] = 1000.0;
-
- ! // In the average, weight elements with this value.
- const double weight = 1.0/9.0;
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a.
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- a[i][j] = weight *
- (b[i+1][j+1] + b[i+1][j ] + b[i+1][j-1] +
- --- 33,50 ----
-
- // Set up the initial conditions.
- ! // All grid values should be zero except for the central value. <co id="tutorial-hand_coded-doof2d-initialization"></co>
- ! for (int j = 0; j < n; j++)
- ! for (int i = 0; i < n; i++)
- a[i][j] = b[i][j] = 0.0;
- b[n/2][n/2] = 1000.0;
-
- ! // In the average, weight elements with this value. <co id="tutorial-hand_coded-doof2d-constants"></co>
- const double weight = 1.0/9.0;
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a. <co id="tutorial-hand_coded-doof2d-first_write"></co>
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- a[i][j] = weight *
- (b[i+1][j+1] + b[i+1][j ] + b[i+1][j-1] +
- ***************
- *** 51,57 ****
- b[i-1][j+1] + b[i-1][j ] + b[i-1][j-1]);
-
- ! // Read from a. Write to b.
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- b[i][j] = weight *
- (a[i+1][j+1] + a[i+1][j ] + a[i+1][j-1] +
- --- 52,58 ----
- b[i-1][j+1] + b[i-1][j ] + b[i-1][j-1]);
-
- ! // Read from a. Write to b. <co id="tutorial-hand_coded-doof2d-second_write"></co>
- ! for (int j = 1; j < n-1; j++)
- ! for (int i = 1; i < n-1; i++)
- b[i][j] = weight *
- (a[i+1][j+1] + a[i+1][j ] + a[i+1][j-1] +
- ***************
- *** 60,68 ****
- }
-
- ! // Print out the final central value.
- ! std::cout << (nuAveragings % 2 ? a[n/2][n/2] : b[n/2][n/2]) << std::endl;
-
- ! // Deallocate the arrays.
- ! for (int i = 0; i < n; i++) {
- delete [] a[i];
- delete [] b[i];
- --- 61,69 ----
- }
-
- ! // Print out the final central value. <co id="tutorial-hand_coded-doof2d-answer"></co>
- ! std::cout &openopen; (nuAveragings % 2 ? a[n/2][n/2] : b[n/2][n/2]) &openopen; std::endl;
-
- ! // Deallocate the arrays. <co id="tutorial-hand_coded-doof2d-deallocation"></co>
- ! for (int i = 0; i < n; i++) {
- delete [] a[i];
- delete [] b[i];
- ***************
- *** 73,74 ****
- --- 74,76 ----
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: examples/Doof2d-Field-distributed-annotated.patch
===================================================================
RCS file: Doof2d-Field-distributed-annotated.patch
diff -N Doof2d-Field-distributed-annotated.patch
*** /tmp/cvswwII7S Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,176 ****
- *** Doof2d-Field-distributed.cpp Wed Dec 5 14:05:10 2001
- --- Doof2d-Field-distributed-annotated.cpp Wed Dec 5 14:41:24 2001
- ***************
- *** 1,3 ****
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Fields.h" // has Pooma's Field
-
- --- 1,4 ----
- ! <programlisting id="tutorial-field_distributed-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <stdlib.h> // has EXIT_SUCCESS
- #include "Pooma/Fields.h" // has Pooma's Field
-
- ***************
- *** 12,16 ****
- // canot use standard input and output. Instead we use command-line
- // arguments, which are replicated, for input, and we use an Inform
- ! // stream for output.
- Inform output;
-
- --- 13,17 ----
- // canot use standard input and output. Instead we use command-line
- // arguments, which are replicated, for input, and we use an Inform
- ! // stream for output. <co id="tutorial-field_distributed-doof2d-io"></co>
- Inform output;
-
- ***************
- *** 18,22 ****
- if (argc != 4) {
- // Incorrect number of command-line arguments.
- ! output << argv[0] << ": number-of-processors number-of-averagings number-of-values" << std::endl;
- return EXIT_FAILURE;
- }
- --- 19,23 ----
- if (argc != 4) {
- // Incorrect number of command-line arguments.
- ! output &openopen; argv[0] &openopen; ": number-of-processors number-of-averagings number-of-values" &openopen; std::endl;
- return EXIT_FAILURE;
- }
- ***************
- *** 25,33 ****
- // Determine the number of processors.
- long nuProcessors;
- ! nuProcessors = strtol(argv[1], &tail, 0);
-
- // Determine the number of averagings.
- long nuAveragings, nuIterations;
- ! nuAveragings = strtol(argv[2], &tail, 0);
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- --- 26,34 ----
- // Determine the number of processors.
- long nuProcessors;
- ! nuProcessors = strtol(argv[1], &tail, 0);
-
- // Determine the number of averagings.
- long nuAveragings, nuIterations;
- ! nuAveragings = strtol(argv[2], &tail, 0);
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ***************
- *** 35,39 ****
- // the grid.
- long n;
- ! n = strtol(argv[3], &tail, 0);
- // The dimension must be a multiple of the number of processors
- // since we are using a UniformGridLayout.
- --- 36,40 ----
- // the grid.
- long n;
- ! n = strtol(argv[3], &tail, 0);
- // The dimension must be a multiple of the number of processors
- // since we are using a UniformGridLayout.
- ***************
- *** 41,50 ****
-
- // Specify the fields' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<1> J(1,n-2);
-
- // Partition the fields' domains uniformly, i.e., each patch has the
- --- 42,51 ----
-
- // Specify the fields' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<1> J(1,n-2);
-
- // Partition the fields' domains uniformly, i.e., each patch has the
- ***************
- *** 52,74 ****
- // dimension. Guard layers optimize communication between patches.
- // Internal guards surround each patch. External guards surround
- ! // the entire field domain.
- ! UniformGridPartition<2> partition(Loc<2>(nuProcessors, nuProcessors),
- ! GuardLayers<2>(1), // internal
- ! GuardLayers<2>(0)); // external
- ! UniformGridLayout<2> layout(vertDomain, partition, DistributedTag());
-
- // Specify the fields' mesh, i.e., its spatial extent, and its
- ! // centering type.
- ! UniformRectilinearMesh<2> mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
- ! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
-
- // The template parameters indicate a mesh and a 'double'
- // element type. MultiPatch indicates multiple computation patches,
- // i.e., distributed computation. The UniformTag indicates the
- ! // patches should have the same size. Each patch has Brick type.
- ! Field<UniformRectilinearMesh<2>, double, MultiPatch<UniformTag,
- ! Remote<Brick> > > a(cell, layout, mesh);
- ! Field<UniformRectilinearMesh<2>, double, MultiPatch<UniformTag,
- ! Remote<Brick> > > b(cell, layout, mesh);
-
- // Set up the initial conditions.
- --- 53,75 ----
- // dimension. Guard layers optimize communication between patches.
- // Internal guards surround each patch. External guards surround
- ! // the entire field domain. <co id="tutorial-field_distributed-doof2d-layout"></co>
- ! UniformGridPartition<2> partition(Loc<2>(nuProcessors, nuProcessors),
- ! GuardLayers<2>(1), // internal
- ! GuardLayers<2>(0)); // external
- ! UniformGridLayout<2> layout(vertDomain, partition, DistributedTag());
-
- // Specify the fields' mesh, i.e., its spatial extent, and its
- ! // centering type. <co id="tutorial-field_distributed-doof2d-mesh"></co>
- ! UniformRectilinearMesh<2> mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
- ! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
-
- // The template parameters indicate a mesh and a 'double'
- // element type. MultiPatch indicates multiple computation patches,
- // i.e., distributed computation. The UniformTag indicates the
- ! // patches should have the same size. Each patch has Brick type. <co id="tutorial-field_distributed-doof2d-remote"></co>
- ! Field<UniformRectilinearMesh<2>, double, MultiPatch<UniformTag,
- ! Remote<Brick> > > a(cell, layout, mesh);
- ! Field<UniformRectilinearMesh<2>, double, MultiPatch<UniformTag,
- ! Remote<Brick> > > b(cell, layout, mesh);
-
- // Set up the initial conditions.
- ***************
- *** 83,87 ****
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- // Read from b. Write to a.
- a(I,J) = weight *
- --- 84,88 ----
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- // Read from b. Write to a.
- a(I,J) = weight *
- ***************
- *** 99,103 ****
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! output << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
-
- // The fields are automatically deallocated.
- --- 100,104 ----
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! output &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
-
- // The fields are automatically deallocated.
- ***************
- *** 107,108 ****
- --- 108,110 ----
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: examples/Doof2d-Field-parallel-annotated.patch
===================================================================
RCS file: Doof2d-Field-parallel-annotated.patch
diff -N Doof2d-Field-parallel-annotated.patch
*** /tmp/cvsOaLly1 Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,120 ****
- *** Doof2d-Field-parallel.cpp Tue Dec 4 10:01:28 2001
- --- Doof2d-Field-parallel-annotated.cpp Tue Dec 4 11:04:26 2001
- ***************
- *** 1,5 ****
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- ! #include "Pooma/Fields.h" // has Pooma's Field
-
- // Doof2d: Pooma Fields, data-parallel implementation
- --- 1,6 ----
- ! <programlisting id="tutorial-field_parallel-doof2d-program" linenumbering="numbered" format="linespecific">
- ! #include <iostream> // has std::cout, ...
- ! #include <stdlib.h> // has EXIT_SUCCESS
- ! #include "Pooma/Fields.h" // has Pooma's Field <co id="tutorial-field_parallel-doof2d-header"></co>
-
- // Doof2d: Pooma Fields, data-parallel implementation
- ***************
- *** 12,17 ****
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout << "Please enter the number of averagings: ";
- ! std::cin >> nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- --- 13,18 ----
- // Ask the user for the number of averagings.
- long nuAveragings, nuIterations;
- ! std::cout &openopen; "Please enter the number of averagings: ";
- ! std::cin &closeclose; nuAveragings;
- nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
-
- ***************
- *** 19,44 ****
- // the grid.
- long n;
- ! std::cout << "Please enter the field size: ";
- ! std::cin >> n;
-
- // Specify the fields' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<1> J(1,n-2);
-
- // Specify the fields' mesh, i.e., its spatial extent, and its
- ! // centering type.
- ! DomainLayout<2> layout(vertDomain);
- ! UniformRectilinearMesh<2> mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
- ! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
-
- // Create the fields.
- // The template parameters indicate a mesh, a 'double' element
- ! // type, and ordinary 'Brick' storage.
- ! Field<UniformRectilinearMesh<2>, double, Brick> a(cell, layout, mesh);
- ! Field<UniformRectilinearMesh<2>, double, Brick> b(cell, layout, mesh);
-
- // Set up the initial conditions.
- --- 20,45 ----
- // the grid.
- long n;
- ! std::cout &openopen; "Please enter the field size: ";
- ! std::cin &closeclose; n;
-
- // Specify the fields' domains [0,n) x [0,n).
- ! Interval<1> N(0, n-1);
- ! Interval<2> vertDomain(N, N);
-
- // Set up interior domains [1,n-1) x [1,n-1) for computation.
- ! Interval<1> I(1,n-2);
- ! Interval<1> J(1,n-2);
-
- // Specify the fields' mesh, i.e., its spatial extent, and its
- ! // centering type. <co id="tutorial-field_parallel-doof2d-mesh"></co>
- ! DomainLayout<2> layout(vertDomain);
- ! UniformRectilinearMesh<2> mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
- ! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
-
- // Create the fields.
- // The template parameters indicate a mesh, a 'double' element
- ! // type, and ordinary 'Brick' storage. <co id="tutorial-field_parallel-doof2d-field_creation"></co>
- ! Field<UniformRectilinearMesh<2>, double, Brick> a(cell, layout, mesh);
- ! Field<UniformRectilinearMesh<2>, double, Brick> b(cell, layout, mesh);
-
- // Set up the initial conditions.
- ***************
- *** 51,56 ****
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a.
- a(I,J) = weight *
- (b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
- --- 52,57 ----
-
- // Perform the simulation.
- ! for (int k = 0; k < nuIterations; ++k) {
- ! // Read from b. Write to a. <co id="tutorial-field_parallel-doof2d-first_write"></co>
- a(I,J) = weight *
- (b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
- ***************
- *** 67,71 ****
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
-
- // The fields are automatically deallocated.
- --- 68,72 ----
- // Print out the final central value.
- Pooma::blockAndEvaluate(); // Ensure all computation has finished.
- ! std::cout &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
-
- // The fields are automatically deallocated.
- ***************
- *** 75,76 ****
- --- 76,78 ----
- return EXIT_SUCCESS;
- }
- + </programlisting>
--- 0 ----
Index: examples/Makefile
===================================================================
RCS file: Makefile
diff -N Makefile
*** /tmp/cvsca9QN9 Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,13 ****
- ### Oldham, Jeffrey D.
- ### 2001Nov27
- ### Pooma
- ###
- ### Produce Annotated Source Code
-
- all: Doof2d-C-element-annotated.cpp Doof2d-Array-element-annotated.cpp \
- Doof2d-Array-parallel-annotated.cpp Doof2d-Array-stencil-annotated.cpp \
- Doof2d-Array-distributed-annotated.cpp \
- Doof2d-Field-parallel-annotated.cpp Doof2d-Field-distributed-annotated.cpp
-
- %-annotated.cpp: %-annotated.patch %.cpp
- patch -o $@ < $<
--- 0 ----
Index: examples/initialize-finalize-annotated.patch
===================================================================
RCS file: initialize-finalize-annotated.patch
diff -N initialize-finalize-annotated.patch
*** /tmp/cvsQZFDjk Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,14 ****
- *** initialize-finalize.cpp Sat Dec 15 15:35:57 2001
- --- initialize-finalize-annotated.cpp Sun Dec 16 14:24:43 2001
- ***************
- *** 1,2 ****
- --- 1,3 ----
- + <programlisting id="initialize-finalize-program" linenumbering="numbered" format="linespecific">
- #include "Pooma/Pooma.h"
-
- ***************
- *** 10,11 ****
- --- 11,13 ----
- return 0;
- }
- + </programlisting>
--- 0 ----
Index: examples/pairs-templated-annotated.patch
===================================================================
RCS file: pairs-templated-annotated.patch
diff -N pairs-templated-annotated.patch
*** /tmp/cvsWpEoKu Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,37 ****
- *** pairs-templated.cpp Wed Dec 26 14:01:38 2001
- --- pairs-templated-annotated.cpp Wed Dec 26 14:12:51 2001
- ***************
- *** 1,15 ****
- ! // Declare a template class storing a pair of values with the same type.
- ! template <typename T>
- struct pair {
- ! pair(const int& left, const int& right)
- : left_(left), right_(right) {}
-
- ! T left_;
- T right_;
- };
-
- ! // Use a class storing a pair of integers.
- ! pair<int> pair1;
-
- // Use a class storing a pair of doubles;
- ! pair<double> pair2;
- --- 1,17 ----
- ! <programlisting id="template_programming-template_use-templated_pair_program" linenumbering="numbered" format="linespecific">
- ! // Declare a template class storing a pair of values with the same type. <co id="template_programming-template_use-templated_pair_program-template_declaration"></co>
- ! template <typename T>
- struct pair {
- ! pair(const T& left, const T& right) // <co id="template_programming-template_use-templated_pair_program-constructor"></co>
- : left_(left), right_(right) {}
-
- ! T left_; // <co id="template_programming-template_use-templated_pair_program-members"></co>
- T right_;
- };
-
- ! // Use a class storing a pair of integers. <co id="template_programming-template_use-templated_pair_program-use"></co>
- ! pair<int> pair1;
-
- // Use a class storing a pair of doubles;
- ! pair<double> pair2;
- ! </programlisting>
--- 0 ----
Index: examples/pairs-untemplated-annotated.patch
===================================================================
RCS file: pairs-untemplated-annotated.patch
diff -N pairs-untemplated-annotated.patch
*** /tmp/cvse4E61E Thu Jan 24 20:22:23 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,35 ****
- *** pairs-untemplated.cpp Wed Dec 26 13:48:10 2001
- --- pairs-untemplated-annotated.cpp Wed Dec 26 14:02:58 2001
- ***************
- *** 1,5 ****
- // Declare a class storing a pair of integers.
- struct pairOfInts {
- ! pairOfInts(const int& left, const int& right)
- : left_(left), right_(right) {}
-
- --- 1,6 ----
- + <programlisting id="template_programming-template_use-untemplated_pair_program" linenumbering="numbered" format="linespecific">
- // Declare a class storing a pair of integers.
- struct pairOfInts {
- ! pairOfInts(const int& left, const int& right)
- : left_(left), right_(right) {}
-
- ***************
- *** 10,14 ****
- // Declare a class storing a pair of doubles.
- struct pairOfDoubles {
- ! pairOfDoubles(const double& left, const double& right)
- : left_(left), right_(right) {}
-
- --- 11,15 ----
- // Declare a class storing a pair of doubles.
- struct pairOfDoubles {
- ! pairOfDoubles(const double& left, const double& right)
- : left_(left), right_(right) {}
-
- ***************
- *** 16,17 ****
- --- 17,19 ----
- double right_;
- };
- + </programlisting>
--- 0 ----
Index: examples/Doof2d/Doof2d-Array-distributed-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Doof2d-Array-distributed-annotated.patch,v
retrieving revision 1.4
diff -c -p -r1.4 Doof2d-Array-distributed-annotated.patch
*** examples/Doof2d/Doof2d-Array-distributed-annotated.patch 2002/01/04 18:00:02 1.4
--- examples/Doof2d/Doof2d-Array-distributed-annotated.patch 2002/01/25 03:22:23
***************
*** 3,15 ****
***************
*** 1,3 ****
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Arrays.h" // has Pooma's Array
--- 1,5 ----
! <programlisting id="tutorial-array_distributed-doof2d-program" linenumbering="numbered" format="linespecific">
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Arrays.h" // has Pooma's Array
***************
*** 14,18 ****
--- 3,15 ----
***************
*** 1,3 ****
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Arrays.h" // has POOMA's Array declarations
--- 1,5 ----
! <programlisting id="tutorial-array_distributed-doof2d-program" linenumbering="numbered" format="linespecific">
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Arrays.h" // has POOMA's Array declarations
***************
*** 14,18 ****
***************
*** 117,124 ****
! GuardLayers<2>(0)); // external
! UniformGridLayout<2> layout(vertDomain, partition, DistributedTag());
! // The template parameters indicate 2 dimensions and a 'double'
! // element type. MultiPatch indicates multiple computation patches,
// i.e., distributed computation. The UniformTag indicates the
! // patches should have the same size. Each patch has Brick type.
! Array<2, double, MultiPatch<UniformTag, Remote<Brick> > > a(layout);
--- 117,124 ----
! GuardLayers<2>(0)); // external
! UniformGridLayout<2> layout(vertDomain, partition, DistributedTag());
! // The Array template parameters indicate 2 dimensions and a 'double'
! // value type. MultiPatch indicates multiple computation patches,
// i.e., distributed computation. The UniformTag indicates the
! // patches should have the same size. Each patch has Brick type.
! Array<2, double, MultiPatch<UniformTag, Remote<Brick> > > a(layout);
***************
*** 134,141 ****
! GuardLayers<2>(0)); // external
! UniformGridLayout<2> layout(vertDomain, partition, DistributedTag());
! // The template parameters indicate 2 dimensions and a 'double'
! // element type. MultiPatch indicates multiple computation patches,
// i.e., distributed computation. The UniformTag indicates the
! // patches should have the same size. Each patch has Brick type. <co id="tutorial-array_distributed-doof2d-remote"></co>
! Array<2, double, MultiPatch<UniformTag, Remote<Brick> > > a(layout);
--- 134,141 ----
! GuardLayers<2>(0)); // external
! UniformGridLayout<2> layout(vertDomain, partition, DistributedTag());
! // The Array template parameters indicate 2 dimensions and a 'double'
! // value type. MultiPatch indicates multiple computation patches,
// i.e., distributed computation. The UniformTag indicates the
! // patches should have the same size. Each patch has Brick type. <co id="tutorial-array_distributed-doof2d-remote"></co>
! Array<2, double, MultiPatch<UniformTag, Remote<Brick> > > a(layout);
Index: examples/Doof2d/Doof2d-Array-element-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Doof2d-Array-element-annotated.patch,v
retrieving revision 1.4
diff -c -p -r1.4 Doof2d-Array-element-annotated.patch
*** examples/Doof2d/Doof2d-Array-element-annotated.patch 2002/01/04 18:00:02 1.4
--- examples/Doof2d/Doof2d-Array-element-annotated.patch 2002/01/25 03:22:23
***************
*** 1,24 ****
*** Doof2d-Array-element.cpp Tue Dec 4 12:02:10 2001
! --- Doof2d-Array-element-annotated.cpp Tue Dec 4 12:24:25 2001
***************
*** 1,5 ****
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! ! #include "Pooma/Arrays.h" // has Pooma's Array
! // Doof2d: Pooma Arrays, element-wise implementation
--- 1,6 ----
! <programlisting id="tutorial-array_elementwise-doof2d-program" linenumbering="numbered" format="linespecific">
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! ! #include "Pooma/Arrays.h" // has Pooma's Array <co id="tutorial-array_elementwise-doof2d-header"></co>
! // Doof2d: Pooma Arrays, element-wise implementation
***************
*** 7,17 ****
int main(int argc, char *argv[])
{
! ! // Prepare the Pooma library for execution.
Pooma::initialize(argc,argv);
// Ask the user for the number of averagings.
--- 1,24 ----
*** Doof2d-Array-element.cpp Tue Dec 4 12:02:10 2001
! --- Doof2d-Array-element-annotated.cpp Wed Jan 23 16:35:29 2002
***************
*** 1,5 ****
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! ! #include "Pooma/Arrays.h" // has POOMA's Array declarations
! // Doof2d: POOMA Arrays, element-wise implementation
--- 1,6 ----
! <programlisting id="tutorial-array_elementwise-doof2d-program" linenumbering="numbered" format="linespecific">
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! ! #include "Pooma/Arrays.h" // has POOMA's Array declarations <co id="tutorial-array_elementwise-doof2d-header"></co>
! // Doof2d: POOMA Arrays, element-wise implementation
***************
*** 7,17 ****
int main(int argc, char *argv[])
{
! ! // Prepare the POOMA library for execution.
Pooma::initialize(argc,argv);
// Ask the user for the number of averagings.
***************
*** 30,36 ****
--- 8,18 ----
int main(int argc, char *argv[])
{
! ! // Prepare the Pooma library for execution. <co id="tutorial-array_elementwise-doof2d-pooma_initialize"></co>
Pooma::initialize(argc,argv);
// Ask the user for the number of averagings.
--- 30,36 ----
--- 8,18 ----
int main(int argc, char *argv[])
{
! ! // Prepare the POOMA library for execution. <co id="tutorial-array_elementwise-doof2d-pooma_initialize"></co>
Pooma::initialize(argc,argv);
// Ask the user for the number of averagings.
***************
*** 51,57 ****
! Interval<2> vertDomain(N, N);
! // Create the arrays.
! // The template parameters indicate 2 dimensions, a 'double' element
// type, and ordinary 'Brick' storage.
! Array<2, double, Brick> a(vertDomain);
! Array<2, double, Brick> b(vertDomain);
--- 51,57 ----
! Interval<2> vertDomain(N, N);
! // Create the arrays.
! // The Array template parameters indicate 2 dimensions, a 'double' value
// type, and ordinary 'Brick' storage.
! Array<2, double, Brick> a(vertDomain);
! Array<2, double, Brick> b(vertDomain);
***************
*** 71,77 ****
! Interval<2> vertDomain(N, N);
! // Create the arrays. <co id="tutorial-array_elementwise-doof2d-array_creation"></co>
! // The template parameters indicate 2 dimensions, a 'double' element
// type, and ordinary 'Brick' storage.
! Array<2, double, Brick> a(vertDomain);
! Array<2, double, Brick> b(vertDomain);
--- 71,77 ----
! Interval<2> vertDomain(N, N);
! // Create the arrays. <co id="tutorial-array_elementwise-doof2d-array_creation"></co>
! // The Array template parameters indicate 2 dimensions, a 'double' value
// type, and ordinary 'Brick' storage.
! Array<2, double, Brick> a(vertDomain);
! Array<2, double, Brick> b(vertDomain);
***************
*** 124,130 ****
! // The arrays are automatically deallocated.
! ! // Tell the Pooma library execution has finished.
Pooma::finalize();
return EXIT_SUCCESS;
}
--- 124,130 ----
! // The arrays are automatically deallocated.
! ! // Tell the POOMA library execution has finished.
Pooma::finalize();
return EXIT_SUCCESS;
}
***************
*** 136,142 ****
! // The arrays are automatically deallocated. <co id="tutorial-array_elementwise-doof2d-deallocation"></co>
! ! // Tell the Pooma library execution has finished. <co id="tutorial-array_elementwise-doof2d-pooma_finish"></co>
Pooma::finalize();
return EXIT_SUCCESS;
}
--- 136,142 ----
! // The arrays are automatically deallocated. <co id="tutorial-array_elementwise-doof2d-deallocation"></co>
! ! // Tell the POOMA library execution has finished. <co id="tutorial-array_elementwise-doof2d-pooma_finish"></co>
Pooma::finalize();
return EXIT_SUCCESS;
}
Index: examples/Doof2d/Doof2d-Array-parallel-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Doof2d-Array-parallel-annotated.patch,v
retrieving revision 1.4
diff -c -p -r1.4 Doof2d-Array-parallel-annotated.patch
*** examples/Doof2d/Doof2d-Array-parallel-annotated.patch 2002/01/04 18:00:02 1.4
--- examples/Doof2d/Doof2d-Array-parallel-annotated.patch 2002/01/25 03:22:23
***************
*** 1,16 ****
*** Doof2d-Array-parallel.cpp Tue Dec 4 11:49:43 2001
! --- Doof2d-Array-parallel-annotated.cpp Tue Dec 4 12:24:36 2001
***************
*** 1,4 ****
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Arrays.h" // has Pooma's Array
--- 1,5 ----
! <programlisting id="tutorial-array_parallel-doof2d-program" linenumbering="numbered" format="linespecific">
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Arrays.h" // has Pooma's Array
***************
*** 12,17 ****
--- 1,16 ----
*** Doof2d-Array-parallel.cpp Tue Dec 4 11:49:43 2001
! --- Doof2d-Array-parallel-annotated.cpp Wed Jan 23 16:35:54 2002
***************
*** 1,4 ****
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Arrays.h" // has POOMA's Array declarations
--- 1,5 ----
! <programlisting id="tutorial-array_parallel-doof2d-program" linenumbering="numbered" format="linespecific">
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Arrays.h" // has POOMA's Array declarations
***************
*** 12,17 ****
***************
*** 43,49 ****
! Interval<1> J(1,n-2);
// Create the arrays.
! // The template parameters indicate 2 dimensions, a 'double' element
// type, and ordinary 'Brick' storage.
! Array<2, double, Brick> a(vertDomain);
! Array<2, double, Brick> b(vertDomain);
--- 43,49 ----
! Interval<1> J(1,n-2);
// Create the arrays.
! // The Array template parameters indicate 2 dimensions, a 'double' value
// type, and ordinary 'Brick' storage.
! Array<2, double, Brick> a(vertDomain);
! Array<2, double, Brick> b(vertDomain);
***************
*** 69,75 ****
! Interval<1> J(1,n-2);
// Create the arrays.
! // The template parameters indicate 2 dimensions, a 'double' element
// type, and ordinary 'Brick' storage.
! Array<2, double, Brick> a(vertDomain);
! Array<2, double, Brick> b(vertDomain);
--- 69,75 ----
! Interval<1> J(1,n-2);
// Create the arrays.
! // The Array template parameters indicate 2 dimensions, a 'double' value
// type, and ordinary 'Brick' storage.
! Array<2, double, Brick> a(vertDomain);
! Array<2, double, Brick> b(vertDomain);
Index: examples/Doof2d/Doof2d-Array-stencil-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Doof2d-Array-stencil-annotated.patch,v
retrieving revision 1.4
diff -c -p -r1.4 Doof2d-Array-stencil-annotated.patch
*** examples/Doof2d/Doof2d-Array-stencil-annotated.patch 2002/01/04 18:00:02 1.4
--- examples/Doof2d/Doof2d-Array-stencil-annotated.patch 2002/01/25 03:22:23
***************
*** 1,12 ****
*** Doof2d-Array-stencil.cpp Tue Dec 4 11:49:39 2001
! --- Doof2d-Array-stencil-annotated.cpp Tue Dec 4 12:26:46 2001
***************
*** 1,9 ****
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Arrays.h" // has Pooma's Array
! // Doof2d: Pooma Arrays, stencil implementation
! // Define the stencil class performing the computation.
class DoofNinePt
--- 1,12 ----
*** Doof2d-Array-stencil.cpp Tue Dec 4 11:49:39 2001
! --- Doof2d-Array-stencil-annotated.cpp Wed Jan 23 16:36:15 2002
***************
*** 1,9 ****
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Arrays.h" // has POOMA's Array declarations
! // Doof2d: POOMA Arrays, stencil implementation
! // Define the stencil class performing the computation.
class DoofNinePt
***************
*** 15,23 ****
! <programlisting id="tutorial-array_stencil-doof2d-program" linenumbering="numbered" format="linespecific">
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Arrays.h" // has Pooma's Array
! // Doof2d: Pooma Arrays, stencil implementation
! // Define the stencil class performing the computation. <co id="tutorial-array_stencil-doof2d-stencil"></co>
class DoofNinePt
--- 15,23 ----
! <programlisting id="tutorial-array_stencil-doof2d-program" linenumbering="numbered" format="linespecific">
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Arrays.h" // has POOMA's Array declarations
! // Doof2d: POOMA Arrays, stencil implementation
! // Define the stencil class performing the computation. <co id="tutorial-array_stencil-doof2d-stencil"></co>
class DoofNinePt
***************
*** 81,87 ****
! Interval<2> interiorDomain(I,I);
// Create the arrays.
! // The template parameters indicate 2 dimensions, a 'double' element
// type, and ordinary 'Brick' storage.
! Array<2, double, Brick> a(vertDomain);
! Array<2, double, Brick> b(vertDomain);
--- 81,87 ----
! Interval<2> interiorDomain(I,I);
// Create the arrays.
! // The Array template parameters indicate 2 dimensions, a 'double' value
// type, and ordinary 'Brick' storage.
! Array<2, double, Brick> a(vertDomain);
! Array<2, double, Brick> b(vertDomain);
***************
*** 102,108 ****
! Interval<2> interiorDomain(I,I);
// Create the arrays.
! // The template parameters indicate 2 dimensions, a 'double' element
// type, and ordinary 'Brick' storage.
! Array<2, double, Brick> a(vertDomain);
! Array<2, double, Brick> b(vertDomain);
--- 102,108 ----
! Interval<2> interiorDomain(I,I);
// Create the arrays.
! // The Array template parameters indicate 2 dimensions, a 'double' value
// type, and ordinary 'Brick' storage.
! Array<2, double, Brick> a(vertDomain);
! Array<2, double, Brick> b(vertDomain);
Index: examples/Doof2d/Doof2d-C-element-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Doof2d-C-element-annotated.patch,v
retrieving revision 1.4
diff -c -p -r1.4 Doof2d-C-element-annotated.patch
*** examples/Doof2d/Doof2d-C-element-annotated.patch 2002/01/04 18:00:02 1.4
--- examples/Doof2d/Doof2d-C-element-annotated.patch 2002/01/25 03:22:23
***************
*** 1,5 ****
! *** Doof2d-C-element.cpp Tue Nov 27 08:36:38 2001
! --- Doof2d-C-element-annotated.cpp Tue Nov 27 12:08:03 2001
***************
*** 1,4 ****
! #include <iostream> // has std::cout, ...
--- 1,5 ----
! *** Doof2d-C-element.cpp Tue Dec 4 09:59:18 2001
! --- Doof2d-C-element-annotated.cpp Wed Jan 23 16:34:20 2002
***************
*** 1,4 ****
! #include <iostream> // has std::cout, ...
***************
*** 26,32 ****
double **a;
double **b;
! // Ask the user for the number n of elements along one dimension of
! // the grid.
long n;
! std::cout << "Please enter the array size: ";
--- 26,32 ----
double **a;
double **b;
! // Ask the user for the number n of values along one dimension of
! // the grid.
long n;
! std::cout << "Please enter the array size: ";
***************
*** 52,58 ****
double **a;
double **b;
! // Ask the user for the number n of elements along one dimension of
! // the grid. <co id="tutorial-hand_coded-doof2d-grid_size"></co>
long n;
! std::cout &openopen; "Please enter the array size: ";
--- 52,58 ----
double **a;
double **b;
! // Ask the user for the number n of values along one dimension of
! // the grid. <co id="tutorial-hand_coded-doof2d-grid_size"></co>
long n;
! std::cout &openopen; "Please enter the array size: ";
Index: examples/Doof2d/Doof2d-Field-distributed-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Doof2d-Field-distributed-annotated.patch,v
retrieving revision 1.3
diff -c -p -r1.3 Doof2d-Field-distributed-annotated.patch
*** examples/Doof2d/Doof2d-Field-distributed-annotated.patch 2002/01/04 18:00:02 1.3
--- examples/Doof2d/Doof2d-Field-distributed-annotated.patch 2002/01/25 03:22:23
***************
*** 1,14 ****
*** Doof2d-Field-distributed.cpp Wed Dec 5 14:05:10 2001
! --- Doof2d-Field-distributed-annotated.cpp Wed Dec 5 14:41:24 2001
***************
*** 1,3 ****
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Fields.h" // has Pooma's Field
--- 1,4 ----
! <programlisting id="tutorial-field_distributed-doof2d-program" linenumbering="numbered" format="linespecific">
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Fields.h" // has Pooma's Field
***************
*** 12,16 ****
--- 1,14 ----
*** Doof2d-Field-distributed.cpp Wed Dec 5 14:05:10 2001
! --- Doof2d-Field-distributed-annotated.cpp Wed Jan 23 16:36:34 2002
***************
*** 1,3 ****
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Fields.h" // has POOMA's Field declarations
--- 1,4 ----
! <programlisting id="tutorial-field_distributed-doof2d-program" linenumbering="numbered" format="linespecific">
! #include <stdlib.h> // has EXIT_SUCCESS
! #include "Pooma/Fields.h" // has POOMA's Field declarations
***************
*** 12,16 ****
***************
*** 108,115 ****
! UniformRectilinearMesh<2> mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
! // The template parameters indicate a mesh and a 'double'
! // element type. MultiPatch indicates multiple computation patches,
// i.e., distributed computation. The UniformTag indicates the
! // patches should have the same size. Each patch has Brick type.
! Field<UniformRectilinearMesh<2>, double, MultiPatch<UniformTag,
--- 108,115 ----
! UniformRectilinearMesh<2> mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
! // The Field template parameters indicate a mesh and a 'double'
! // value type. MultiPatch indicates multiple computation patches,
// i.e., distributed computation. The UniformTag indicates the
! // patches should have the same size. Each patch has Brick type.
! Field<UniformRectilinearMesh<2>, double, MultiPatch<UniformTag,
***************
*** 132,139 ****
! UniformRectilinearMesh<2> mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
! // The template parameters indicate a mesh and a 'double'
! // element type. MultiPatch indicates multiple computation patches,
// i.e., distributed computation. The UniformTag indicates the
! // patches should have the same size. Each patch has Brick type. <co id="tutorial-field_distributed-doof2d-remote"></co>
! Field<UniformRectilinearMesh<2>, double, MultiPatch<UniformTag,
--- 132,139 ----
! UniformRectilinearMesh<2> mesh(layout, Vector<2>(0.0), Vector<2>(1.0, 1.0));
! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
! // The Field template parameters indicate a mesh and a 'double'
! // value type. MultiPatch indicates multiple computation patches,
// i.e., distributed computation. The UniformTag indicates the
! // patches should have the same size. Each patch has Brick type. <co id="tutorial-field_distributed-doof2d-remote"></co>
! Field<UniformRectilinearMesh<2>, double, MultiPatch<UniformTag,
Index: examples/Doof2d/Doof2d-Field-parallel-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Doof2d-Field-parallel-annotated.patch,v
retrieving revision 1.3
diff -c -p -r1.3 Doof2d-Field-parallel-annotated.patch
*** examples/Doof2d/Doof2d-Field-parallel-annotated.patch 2002/01/04 18:00:02 1.3
--- examples/Doof2d/Doof2d-Field-parallel-annotated.patch 2002/01/25 03:22:23
***************
*** 1,19 ****
! *** Doof2d-Field-parallel.cpp Tue Dec 4 10:01:28 2001
! --- Doof2d-Field-parallel-annotated.cpp Tue Dec 4 11:04:26 2001
***************
*** 1,5 ****
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! ! #include "Pooma/Fields.h" // has Pooma's Field
! // Doof2d: Pooma Fields, data-parallel implementation
--- 1,6 ----
! <programlisting id="tutorial-field_parallel-doof2d-program" linenumbering="numbered" format="linespecific">
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! ! #include "Pooma/Fields.h" // has Pooma's Field <co id="tutorial-field_parallel-doof2d-header"></co>
! // Doof2d: Pooma Fields, data-parallel implementation
***************
*** 12,17 ****
// Ask the user for the number of averagings.
--- 1,19 ----
! *** Doof2d-Field-parallel.cpp Tue Dec 4 11:47:58 2001
! --- Doof2d-Field-parallel-annotated.cpp Wed Jan 23 16:37:19 2002
***************
*** 1,5 ****
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! ! #include "Pooma/Fields.h" // has POOMA's Field declarations
! // Doof2d: POOMA Fields, data-parallel implementation
--- 1,6 ----
! <programlisting id="tutorial-field_parallel-doof2d-program" linenumbering="numbered" format="linespecific">
! #include <iostream> // has std::cout, ...
! #include <stdlib.h> // has EXIT_SUCCESS
! ! #include "Pooma/Fields.h" // has POOMA's Field declarations <co id="tutorial-field_parallel-doof2d-header"></co>
! // Doof2d: POOMA Fields, data-parallel implementation
***************
*** 12,17 ****
// Ask the user for the number of averagings.
***************
*** 51,57 ****
! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
// Create the fields.
! // The template parameters indicate a mesh, a 'double' element
! // type, and ordinary 'Brick' storage.
! Field<UniformRectilinearMesh<2>, double, Brick> a(cell, layout, mesh);
! Field<UniformRectilinearMesh<2>, double, Brick> b(cell, layout, mesh);
--- 51,57 ----
! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
// Create the fields.
! // The Field template parameters indicate a mesh, a 'double' value
! // type, and ordinary 'Brick' storage.
! Field<UniformRectilinearMesh<2>, double, Brick> a(cell, layout, mesh);
! Field<UniformRectilinearMesh<2>, double, Brick> b(cell, layout, mesh);
***************
*** 78,98 ****
! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
// Create the fields.
! // The template parameters indicate a mesh, a 'double' element
! // type, and ordinary 'Brick' storage. <co id="tutorial-field_parallel-doof2d-field_creation"></co>
! Field<UniformRectilinearMesh<2>, double, Brick> a(cell, layout, mesh);
! Field<UniformRectilinearMesh<2>, double, Brick> b(cell, layout, mesh);
// Set up the initial conditions.
***************
! *** 51,56 ****
// Perform the simulation.
! for (int k = 0; k < nuIterations; ++k) {
! // Read from b. Write to a.
a(I,J) = weight *
(b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
! --- 52,57 ----
// Perform the simulation.
! for (int k = 0; k < nuIterations; ++k) {
--- 78,98 ----
! Centering<2> cell = canonicalCentering<2>(CellType, Continuous, AllDim);
// Create the fields.
! // The Field template parameters indicate a mesh, a 'double' value
! // type, and ordinary 'Brick' storage. <co id="tutorial-field_parallel-doof2d-field_creation"></co>
! Field<UniformRectilinearMesh<2>, double, Brick> a(cell, layout, mesh);
! Field<UniformRectilinearMesh<2>, double, Brick> b(cell, layout, mesh);
// Set up the initial conditions.
***************
! *** 53,58 ****
// Perform the simulation.
! for (int k = 0; k < nuIterations; ++k) {
! // Read from b. Write to a.
a(I,J) = weight *
(b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
! --- 54,59 ----
// Perform the simulation.
! for (int k = 0; k < nuIterations; ++k) {
***************
*** 100,120 ****
a(I,J) = weight *
(b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
***************
! *** 67,71 ****
// Print out the final central value.
Pooma::blockAndEvaluate(); // Ensure all computation has finished.
! std::cout << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
// The fields are automatically deallocated.
! --- 68,72 ----
// Print out the final central value.
Pooma::blockAndEvaluate(); // Ensure all computation has finished.
! std::cout &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
// The fields are automatically deallocated.
***************
! *** 75,76 ****
! --- 76,78 ----
return EXIT_SUCCESS;
}
+ </programlisting>
--- 100,120 ----
a(I,J) = weight *
(b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
***************
! *** 69,73 ****
// Print out the final central value.
Pooma::blockAndEvaluate(); // Ensure all computation has finished.
! std::cout << (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) << std::endl;
// The fields are automatically deallocated.
! --- 70,74 ----
// Print out the final central value.
Pooma::blockAndEvaluate(); // Ensure all computation has finished.
! std::cout &openopen; (nuAveragings % 2 ? a(n/2,n/2) : b(n/2,n/2)) &openopen; std::endl;
// The fields are automatically deallocated.
***************
! *** 77,78 ****
! --- 78,80 ----
return EXIT_SUCCESS;
}
+ </programlisting>
Index: examples/Sequential/array-copy-annotated.patch
===================================================================
RCS file: array-copy-annotated.patch
diff -N array-copy-annotated.patch
*** /dev/null Fri Mar 23 21:37:44 2001
--- array-copy-annotated.patch Thu Jan 24 20:22:23 2002
***************
*** 0 ****
--- 1,77 ----
+ *** array-copy.cpp Thu Jan 24 11:12:23 2002
+ --- array-copy-annotated.cpp Thu Jan 24 11:12:49 2002
+ ***************
+ *** 1,8 ****
+ #include "Pooma/Pooma.h"
+ #include "Pooma/Arrays.h"
+ ! #include <iostream>
+
+ // Changes the Array value at index (0,0).
+ ! void changeValue(Array<2,int,Brick>& z)
+ { z(0,0) = 6; }
+
+ --- 1,9 ----
+ + <programlisting id="array-copy-program" linenumbering="numbered" format="linespecific">
+ #include "Pooma/Pooma.h"
+ #include "Pooma/Arrays.h"
+ ! #include <iostream>
+
+ // Changes the Array value at index (0,0).
+ ! void changeValue(Array<2,int,Brick>& z)
+ { z(0,0) = 6; }
+
+ ***************
+ *** 11,17 ****
+ Pooma::initialize(argc,argv);
+
+ ! Array<2,int,Brick> a(3,4, ModelElement<int>(4));
+ ! std::cout << "Initial value:\n";
+ ! std::cout << "a: " << a(0,0) << std::endl;
+
+ // Array copies share the same underlying values.
+ --- 12,18 ----
+ Pooma::initialize(argc,argv);
+
+ ! Array<2,int,Brick> a(3,4, ModelElement<int>(4));
+ ! std::cout &openopen; "Initial value:\n";
+ ! std::cout &openopen; "a: " &openopen; a(0,0) &openopen; std::endl;
+
+ // Array copies share the same underlying values.
+ ***************
+ *** 19,35 ****
+ // Explicit initialization uses reference semantics so changing the
+ // copy's value at (0,0) also changes the original's value.
+ ! Array<2,int,Brick> b(a);
+ b(0,0) = 5;
+ ! std::cout << "After explicit initialization.\n";
+ ! std::cout << "a: " << a(0,0) << std::endl;
+ ! std::cout << "b: " << b(0,0) << std::endl;
+
+ // Initialization of function arguments also uses reference semantics.
+ ! std::cout << "After function call:\n";
+ changeValue(a);
+ ! std::cout << "a: " << a(0,0) << std::endl;
+ ! std::cout << "b: " << b(0,0) << std::endl;
+
+ Pooma::finalize();
+ return 0;
+ }
+ --- 20,37 ----
+ // Explicit initialization uses reference semantics so changing the
+ // copy's value at (0,0) also changes the original's value.
+ ! Array<2,int,Brick> b(a);
+ b(0,0) = 5;
+ ! std::cout &openopen; "After explicit initialization.\n";
+ ! std::cout &openopen; "a: " &openopen; a(0,0) &openopen; std::endl;
+ ! std::cout &openopen; "b: " &openopen; b(0,0) &openopen; std::endl;
+
+ // Initialization of function arguments also uses reference semantics.
+ ! std::cout &openopen; "After function call:\n";
+ changeValue(a);
+ ! std::cout &openopen; "a: " &openopen; a(0,0) &openopen; std::endl;
+ ! std::cout &openopen; "b: " &openopen; b(0,0) &openopen; std::endl;
+
+ Pooma::finalize();
+ return 0;
+ }
+ + </programlisting>
Index: examples/Sequential/array-size-annotated.patch
===================================================================
RCS file: array-size-annotated.patch
diff -N array-size-annotated.patch
*** /dev/null Fri Mar 23 21:37:44 2001
--- array-size-annotated.patch Thu Jan 24 20:22:23 2002
***************
*** 0 ****
--- 1,67 ----
+ *** array-size.cpp Tue Jan 15 12:59:40 2002
+ --- array-size-annotated.cpp Tue Jan 15 13:30:07 2002
+ ***************
+ *** 1,5 ****
+ #include "Pooma/Pooma.h"
+ #include "Pooma/Arrays.h"
+ ! #include <iostream>
+
+ // Print an Array's Size
+ --- 1,6 ----
+ + <programlisting id="array-size-program" linenumbering="numbered" format="linespecific">
+ #include "Pooma/Pooma.h"
+ #include "Pooma/Arrays.h"
+ ! #include <iostream>
+
+ // Print an Array's Size
+ ***************
+ *** 10,22 ****
+ // member functions.
+
+ ! template <int Dim, typename Type, typename EngineTag>
+ inline
+ ! long computeArraySize(const Array<Dim,Type,EngineTag>& a)
+ {
+ ! const Loc<Dim> fs = a.firsts();
+ ! const Loc<Dim> ls = a.lasts();
+ ! const Loc<Dim> lens = a.lengths();
+ long size = 1;
+ ! for (int d = 0; d < Dim; ++d) {
+ size *= (ls[d] - fs[d] + 1).first();
+ // Check that lengths() and our computed lengths agree.
+ --- 11,23 ----
+ // member functions.
+
+ ! template <int Dim, typename Type, typename EngineTag>
+ inline
+ ! long computeArraySize(const Array<Dim,Type,EngineTag>& a)
+ {
+ ! const Loc<Dim> fs = a.firsts();
+ ! const Loc<Dim> ls = a.lasts();
+ ! const Loc<Dim> lens = a.lengths();
+ long size = 1;
+ ! for (int d = 0; d < Dim; ++d) {
+ size *= (ls[d] - fs[d] + 1).first();
+ // Check that lengths() and our computed lengths agree.
+ ***************
+ *** 30,38 ****
+ Pooma::initialize(argc,argv);
+
+ ! Array<3,int,Brick> a(3,4,5, ModelElement<int>(4));
+ PAssert(computeArraySize(a) == a.size());
+ ! std::cout << "The array's size is " << a.size() << ".\n";
+
+ Pooma::finalize();
+ return 0;
+ }
+ --- 31,40 ----
+ Pooma::initialize(argc,argv);
+
+ ! Array<3,int,Brick> a(3,4,5, ModelElement<int>(4));
+ PAssert(computeArraySize(a) == a.size());
+ ! std::cout &openopen; "The array's size is " &openopen; a.size() &openopen; ".\n";
+
+ Pooma::finalize();
+ return 0;
+ }
+ + </programlisting>
Index: examples/Sequential/dynamicarray-annotated.patch
===================================================================
RCS file: dynamicarray-annotated.patch
diff -N dynamicarray-annotated.patch
*** /dev/null Fri Mar 23 21:37:44 2001
--- dynamicarray-annotated.patch Thu Jan 24 20:22:23 2002
***************
*** 0 ****
--- 1,80 ----
+ *** dynamicarray.cpp Mon Jan 21 17:29:38 2002
+ --- dynamicarray-annotated.cpp Tue Jan 22 07:06:15 2002
+ ***************
+ *** 1,5 ****
+ #include "Pooma/Pooma.h"
+ ! #include "Pooma/DynamicArrays.h"
+ ! #include <iostream>
+
+ // Demonstrate using DynamicArrays.
+ --- 1,6 ----
+ + <programlisting id="dynamicarray-program" linenumbering="numbered" format="linespecific">
+ #include "Pooma/Pooma.h"
+ ! #include "Pooma/DynamicArrays.h" <co id="arrays-dynamic_arrays-example-header"></co>
+ ! #include <iostream>
+
+ // Demonstrate using DynamicArrays.
+ ***************
+ *** 9,38 ****
+ Pooma::initialize(argc,argv);
+
+ ! // Create a DynamicArray with one element.
+ ! DynamicArray<> d0(1);
+ ! DynamicArray<double> d01(1);
+ ! DynamicArray<double, Dynamic> d02(1);
+
+ ! // Add five more elements.
+ d0.create(5);
+ // Store values in the array.
+ ! for (int i = d0.domain().first(); i <= d0.domain().last(); ++i)
+ ! d0(i) = i;
+
+ ! // Delete every other element.
+ ! d0.destroy(Range<1>(d0.domain().first(),d0.domain().last(),2), BackFill());
+
+ // Print the resulting array.
+ ! std::cout << d0 << std::endl;
+
+ // Use the iterator form of 'destroy.'
+ ! DynamicArray<> d1(6);
+ for (int i = d1.domain().first(); i <= d1.domain().last(); ++i)
+ d1(i) = i;
+ ! int killList[] = { 0, 2, 4 };
+ d1.destroy(killList, killList+3);
+ ! std::cout << d1 << std::endl;
+
+ Pooma::finalize();
+ return 0;
+ }
+ --- 10,40 ----
+ Pooma::initialize(argc,argv);
+
+ ! // Create a DynamicArray with one element. <co id="arrays-dynamic_arrays-example-identical_declarations"></co>
+ ! DynamicArray<> d0(1);
+ ! DynamicArray<double> d01(1);
+ ! DynamicArray<double, Dynamic> d02(1);
+
+ ! // Add five more elements. <co id="arrays-dynamic_arrays-example-extension"></co>
+ d0.create(5);
+ // Store values in the array.
+ ! for (int i = d0.domain().first(); i <= d0.domain().last(); ++i)
+ ! d0(i) = i; <co id="arrays-dynamic_arrays-example-access"></co>
+
+ ! // Delete every other element. <co id="arrays-dynamic_arrays-example-destroy_range"></co>
+ ! d0.destroy(Range<1>(d0.domain().first(),d0.domain().last(),2), BackFill());
+
+ // Print the resulting array.
+ ! std::cout &openopen; d0 &openopen; std::endl;
+
+ // Use the iterator form of 'destroy.'
+ ! DynamicArray<> d1(6);
+ for (int i = d1.domain().first(); i <= d1.domain().last(); ++i)
+ d1(i) = i;
+ ! int killList[] = { 0, 2, 4 }; <co id="arrays-dynamic_arrays-example-destroy_iterators"></co>
+ d1.destroy(killList, killList+3);
+ ! std::cout &openopen; d1 &openopen; std::endl;
+
+ Pooma::finalize();
+ return 0;
+ }
+ + </programlisting>
Index: examples/Sequential/initialize-finalize-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/initialize-finalize-annotated.patch,v
retrieving revision 1.1
diff -c -p -r1.1 initialize-finalize-annotated.patch
*** examples/Sequential/initialize-finalize-annotated.patch 2002/01/04 18:00:02 1.1
--- examples/Sequential/initialize-finalize-annotated.patch 2002/01/25 03:22:23
***************
*** 1,14 ****
! *** initialize-finalize.cpp Sat Dec 15 15:35:57 2001
! --- initialize-finalize-annotated.cpp Sun Dec 16 14:24:43 2001
***************
! *** 1,2 ****
! --- 1,3 ----
+ <programlisting id="initialize-finalize-program" linenumbering="numbered" format="linespecific">
#include "Pooma/Pooma.h"
***************
! *** 10,11 ****
! --- 11,13 ----
return 0;
}
+ </programlisting>
--- 1,20 ----
! *** initialize-finalize.cpp Thu Jan 24 11:14:13 2002
! --- initialize-finalize-annotated.cpp Thu Jan 24 11:14:17 2002
***************
! *** 1,4 ****
! #include "Pooma/Pooma.h"
! ! #include <iostream>
!
! int main(int argc, char *argv[])
! --- 1,5 ----
+ <programlisting id="initialize-finalize-program" linenumbering="numbered" format="linespecific">
#include "Pooma/Pooma.h"
+ ! #include <iostream>
+ int main(int argc, char *argv[])
***************
! *** 11,12 ****
! --- 12,14 ----
return 0;
}
+ </programlisting>
Index: examples/Templates/pairs-templated-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/pairs-templated-annotated.patch,v
retrieving revision 1.1
diff -c -p -r1.1 pairs-templated-annotated.patch
*** examples/Templates/pairs-templated-annotated.patch 2002/01/04 18:00:02 1.1
--- examples/Templates/pairs-templated-annotated.patch 2002/01/25 03:22:23
***************
*** 1,8 ****
! *** pairs-templated.cpp Wed Dec 26 14:01:38 2001
! --- pairs-templated-annotated.cpp Wed Dec 26 14:12:51 2001
***************
*** 1,15 ****
! ! // Declare a template class storing a pair of values with the same type.
! template <typename T>
struct pair {
! pair(const int& left, const int& right)
--- 1,8 ----
! *** pairs-templated.cpp Mon Jan 7 16:11:56 2002
! --- pairs-templated-annotated.cpp Wed Jan 23 12:33:13 2002
***************
*** 1,15 ****
! // Declare a template class storing a pair of values with the same type.
! template <typename T>
struct pair {
! pair(const int& left, const int& right)
***************
*** 12,26 ****
T right_;
};
! ! // Use a class storing a pair of integers.
! pair<int> pair1;
! // Use a class storing a pair of doubles;
! pair<double> pair2;
--- 1,17 ----
! ! <programlisting id="template_programming-template_use-templated_pair_program" linenumbering="numbered" format="linespecific">
! ! // Declare a template class storing a pair of values with the same type. <co id="template_programming-template_use-templated_pair_program-template_declaration"></co>
! ! template <typename T>
struct pair {
! pair(const T& left, const T& right) // <co id="template_programming-template_use-templated_pair_program-constructor"></co>
: left_(left), right_(right) {}
--- 12,26 ----
T right_;
};
! ! // Define a class storing a pair of integers.
! pair<int> pair1;
! ! // Define a class storing a pair of doubles;
! pair<double> pair2;
--- 1,17 ----
! + <programlisting id="template_programming-template_use-templated_pair_program" linenumbering="numbered" format="linespecific">
! // Declare a template class storing a pair of values with the same type.
! ! template <typename T> // <co id="template_programming-template_use-templated_pair_program-template_declaration"></co>
struct pair {
! pair(const T& left, const T& right) // <co id="template_programming-template_use-templated_pair_program-constructor"></co>
: left_(left), right_(right) {}
***************
*** 32,37 ****
! // Use a class storing a pair of integers. <co id="template_programming-template_use-templated_pair_program-use"></co>
! pair<int> pair1;
! // Use a class storing a pair of doubles;
! pair<double> pair2;
! </programlisting>
--- 32,37 ----
! // Use a class storing a pair of integers. <co id="template_programming-template_use-templated_pair_program-use"></co>
! pair<int> pair1;
! ! // Use a class storing a pair of doubles;
! pair<double> pair2;
! </programlisting>
More information about the pooma-dev
mailing list