Manual: Illustrative Programs

Jeffrey oldham at mail.codesourcery.com
Fri Jan 25 03:48:27 UTC 2002


This file hopefully saves all the POOMA programs illustrated in the
POOMA manual.

2002-Jan-24  Jeffrey D. Oldham  <oldham at codesourcery.com>

	* Doof2d/Doof2d-Array-distributed.cpp: Minor comment changes.
	s/element/value/g.  s/Pooma/POOMA/ in comment.
	* Doof2d/Doof2d-Array-element.cpp: Likewise.
	* Doof2d/Doof2d-Array-parallel.cpp: Likewise.
	* Doof2d/Doof2d-Array-stencil.cpp: Likewise.
	* Doof2d/Doof2d-C-element.cpp: Likewise.
	* Doof2d/Doof2d-Field-distributed.cpp: Likewise.
	* Doof2d/Doof2d-Field-parallel.cpp: Likewise.
	* Sequential/array-copy.cpp: New file indicating Array copy
	reference semantics.
	* Sequential/array-size.cpp: New file illustrating use of Array
	member functions.
	* Sequential/data-parallel.cpp: New file illustrating use of data
	parallel expressions.
	* Sequential/dynamicarray.cpp: New file illustrating changing
	domains.
	* Sequential/initialize-finalize.cpp: New file illustrating
	simplest POOMA program.
	* Sequential/makefile: New file.
	* Templates/pairs-templated.cpp: New file demonstrating templated
	class.
	* Templates/pairs-untemplated.cpp: New file with untemplated
	classes.

Applied to	mainline.
Approved by	me.

Thanks,
Jeffrey D. Oldham
oldham at codesourcery.com
-------------- next part --------------
Index: Doof2d/Doof2d-Array-distributed.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/examples/Manual/Doof2d/Doof2d-Array-distributed.cpp,v
retrieving revision 1.2
diff -c -p -r1.2 Doof2d-Array-distributed.cpp
*** Doof2d/Doof2d-Array-distributed.cpp	2001/12/11 19:22:32	1.2
--- Doof2d/Doof2d-Array-distributed.cpp	2002/01/25 03:36:10
***************
*** 1,7 ****
  #include <stdlib.h>		// has EXIT_SUCCESS
! #include "Pooma/Arrays.h"	// has Pooma's Array
  
! // Doof2d: Pooma Arrays, stencil, multiple processor implementation
  
  // Define the stencil class performing the computation.
  class DoofNinePt
--- 1,7 ----
  #include <stdlib.h>		// has EXIT_SUCCESS
! #include "Pooma/Arrays.h"	// has POOMA's Array declarations
  
! // Doof2d: POOMA Arrays, stencil, multiple processor implementation
  
  // Define the stencil class performing the computation.
  class DoofNinePt
*************** private:
*** 35,41 ****
  
  int main(int argc, char *argv[])
  {
!   // Prepare the Pooma library for execution.
    Pooma::initialize(argc,argv);
  
    // Since multiple copies of this program may simultaneously run, we
--- 35,41 ----
  
  int main(int argc, char *argv[])
  {
!   // Prepare the POOMA library for execution.
    Pooma::initialize(argc,argv);
  
    // Since multiple copies of this program may simultaneously run, we
*************** int main(int argc, char *argv[])
*** 61,67 ****
    nuAveragings = strtol(argv[2], &tail, 0);
    nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
  
!   // Ask the user for the number n of elements along one dimension of
    // the grid.
    long n;
    n = strtol(argv[3], &tail, 0);
--- 61,67 ----
    nuAveragings = strtol(argv[2], &tail, 0);
    nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
  
!   // Ask the user for the number n of values along one dimension of
    // the grid.
    long n;
    n = strtol(argv[3], &tail, 0);
*************** int main(int argc, char *argv[])
*** 88,95 ****
  				    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);
--- 88,95 ----
  				    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);
*************** int main(int argc, char *argv[])
*** 120,126 ****
  
    // The arrays are automatically deallocated.
  
!   // Tell the Pooma library execution has finished.
    Pooma::finalize();
    return EXIT_SUCCESS;
  }
--- 120,126 ----
  
    // The arrays are automatically deallocated.
  
!   // Tell the POOMA library execution has finished.
    Pooma::finalize();
    return EXIT_SUCCESS;
  }
Index: Doof2d/Doof2d-Array-element.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/examples/Manual/Doof2d/Doof2d-Array-element.cpp,v
retrieving revision 1.2
diff -c -p -r1.2 Doof2d-Array-element.cpp
*** Doof2d/Doof2d-Array-element.cpp	2001/12/11 19:22:32	1.2
--- Doof2d/Doof2d-Array-element.cpp	2002/01/25 03:36:10
***************
*** 1,12 ****
  #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
  
  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,12 ----
  #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
  
  int main(int argc, char *argv[])
  {
!   // Prepare the POOMA library for execution.
    Pooma::initialize(argc,argv);
    
    // Ask the user for the number of averagings.
*************** int main(int argc, char *argv[])
*** 15,21 ****
    std::cin >> nuAveragings;
    nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
  
!   // Ask the user for the number n of elements along one dimension of
    // the grid.
    long n;
    std::cout << "Please enter the array size: ";
--- 15,21 ----
    std::cin >> nuAveragings;
    nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
  
!   // Ask the user for the number n of values along one dimension of
    // the grid.
    long n;
    std::cout << "Please enter the array size: ";
*************** int main(int argc, char *argv[])
*** 26,32 ****
    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);
--- 26,32 ----
    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);
*************** int main(int argc, char *argv[])
*** 65,71 ****
  
    // The arrays are automatically deallocated.
  
!   // Tell the Pooma library execution has finished.
    Pooma::finalize();
    return EXIT_SUCCESS;
  }
--- 65,71 ----
  
    // The arrays are automatically deallocated.
  
!   // Tell the POOMA library execution has finished.
    Pooma::finalize();
    return EXIT_SUCCESS;
  }
Index: Doof2d/Doof2d-Array-parallel.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/examples/Manual/Doof2d/Doof2d-Array-parallel.cpp,v
retrieving revision 1.2
diff -c -p -r1.2 Doof2d-Array-parallel.cpp
*** Doof2d/Doof2d-Array-parallel.cpp	2001/12/11 19:22:32	1.2
--- Doof2d/Doof2d-Array-parallel.cpp	2002/01/25 03:36:10
***************
*** 1,12 ****
  #include <iostream>		// has std::cout, ...
  #include <stdlib.h>		// has EXIT_SUCCESS
! #include "Pooma/Arrays.h"	// has Pooma's Array
  
! // Doof2d: Pooma Arrays, data-parallel implementation
  
  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,12 ----
  #include <iostream>		// has std::cout, ...
  #include <stdlib.h>		// has EXIT_SUCCESS
! #include "Pooma/Arrays.h"	// has POOMA's Array declarations
  
! // Doof2d: POOMA Arrays, data-parallel implementation
  
  int main(int argc, char *argv[])
  {
!   // Prepare the POOMA library for execution.
    Pooma::initialize(argc,argv);
    
    // Ask the user for the number of averagings.
*************** int main(int argc, char *argv[])
*** 15,21 ****
    std::cin >> nuAveragings;
    nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
  
!   // Ask the user for the number n of elements along one dimension of
    // the grid.
    long n;
    std::cout << "Please enter the array size: ";
--- 15,21 ----
    std::cin >> nuAveragings;
    nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
  
!   // Ask the user for the number n of values along one dimension of
    // the grid.
    long n;
    std::cout << "Please enter the array size: ";
*************** int main(int argc, char *argv[])
*** 30,36 ****
    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);
--- 30,36 ----
    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);
*************** int main(int argc, char *argv[])
*** 66,72 ****
  
    // The arrays are automatically deallocated.
  
!   // Tell the Pooma library execution has finished.
    Pooma::finalize();
    return EXIT_SUCCESS;
  }
--- 66,72 ----
  
    // The arrays are automatically deallocated.
  
!   // Tell the POOMA library execution has finished.
    Pooma::finalize();
    return EXIT_SUCCESS;
  }
Index: Doof2d/Doof2d-Array-stencil.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/examples/Manual/Doof2d/Doof2d-Array-stencil.cpp,v
retrieving revision 1.2
diff -c -p -r1.2 Doof2d-Array-stencil.cpp
*** Doof2d/Doof2d-Array-stencil.cpp	2001/12/11 19:22:32	1.2
--- Doof2d/Doof2d-Array-stencil.cpp	2002/01/25 03:36:10
***************
*** 1,8 ****
  #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,8 ----
  #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
*************** private:
*** 36,42 ****
  
  int main(int argc, char *argv[])
  {
!   // Prepare the Pooma library for execution.
    Pooma::initialize(argc,argv);
    
    // Ask the user for the number of averagings.
--- 36,42 ----
  
  int main(int argc, char *argv[])
  {
!   // Prepare the POOMA library for execution.
    Pooma::initialize(argc,argv);
    
    // Ask the user for the number of averagings.
*************** int main(int argc, char *argv[])
*** 45,51 ****
    std::cin >> nuAveragings;
    nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
  
!   // Ask the user for the number n of elements along one dimension of
    // the grid.
    long n;
    std::cout << "Please enter the array size: ";
--- 45,51 ----
    std::cin >> nuAveragings;
    nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
  
!   // Ask the user for the number n of values along one dimension of
    // the grid.
    long n;
    std::cout << "Please enter the array size: ";
*************** int main(int argc, char *argv[])
*** 60,66 ****
    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);
--- 60,66 ----
    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);
*************** int main(int argc, char *argv[])
*** 90,96 ****
  
    // The arrays are automatically deallocated.
  
!   // Tell the Pooma library execution has finished.
    Pooma::finalize();
    return EXIT_SUCCESS;
  }
--- 90,96 ----
  
    // The arrays are automatically deallocated.
  
!   // Tell the POOMA library execution has finished.
    Pooma::finalize();
    return EXIT_SUCCESS;
  }
Index: Doof2d/Doof2d-C-element.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/examples/Manual/Doof2d/Doof2d-C-element.cpp,v
retrieving revision 1.2
diff -c -p -r1.2 Doof2d-C-element.cpp
*** Doof2d/Doof2d-C-element.cpp	2001/12/11 19:22:32	1.2
--- Doof2d/Doof2d-C-element.cpp	2002/01/25 03:36:10
*************** int main()
*** 15,21 ****
    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: ";
--- 15,21 ----
    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: ";
Index: Doof2d/Doof2d-Field-distributed.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/examples/Manual/Doof2d/Doof2d-Field-distributed.cpp,v
retrieving revision 1.2
diff -c -p -r1.2 Doof2d-Field-distributed.cpp
*** Doof2d/Doof2d-Field-distributed.cpp	2001/12/11 19:22:32	1.2
--- Doof2d/Doof2d-Field-distributed.cpp	2002/01/25 03:36:10
***************
*** 1,11 ****
  #include <stdlib.h>		// has EXIT_SUCCESS
! #include "Pooma/Fields.h"	// has Pooma's Field
  
! // Doof2d: Pooma Fields, data-parallel, multiple processor implementation
  
  int main(int argc, char *argv[])
  {
!   // Prepare the Pooma library for execution.
    Pooma::initialize(argc,argv);
    
    // Since multiple copies of this program may simultaneously run, we
--- 1,11 ----
  #include <stdlib.h>		// has EXIT_SUCCESS
! #include "Pooma/Fields.h"	// has POOMA's Field declarations
  
! // Doof2d: POOMA Fields, data-parallel, multiple processor implementation
  
  int main(int argc, char *argv[])
  {
!   // Prepare the POOMA library for execution.
    Pooma::initialize(argc,argv);
    
    // Since multiple copies of this program may simultaneously run, we
*************** int main(int argc, char *argv[])
*** 31,37 ****
    nuAveragings = strtol(argv[2], &tail, 0);
    nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
  
!   // Ask the user for the number n of elements along one dimension of
    // the grid.
    long n;
    n = strtol(argv[3], &tail, 0);
--- 31,37 ----
    nuAveragings = strtol(argv[2], &tail, 0);
    nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
  
!   // Ask the user for the number n of values along one dimension of
    // the grid.
    long n;
    n = strtol(argv[3], &tail, 0);
*************** int main(int argc, char *argv[])
*** 62,69 ****
    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,
--- 62,69 ----
    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,
*************** int main(int argc, char *argv[])
*** 102,108 ****
  
    // The fields are automatically deallocated.
  
!   // Tell the Pooma library execution has finished.
    Pooma::finalize();
    return EXIT_SUCCESS;
  }
--- 102,108 ----
  
    // The fields are automatically deallocated.
  
!   // Tell the POOMA library execution has finished.
    Pooma::finalize();
    return EXIT_SUCCESS;
  }
Index: Doof2d/Doof2d-Field-parallel.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/examples/Manual/Doof2d/Doof2d-Field-parallel.cpp,v
retrieving revision 1.2
diff -c -p -r1.2 Doof2d-Field-parallel.cpp
*** Doof2d/Doof2d-Field-parallel.cpp	2001/12/11 19:22:32	1.2
--- Doof2d/Doof2d-Field-parallel.cpp	2002/01/25 03:36:10
***************
*** 1,12 ****
  #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
  
  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,12 ----
  #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
  
  int main(int argc, char *argv[])
  {
!   // Prepare the POOMA library for execution.
    Pooma::initialize(argc,argv);
    
    // Ask the user for the number of averagings.
*************** int main(int argc, char *argv[])
*** 15,21 ****
    std::cin >> nuAveragings;
    nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
  
!   // Ask the user for the number n of elements along one dimension of
    // the grid.
    long n;
    std::cout << "Please enter the field size: ";
--- 15,21 ----
    std::cin >> nuAveragings;
    nuIterations = (nuAveragings+1)/2; // Each iteration performs two averagings.
  
!   // Ask the user for the number n of values along one dimension of
    // the grid.
    long n;
    std::cout << "Please enter the field size: ";
*************** int main(int argc, char *argv[])
*** 36,42 ****
    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);
--- 36,42 ----
    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);
*************** int main(int argc, char *argv[])
*** 72,78 ****
  
    // The fields are automatically deallocated.
  
!   // Tell the Pooma library execution has finished.
    Pooma::finalize();
    return EXIT_SUCCESS;
  }
--- 72,78 ----
  
    // The fields are automatically deallocated.
  
!   // Tell the POOMA library execution has finished.
    Pooma::finalize();
    return EXIT_SUCCESS;
  }
Index: Sequential/array-copy.cpp
===================================================================
RCS file: array-copy.cpp
diff -N array-copy.cpp
*** /dev/null	Fri Mar 23 21:37:44 2001
--- array-copy.cpp	Thu Jan 24 20:36:10 2002
***************
*** 0 ****
--- 1,35 ----
+ #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; }
+ 
+ int main(int argc, char *argv[])
+ {
+   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.
+ 
+   // 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;
+ }
Index: Sequential/array-size.cpp
===================================================================
RCS file: array-size.cpp
diff -N array-size.cpp
*** /dev/null	Fri Mar 23 21:37:44 2001
--- array-size.cpp	Thu Jan 24 20:36:10 2002
***************
*** 0 ****
--- 1,38 ----
+ #include "Pooma/Pooma.h"
+ #include "Pooma/Arrays.h"
+ #include <iostream>
+ 
+ // Print an Array's Size
+ 
+ // This program illustrates using the Array member functions.
+ // computeArraySize's computation is redundant because Array's size()
+ // function computes the same value, but it illustrates using Array
+ // 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 *= lens[d].first();
+     // Check that lengths() and our computed lengths agree.
+     PAssert((ls[d] - fs[d] + 1).first() == a.length(d));
+   }
+   return size;
+ }
+ 
+ int main(int argc, char *argv[])
+ {
+   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;
+ }
Index: Sequential/data-parallel.cpp
===================================================================
RCS file: data-parallel.cpp
diff -N data-parallel.cpp
*** /dev/null	Fri Mar 23 21:37:44 2001
--- data-parallel.cpp	Thu Jan 24 20:36:10 2002
***************
*** 0 ****
--- 1,17 ----
+ // Illustrate data-parallel expressions.
+ 
+ #include "Pooma/Arrays.h"
+ 
+ int main(int argc, char *argv[])
+ {
+   Pooma::initialize(argc,argv);
+ 
+   Array<1, double, Brick> A(Interval<1>(0,2));
+   Array<1, double, Brick> B(Interval<1>(1,3));
+   A = 1.0;
+   B = 2.0;
+   std::cout << A-B << std::endl;
+ 
+   Pooma::finalize();
+   return 0;
+ }
Index: Sequential/dynamicarray.cpp
===================================================================
RCS file: dynamicarray.cpp
diff -N dynamicarray.cpp
*** /dev/null	Fri Mar 23 21:37:44 2001
--- dynamicarray.cpp	Thu Jan 24 20:36:10 2002
***************
*** 0 ****
--- 1,38 ----
+ #include "Pooma/Pooma.h"
+ #include "Pooma/DynamicArrays.h"
+ #include <iostream>
+ 
+ // Demonstrate using DynamicArrays.
+ 
+ int main(int argc, char *argv[])
+ {
+   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;
+ }
Index: Sequential/initialize-finalize.cpp
===================================================================
RCS file: initialize-finalize.cpp
diff -N initialize-finalize.cpp
*** /dev/null	Fri Mar 23 21:37:44 2001
--- initialize-finalize.cpp	Thu Jan 24 20:36:10 2002
***************
*** 0 ****
--- 1,12 ----
+ #include "Pooma/Pooma.h"
+ #include <iostream>
+ 
+ int main(int argc, char *argv[])
+ {
+   // Prepare the Pooma library for execution.
+   Pooma::initialize(argc,argv);
+ 
+   // Tell the Pooma library execution has finished.
+   Pooma::finalize();
+   return 0;
+ }
Index: Sequential/makefile
===================================================================
RCS file: makefile
diff -N makefile
*** /dev/null	Fri Mar 23 21:37:44 2001
--- makefile	Thu Jan 24 20:36:10 2002
***************
*** 0 ****
--- 1,80 ----
+ # Generated by mm.pl: Mon Mar  9 13:58:39 MST 1998
+ # ACL:license
+ #  ----------------------------------------------------------------------
+ #  This software and ancillary information (herein called "SOFTWARE")
+ #  called POOMA (Parallel Object-Oriented Methods and Applications) is
+ #  made available under the terms described here.  The SOFTWARE has been
+ #  approved for release with associated LA-CC Number LA-CC-98-65.
+ #  
+ #  Unless otherwise indicated, this SOFTWARE has been authored by an
+ #  employee or employees of the University of California, operator of the
+ #  Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with
+ #  the U.S. Department of Energy.  The U.S. Government has rights to use,
+ #  reproduce, and distribute this SOFTWARE. The public may copy, distribute,
+ #  prepare derivative works and publicly display this SOFTWARE without 
+ #  charge, provided that this Notice and any statement of authorship are 
+ #  reproduced on all copies.  Neither the Government nor the University 
+ #  makes any warranty, express or implied, or assumes any liability or 
+ #  responsibility for the use of this SOFTWARE.
+ #  
+ #  If SOFTWARE is modified to produce derivative works, such modified
+ #  SOFTWARE should be clearly marked, so as not to confuse it with the
+ #  version available from LANL.
+ #  
+ #  For more information about POOMA, send e-mail to pooma at acl.lanl.gov,
+ #  or visit the POOMA web page at http://www.acl.lanl.gov/pooma/.
+ #  ----------------------------------------------------------------------
+ # ACL:license
+ 
+ # This file is user-editable
+ 
+ PROJECT_ROOT = $(shell cd ../../..; pwd)
+ include $(PROJECT_ROOT)/config/head.mk
+ 
+ PASS=APP
+ 
+ default:: array-copy array-size data-parallel dynamicarray initialize-finalize
+ 
+ .PHONY: array-copy
+ 
+ array-copy:: $(ODIR)/array-copy
+ 
+ $(ODIR)/array-copy: $(ODIR)/array-copy.o
+ 	$(LinkToSuite)
+ 
+ .PHONY: array-size
+ 
+ array-size:: $(ODIR)/array-size
+ 
+ $(ODIR)/array-size: $(ODIR)/array-size.o
+ 	$(LinkToSuite)
+ 
+ .PHONY: data-parallel
+ 
+ data-parallel:: $(ODIR)/data-parallel
+ 
+ $(ODIR)/data-parallel: $(ODIR)/data-parallel.o
+ 	$(LinkToSuite)
+ 
+ .PHONY: dynamicarray
+ 
+ dynamicarray:: $(ODIR)/dynamicarray
+ 
+ $(ODIR)/dynamicarray: $(ODIR)/dynamicarray.o
+ 	$(LinkToSuite)
+ 
+ .PHONY: initialize-finalize
+ 
+ initialize-finalize:: $(ODIR)/initialize-finalize
+ 
+ $(ODIR)/initialize-finalize: $(ODIR)/initialize-finalize.o
+ 	$(LinkToSuite)
+ 
+ include $(SHARED_ROOT)/tail.mk
+ 
+ # ACL:rcsinfo
+ #  ----------------------------------------------------------------------
+ #  $RCSfile: makefile,v $   $Author: oldham $
+ #  $Revision: 1.1 $   $Date: 2001/12/04 00:07:00 $
+ #  ----------------------------------------------------------------------
+ # ACL:rcsinfo
Index: Templates/pairs-templated.cpp
===================================================================
RCS file: pairs-templated.cpp
diff -N pairs-templated.cpp
*** /dev/null	Fri Mar 23 21:37:44 2001
--- pairs-templated.cpp	Thu Jan 24 20:36:10 2002
***************
*** 0 ****
--- 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;
Index: Templates/pairs-untemplated.cpp
===================================================================
RCS file: pairs-untemplated.cpp
diff -N pairs-untemplated.cpp
*** /dev/null	Fri Mar 23 21:37:44 2001
--- pairs-untemplated.cpp	Thu Jan 24 20:36:10 2002
***************
*** 0 ****
--- 1,17 ----
+ // Declare a class storing a pair of integers.
+ struct pairOfInts {
+   pairOfInts(const int& left, const int& right)
+     : left_(left), right_(right) {}
+ 
+   int left_;
+   int right_;
+ };
+ 
+ // Declare a class storing a pair of doubles.
+ struct pairOfDoubles {
+   pairOfDoubles(const double& left, const double& right)
+     : left_(left), right_(right) {}
+ 
+   double left_;
+   double right_;
+ };


More information about the pooma-dev mailing list