Manual Patch: Tidy Programs
Jeffrey D . Oldham
oldham at codesourcery.com
Thu Jan 31 22:04:17 UTC 2002
2002-Jan-31 Jeffrey D. Oldham <oldham at codesourcery.com>
The changes in this patch
1) Remove duplicates of files.
2) Reformat DocBook output to avoid lines that intrude into the right
margin.
* array-copy-annotated.patch: Remove this file, which should not
have been present.
* array-size-annotated.patch: Likewise.
* dynamicarray-annotated.patch: Likewise.
* examples/array-copy-annotated.patch: Likewise.
* examples/array-size-annotated.patch: Likewise.
* examples/dynamicarray-annotated.patch: Likewise.
* examples/Doof2d/Doof2d-Array-distributed-annotated.patch:
Reformat to avoid long lines.
* 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/Doof2d/array-copy-annotated.patch: Remove this file,
which should not have been present.
* examples/Doof2d/array-size-annotated.patch: Likewise.
* examples/Doof2d/dynamicarray-annotated.patch: Likewise.
* examples/Doof2d/initialize-finalize-annotated.patch: Likewise.
* examples/Doof2d/pairs-templated-annotated.patch: Likewise.
* examples/Sequential/Doof2d-Array-distributed-annotated.patch: Likewise.
* examples/Sequential/Doof2d-Array-element-annotated.patch: Likewise.
* examples/Sequential/Doof2d-Array-parallel-annotated.patch: Likewise.
* examples/Sequential/Doof2d-Array-stencil-annotated.patch: Likewise.
* examples/Sequential/Doof2d-C-element-annotated.patch: Likewise.
* examples/Sequential/Doof2d-Field-distributed-annotated.patch: Likewise.
* examples/Sequential/Doof2d-Field-parallel-annotated.patch: Likewise.
* examples/Sequential/array-copy-annotated.patch: Reformat to
avoid long lines.
* examples/Sequential/array-size-annotated.patch: Likewise.
* examples/Sequential/pairs-templated-annotated.patch: Likewise.
* examples/Sequential/pairs-untemplated-annotated.patch: Likewise.
* examples/Templates/Doof2d-Array-distributed-annotated.patch:
Remove this file, which should not have been present.
* examples/Templates/Doof2d-Array-element-annotated.patch: Likewise.
* examples/Templates/Doof2d-Array-parallel-annotated.patch: Likewise.
* examples/Templates/Doof2d-Array-stencil-annotated.patch: Likewise.
* examples/Templates/Doof2d-C-element-annotated.patch: Likewise.
* examples/Templates/Doof2d-Field-distributed-annotated.patch: Likewise.
* examples/Templates/Doof2d-Field-parallel-annotated.patch: Likewise.
* examples/Templates/array-copy-annotated.patch: Likewise.
* examples/Templates/array-size-annotated.patch: Likewise.
* examples/Templates/dynamicarray-annotated.patch: Likewise.
* examples/Templates/initialize-finalize-annotated.patch: Likewise.
* examples/Templates/pairs-templated-annotated.patch: Move this
file to the Sequential directory.
Applied to mainline.
Thanks,
Jeffrey D. Oldham
oldham at codesourcery.com
-------------- next part --------------
Index: array-copy-annotated.patch
===================================================================
RCS file: array-copy-annotated.patch
diff -N array-copy-annotated.patch
*** /tmp/cvsRJePSY Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: array-size-annotated.patch
===================================================================
RCS file: array-size-annotated.patch
diff -N array-size-annotated.patch
*** /tmp/cvsaVwiqN Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: dynamicarray-annotated.patch
===================================================================
RCS file: dynamicarray-annotated.patch
diff -N dynamicarray-annotated.patch
*** /tmp/cvsrLmG7D Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: examples/array-copy-annotated.patch
===================================================================
RCS file: array-copy-annotated.patch
diff -N array-copy-annotated.patch
*** /tmp/cvsaoaUyu Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: examples/array-size-annotated.patch
===================================================================
RCS file: array-size-annotated.patch
diff -N array-size-annotated.patch
*** /tmp/cvsh5HZIk Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: examples/dynamicarray-annotated.patch
===================================================================
RCS file: dynamicarray-annotated.patch
diff -N dynamicarray-annotated.patch
*** /tmp/cvsilZAQa Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: examples/Doof2d/Doof2d-Array-distributed-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Attic/Doof2d-Array-distributed-annotated.patch,v
retrieving revision 1.7
diff -c -p -r1.7 Doof2d-Array-distributed-annotated.patch
*** examples/Doof2d/Doof2d-Array-distributed-annotated.patch 2002/01/25 03:27:30 1.7
--- examples/Doof2d/Doof2d-Array-distributed-annotated.patch 2002/01/31 21:52:13
***************
*** 1,57 ****
! *** 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 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 ****
! // (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);
--- 1,99 ----
! *** Doof2d-Array-distributed.cpp Mon Jan 28 20:35:07 2002
! --- Doof2d-Array-distributed-annotated.cpp Thu Jan 31 09:12:19 2002
***************
! *** 1,6 ****
! #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.
! --- 1,10 ----
! <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
!
! ! // Doof2d: POOMA Arrays, stencil, multiple
! ! // processor implementation
+ // Define the stencil class performing the computation.
***************
! *** 11,26 ****
! DoofNinePt() : weight(1.0/9.0) {}
!
! ! // 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
! ! operator()(const C& x, int i, int j) const
! ! {
! ! return ( weight *
! ! ( x.read(i+1,j+1) + x.read(i+1,j ) + x.read(i+1,j-1) +
! ! x.read(i ,j+1) + x.read(i ,j ) + x.read(i ,j-1) +
! ! x.read(i-1,j+1) + x.read(i-1,j ) + x.read(i-1,j-1) ) );
! }
!
! --- 15,31 ----
! DoofNinePt() : weight(1.0/9.0) {}
!
! ! // 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
+ ! operator()(const C& x, int i, int j) const {
+ ! return
+ ! weight *
+ ! (x.read(i+1,j+1)+x.read(i+1,j)+x.read(i+1,j-1) +
+ ! x.read(i ,j+1)+x.read(i ,j)+x.read(i ,j-1) +
+ ! x.read(i-1,j+1)+x.read(i-1,j)+x.read(i-1,j-1));
+ }
+
***************
! *** 39,52 ****
! Pooma::initialize(argc,argv);
! ! // Since multiple copies of this program may simultaneously run, we
! ! // cannot 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;
! ! // Read the program input from the command-line arguments.
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;
}
! --- 44,63 ----
! Pooma::initialize(argc,argv);
!
! ! // Since multiple copies of this program may simul-
! ! // taneously run, we cannot 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;
!
! ! // Read the program input from the command-line
! ! // arguments.
if (argc != 4) {
// Incorrect number of command-line arguments.
! ! output &openopen;
! ! argv[0] &openopen;
! ! ": number-of-processors number-of-averagings"
! ! &openopen; " number-of-values"
! ! &openopen; std::endl;
return EXIT_FAILURE;
}
***************
! *** 55,112 ****
// Determine the number of processors.
long nuProcessors;
! nuProcessors = strtol(argv[1], &tail, 0);
***************
*** 59,149 ****
// 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 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);
! 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 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);
- ! 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;
--- 101,148 ----
// Determine the number of averagings.
long nuAveragings, nuIterations;
! 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);
! ! // The dimension must be a multiple of the number of processors
! ! // since we are using a UniformGridLayout.
! ! n = ((n+nuProcessors-1) / nuProcessors) * nuProcessors;
// 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.
! ! // Partition the arrays' domains uniformly, i.e., each patch has the
! ! // same size. The first parameter tells how many patches for each
! ! // 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 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);
! Array<2, double, MultiPatch<UniformTag, Remote<Brick> > > b(layout);
// 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;
// Create the stencil performing the computation.
! Stencil<DoofNinePt> stencil;
***************
*** 152,160 ****
! 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;
--- 151,222 ----
! for (int k = 0; k < nuIterations; ++k) {
! // Read from b. Write to a.
a(interiorDomain) = stencil(b, interiorDomain);
+
+ --- 66,137 ----
+ // 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.
+
+ ! // Ask the user for the number n of values along
+ ! // one dimension of 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.
+ ! n=((n+nuProcessors-1)/nuProcessors)*nuProcessors;
+
+ // 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.
! !
! ! // Partition the arrays' domains uniformly, i.e.,
! ! // each patch has the same size. The first para-
! ! // meter tells how many patches for each 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 Array template parameters indicate 2 dims
! ! // 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);
! ! Array<2, double, MultiPatch<UniformTag,
! ! Remote<Brick> > > b(layout);
+ // 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;
+
// Create the stencil performing the computation.
! Stencil<DoofNinePt> stencil;
***************
*** 164,184 ****
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>
--- 226,251 ----
a(interiorDomain) = stencil(b, interiorDomain);
***************
! *** 116,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.
! --- 141,149 ----
!
// 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 ****
! --- 153,155 ----
return EXIT_SUCCESS;
}
+ </programlisting>
Index: examples/Doof2d/Doof2d-Array-element-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Attic/Doof2d-Array-element-annotated.patch,v
retrieving revision 1.7
diff -c -p -r1.7 Doof2d-Array-element-annotated.patch
*** examples/Doof2d/Doof2d-Array-element-annotated.patch 2002/01/25 03:27:30 1.7
--- examples/Doof2d/Doof2d-Array-element-annotated.patch 2002/01/31 21:52:13
***************
*** 1,5 ****
! *** 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, ...
--- 1,5 ----
! *** Doof2d-Array-element.cpp Wed Jan 23 19:18:17 2002
! --- Doof2d-Array-element-annotated.cpp Thu Jan 31 08:55:57 2002
***************
*** 1,5 ****
! #include <iostream> // has std::cout, ...
***************
*** 7,21 ****
! #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.
--- 7,22 ----
! #include "Pooma/Arrays.h" // has POOMA's Array declarations
// Doof2d: POOMA Arrays, element-wise implementation
! --- 1,7 ----
! <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,37 ****
int main(int argc, char *argv[])
{
! // Prepare the POOMA library for execution.
***************
*** 25,47 ****
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;
--- 26,35 ----
long nuAveragings, nuIterations;
! std::cout << "Please enter the number of averagings: ";
! 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: ";
! std::cin >> n;
***************
*** 49,57 ****
! // Specify the arrays' domains [0,n) x [0,n).
! Interval<1> N(0, n-1);
! 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);
--- 37,45 ----
! // Specify the arrays' domains [0,n) x [0,n).
! Interval<1> N(0, n-1);
! 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);
***************
*** 60,67 ****
! // 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;
--- 48,68 ----
! // 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++)
! --- 9,42 ----
! 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.
!
! ! // Ask the user for the number n of values along
! ! // one dimension of the grid.
long n;
! std::cout &openopen; "Please enter the array size: ";
! std::cin &closeclose; n;
***************
*** 69,83 ****
! // 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 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);
// 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++)
***************
--- 70,86 ----
! // 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 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);
// 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++)
***************
***************
*** 91,97 ****
! 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) {
--- 94,100 ----
! 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) +
! --- 48,56 ----
// Perform the simulation.
! for (int k = 0; k < nuIterations; ++k) {
***************
*** 109,115 ****
! 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++)
--- 112,118 ----
! 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) +
! --- 58,63 ----
// Read from a. Write to b.
! for (int j = 1; j < n-1; j++)
***************
*** 128,142 ****
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;
}
--- 131,148 ----
Pooma::finalize();
return EXIT_SUCCESS;
}
! --- 67,81 ----
// 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 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/Attic/Doof2d-Array-parallel-annotated.patch,v
retrieving revision 1.7
diff -c -p -r1.7 Doof2d-Array-parallel-annotated.patch
*** examples/Doof2d/Doof2d-Array-parallel-annotated.patch 2002/01/25 03:27:30 1.7
--- examples/Doof2d/Doof2d-Array-parallel-annotated.patch 2002/01/31 21:52:13
***************
*** 1,35 ****
! *** 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 ****
// 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;
--- 1,30 ----
! *** Doof2d-Array-parallel.cpp Wed Jan 23 19:18:32 2002
! --- Doof2d-Array-parallel-annotated.cpp Mon Jan 28 20:41:18 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, data-parallel implementation
! --- 1,7 ----
! <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
+ // Doof2d: POOMA Arrays, data-parallel implementation
***************
! *** 12,43 ****
// 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.
! ! // Ask the user for the number n of values along one dimension of
! ! // the grid.
long n;
! std::cout << "Please enter the array size: ";
! std::cin >> n;
***************
*** 43,61 ****
! 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);
// 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;
--- 38,64 ----
! 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);
// 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;
! --- 14,50 ----
! // 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.
!
! ! // Ask the user for the number n of values along one
! ! // dimension of the grid.
long n;
! std::cout &openopen; "Please enter the array size: ";
! std::cin &closeclose; n;
***************
*** 64,83 ****
! 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 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);
// 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;
***************
--- 67,90 ----
! 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 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);
// 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;
***************
***************
*** 88,94 ****
! // 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) {
--- 95,101 ----
! // 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) {
***************
*** 96,116 ****
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>
--- 103,128 ----
a(I,J) = weight *
(b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
***************
! *** 62,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.
! --- 69,77 ----
!
// 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 ****
! --- 81,83 ----
return EXIT_SUCCESS;
}
+ </programlisting>
Index: examples/Doof2d/Doof2d-Array-stencil-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Attic/Doof2d-Array-stencil-annotated.patch,v
retrieving revision 1.7
diff -c -p -r1.7 Doof2d-Array-stencil-annotated.patch
*** examples/Doof2d/Doof2d-Array-stencil-annotated.patch 2002/01/25 03:27:30 1.7
--- examples/Doof2d/Doof2d-Array-stencil-annotated.patch 2002/01/31 21:52:13
***************
*** 1,73 ****
! *** 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
{
! --- 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 declarations
// 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;
--- 1,80 ----
! *** Doof2d-Array-stencil.cpp Wed Jan 23 19:18:49 2002
! --- Doof2d-Array-stencil-annotated.cpp Thu Jan 31 09:11:12 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
{
! --- 1,11 ----
! <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 a stencil class performing computation. <co id="tutorial-array_stencil-doof2d-stencil"></co>
class DoofNinePt
{
***************
! *** 12,30 ****
! DoofNinePt() : weight(1.0/9.0) {}
!
! ! // 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
! ! operator()(const C& c, int i, int j) const
! ! {
! ! return ( weight *
! ! ( c.read(i+1,j+1) + c.read(i+1,j ) + c.read(i+1,j-1) +
! ! c.read(i ,j+1) + c.read(i ,j ) + c.read(i ,j-1) +
! ! c.read(i-1,j+1) + c.read(i-1,j ) + c.read(i-1,j-1) ) );
}
! inline int lowerExtent(int) const { return 1; }
inline int upperExtent(int) const { return 1; }
+
+ --- 14,33 ----
+ DoofNinePt() : weight(1.0/9.0) {}
! ! // 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 & Fields. <co id="tutorial-array_stencil-doof2d-stencil_operator"></co>
! ! template <class C>
! inline
! typename C::Element_t
! ! operator()(const C& c, int i, int j) const {
! ! return
! ! weight *
! ! (c.read(i+1,j+1)+c.read(i+1,j)+c.read(i+1,j-1)+
! ! c.read(i ,j+1)+c.read(i ,j)+c.read(i ,j-1)+
! ! c.read(i-1,j+1)+c.read(i-1,j)+c.read(i-1,j-1));
}
! inline int lowerExtent(int) const { return 1; } <co id="tutorial-array_stencil-doof2d-stencil_extent"></co>
inline int upperExtent(int) const { return 1; }
***************
! *** 42,82 ****
// 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.
! ! // Ask the user for the number n of values along one dimension of
! ! // the grid.
long n;
! std::cout << "Please enter the array size: ";
! std::cin >> n;
***************
*** 76,94 ****
! 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 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);
// Set up the initial conditions.
! --- 50,69 ----
! // the grid.
long n;
! std::cout &openopen; "Please enter the array size: ";
! std::cin &closeclose; n;
--- 83,123 ----
! 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 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);
// 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;
!
! ! // 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);
!
! --- 45,90 ----
! // 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.
!
! ! // Ask the user for the number n of values along one
! ! // dimension of the grid.
long n;
! std::cout &openopen; "Please enter the array size: ";
! std::cin &closeclose; n;
***************
*** 97,129 ****
! 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 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);
// 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.
--- 126,153 ----
! 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 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);
// 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;
! ! // Create a stencil performing the computation. <co id="tutorial-array_stencil-doof2d-stencil_creation"></co>
! Stencil<DoofNinePt> stencil;
// Perform the simulation.
***************
*** 132,152 ****
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>
--- 156,181 ----
a(interiorDomain) = stencil(b, interiorDomain);
***************
! *** 86,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.
! --- 94,102 ----
!
// 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 ****
! --- 106,108 ----
return EXIT_SUCCESS;
}
+ </programlisting>
Index: examples/Doof2d/Doof2d-C-element-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Attic/Doof2d-C-element-annotated.patch,v
retrieving revision 1.7
diff -c -p -r1.7 Doof2d-C-element-annotated.patch
*** examples/Doof2d/Doof2d-C-element-annotated.patch 2002/01/25 03:27:30 1.7
--- examples/Doof2d/Doof2d-C-element-annotated.patch 2002/01/31 21:52:13
***************
*** 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, ...
--- 1,5 ----
! *** Doof2d-C-element.cpp Thu Jan 31 08:46:50 2002
! --- Doof2d-C-element-annotated.cpp Thu Jan 31 08:47:14 2002
***************
*** 1,4 ****
! #include <iostream> // has std::cout, ...
***************
*** 20,32 ****
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 values along one dimension of
! // the grid.
long n;
! std::cout << "Please enter the array size: ";
--- 20,32 ----
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 values along one dimension of
! // the grid.
long n;
! std::cout << "Please enter the array size: ";
***************
*** 39,59 ****
! 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 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: ";
! std::cin &closeclose; n;
--- 39,60 ----
! for (int i = 0; i < n; i++) {
a[i] = new double[n];
b[i] = new double[n];
! --- 7,32 ----
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 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: ";
! std::cin &closeclose; n;
***************
*** 75,81 ****
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.
--- 76,82 ----
a[i][j] = b[i][j] = 0.0;
b[n/2][n/2] = 1000.0;
! ! // Average using this weight.
const double weight = 1.0/9.0;
// Perform the simulation.
***************
*** 85,100 ****
! 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.
--- 86,102 ----
! 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] +
! --- 34,52 ----
// 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;
! ! // Average using this weight. <co id="tutorial-hand_coded-doof2d-constants"></co>
const double weight = 1.0/9.0;
// Perform the simulation.
***************
*** 113,119 ****
! 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>
--- 115,121 ----
! 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,60 ----
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>
***************
*** 132,142 ****
! 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++) {
--- 134,146 ----
! for (int i = 0; i < n; i++) {
delete [] a[i];
delete [] b[i];
! --- 63,73 ----
}
! // 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++) {
***************
*** 144,150 ****
delete [] b[i];
***************
*** 73,74 ****
! --- 74,76 ----
return EXIT_SUCCESS;
}
+ </programlisting>
--- 148,154 ----
delete [] b[i];
***************
*** 73,74 ****
! --- 78,80 ----
return EXIT_SUCCESS;
}
+ </programlisting>
Index: examples/Doof2d/Doof2d-Field-distributed-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Attic/Doof2d-Field-distributed-annotated.patch,v
retrieving revision 1.6
diff -c -p -r1.6 Doof2d-Field-distributed-annotated.patch
*** examples/Doof2d/Doof2d-Field-distributed-annotated.patch 2002/01/25 03:27:30 1.6
--- examples/Doof2d/Doof2d-Field-distributed-annotated.patch 2002/01/31 21:52:13
***************
*** 1,26 ****
! *** 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 ****
! // 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;
***************
--- 1,41 ----
! *** Doof2d-Field-distributed.cpp Wed Jan 23 19:20:15 2002
! --- Doof2d-Field-distributed-annotated.cpp Wed Jan 30 16:40:27 2002
***************
! *** 1,6 ****
! #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[])
! --- 1,9 ----
! <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
!
! ! // Doof2d: POOMA Fields, data-parallel, multiple
! ! // processor implementation
+ int main(int argc, char *argv[])
***************
! *** 9,16 ****
! Pooma::initialize(argc,argv);
!
! ! // Since multiple copies of this program may simultaneously run, we
! ! // 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;
! --- 12,20 ----
! Pooma::initialize(argc,argv);
!
! ! // Since multiple copies of this program may
! ! // simultaneously run, we 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;
***************
***************
*** 30,43 ****
! 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);
--- 45,61 ----
! output << argv[0] << ": number-of-processors number-of-averagings number-of-values" << std::endl;
return EXIT_FAILURE;
}
! --- 22,29 ----
if (argc != 4) {
// Incorrect number of command-line arguments.
! ! output &openopen; argv[0] &openopen;
! ! ": number-of-processors number-of-averagings"
! ! &openopen; " number-of-values"
! ! &openopen; std::endl;
return EXIT_FAILURE;
}
***************
! *** 25,79 ****
// Determine the number of processors.
long nuProcessors;
! nuProcessors = strtol(argv[1], &tail, 0);
***************
*** 45,116 ****
// 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 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,
! Remote<Brick> > > a(cell, layout, mesh);
--- 63,104 ----
// Determine the number of averagings.
long nuAveragings, nuIterations;
! 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);
! ! // The dimension must be a multiple of the number of processors
! ! // since we are using a UniformGridLayout.
! n = ((n+nuProcessors-1) / nuProcessors) * nuProcessors;
// 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
! ! // same size. The first parameter tells how many patches for each
! ! // 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 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,
! Remote<Brick> > > a(cell, layout, mesh);
***************
*** 118,147 ****
! 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 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,
! ! 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 ****
--- 106,185 ----
! Remote<Brick> > > b(cell, layout, mesh);
// 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;
! --- 32,99 ----
! // 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.
!
! ! // Ask the user for the number n of values along
! ! // one dimension of 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.
! n = ((n+nuProcessors-1) / nuProcessors) * nuProcessors;
!
! // 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 same size. The first parameter
+ ! // tells how many patches for each 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 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, Remote<Brick&closecloseclose;
+ ! a(cell, layout, mesh);
+ ! Field<UniformRectilinearMesh<2>, double,
+ ! MultiPatch<UniformTag, Remote<Brick&closecloseclose;
+ ! b(cell, layout, mesh);
+
// 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;
***************
*** 83,87 ****
***************
*** 149,176 ****
! 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>
--- 187,219 ----
! for (int k = 0; k < nuIterations; ++k) {
// Read from b. Write to a.
a(I,J) = weight *
! --- 103,107 ----
// Perform the simulation.
! for (int k = 0; k < nuIterations; ++k) {
// Read from b. Write to a.
a(I,J) = weight *
***************
! *** 98,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.
! --- 118,126 ----
!
// 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 ****
! --- 130,132 ----
return EXIT_SUCCESS;
}
+ </programlisting>
Index: examples/Doof2d/Doof2d-Field-parallel-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Attic/Doof2d-Field-parallel-annotated.patch,v
retrieving revision 1.6
diff -c -p -r1.6 Doof2d-Field-parallel-annotated.patch
*** examples/Doof2d/Doof2d-Field-parallel-annotated.patch 2002/01/25 03:27:30 1.6
--- examples/Doof2d/Doof2d-Field-parallel-annotated.patch 2002/01/31 21:52:13
***************
*** 1,5 ****
! *** 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, ...
--- 1,5 ----
! *** Doof2d-Field-parallel.cpp Wed Jan 23 19:20:33 2002
! --- Doof2d-Field-parallel-annotated.cpp Thu Jan 31 09:07:32 2002
***************
*** 1,5 ****
! #include <iostream> // has std::cout, ...
***************
*** 7,37 ****
! #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.
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;
--- 7,30 ----
! #include "Pooma/Fields.h" // has POOMA's Field declarations
// Doof2d: POOMA Fields, data-parallel implementation
! --- 1,7 ----
! <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,49 ****
// 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.
! ! // Ask the user for the number n of values along one dimension of
! ! // the grid.
long n;
! std::cout << "Please enter the field size: ";
! std::cin >> n;
***************
*** 40,64 ****
! 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 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);
// Set up the initial conditions.
! --- 20,45 ----
! // the grid.
long n;
! std::cout &openopen; "Please enter the field size: ";
! std::cin &closeclose; n;
--- 33,70 ----
! 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 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);
// 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;
! --- 14,60 ----
! // 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.
!
! ! // Ask the user for the number n of values along
! ! // one dimension of the grid.
long n;
! std::cout &openopen; "Please enter the field size: ";
! std::cin &closeclose; n;
***************
*** 67,89 ****
! 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 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 ****
--- 73,108 ----
! 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 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.
+ ! // 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;
***************
*** 53,58 ****
***************
*** 92,98 ****
! // 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) {
--- 111,117 ----
! // Read from b. Write to a.
a(I,J) = weight *
(b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
! --- 64,69 ----
// 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) +
***************
! *** 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>
--- 119,144 ----
a(I,J) = weight *
(b(I+1,J+1) + b(I+1,J ) + b(I+1,J-1) +
***************
! *** 68,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.
! --- 79,87 ----
!
// 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 ****
! --- 91,93 ----
return EXIT_SUCCESS;
}
+ </programlisting>
Index: examples/Doof2d/array-copy-annotated.patch
===================================================================
RCS file: array-copy-annotated.patch
diff -N array-copy-annotated.patch
*** /tmp/cvsqJ3CRs Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: examples/Doof2d/array-size-annotated.patch
===================================================================
RCS file: array-size-annotated.patch
diff -N array-size-annotated.patch
*** /tmp/cvsrt0L1q Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: examples/Doof2d/dynamicarray-annotated.patch
===================================================================
RCS file: dynamicarray-annotated.patch
diff -N dynamicarray-annotated.patch
*** /tmp/cvs0gWRWo Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: examples/Doof2d/initialize-finalize-annotated.patch
===================================================================
RCS file: initialize-finalize-annotated.patch
diff -N initialize-finalize-annotated.patch
*** /tmp/cvsxFjk1o Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: examples/Doof2d/pairs-templated-annotated.patch
===================================================================
RCS file: pairs-templated-annotated.patch
diff -N pairs-templated-annotated.patch
*** /tmp/cvsq1PS0o Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,37 ****
- *** 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)
- : left_(left), right_(right) {}
-
- ! T left_;
- 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) {}
-
- ! 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/Sequential/Doof2d-Array-distributed-annotated.patch
===================================================================
RCS file: Doof2d-Array-distributed-annotated.patch
diff -N Doof2d-Array-distributed-annotated.patch
*** /tmp/cvs5nG7Ho Thu Jan 31 14:52:13 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 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 ****
- // (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 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);
- ! 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 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);
- ! 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/Sequential/Doof2d-Array-element-annotated.patch
===================================================================
RCS file: Doof2d-Array-element-annotated.patch
diff -N Doof2d-Array-element-annotated.patch
*** /tmp/cvsyWNCZn Thu Jan 31 14:52:13 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 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.
- 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 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);
-
- // 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 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);
-
- // 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/Sequential/Doof2d-Array-parallel-annotated.patch
===================================================================
RCS file: Doof2d-Array-parallel-annotated.patch
diff -N Doof2d-Array-parallel-annotated.patch
*** /tmp/cvsV9LpYm Thu Jan 31 14:52:13 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 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 ****
- // 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 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);
-
- // 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 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);
-
- // 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/Sequential/Doof2d-Array-stencil-annotated.patch
===================================================================
RCS file: Doof2d-Array-stencil-annotated.patch
diff -N Doof2d-Array-stencil-annotated.patch
*** /tmp/cvscMIWSn Thu Jan 31 14:52:13 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 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
- {
- --- 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 declarations
-
- // 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 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);
-
- // 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 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);
-
- // 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/Sequential/Doof2d-C-element-annotated.patch
===================================================================
RCS file: Doof2d-C-element-annotated.patch
diff -N Doof2d-C-element-annotated.patch
*** /tmp/cvsfhxNpo Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,150 ****
- *** 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, ...
- ! #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 values 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 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: ";
- ! 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/Sequential/Doof2d-Field-distributed-annotated.patch
===================================================================
RCS file: Doof2d-Field-distributed-annotated.patch
diff -N Doof2d-Field-distributed-annotated.patch
*** /tmp/cvsCgy7wo Thu Jan 31 14:52:13 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 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 ****
- // 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 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,
- ! 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 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,
- ! 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/Sequential/Doof2d-Field-parallel-annotated.patch
===================================================================
RCS file: Doof2d-Field-parallel-annotated.patch
diff -N Doof2d-Field-parallel-annotated.patch
*** /tmp/cvsLMrrLq Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,120 ****
- *** 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.
- 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 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);
-
- // 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 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) {
- ! // 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) +
- ***************
- *** 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>
--- 0 ----
Index: examples/Sequential/array-copy-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/array-copy-annotated.patch,v
retrieving revision 1.1
diff -c -p -r1.1 array-copy-annotated.patch
*** examples/Sequential/array-copy-annotated.patch 2002/01/25 03:27:30 1.1
--- examples/Sequential/array-copy-annotated.patch 2002/01/31 21:52:13
***************
*** 1,5 ****
*** 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"
--- 1,5 ----
*** array-copy.cpp Thu Jan 24 11:12:23 2002
! --- array-copy-annotated.cpp Thu Jan 31 09:22:57 2002
***************
*** 1,8 ****
#include "Pooma/Pooma.h"
***************
*** 21,27 ****
{ z(0,0) = 6; }
***************
! *** 11,17 ****
Pooma::initialize(argc,argv);
! Array<2,int,Brick> a(3,4, ModelElement<int>(4));
--- 21,27 ----
{ z(0,0) = 6; }
***************
! *** 11,35 ****
Pooma::initialize(argc,argv);
! Array<2,int,Brick> a(3,4, ModelElement<int>(4));
***************
*** 29,53 ****
! 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;
--- 29,44 ----
! 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;
***************
*** 56,71 ****
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;
--- 47,72 ----
Pooma::finalize();
return 0;
}
! --- 12,39 ----
! 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.
!
! ! // 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;
Index: examples/Sequential/array-size-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/array-size-annotated.patch,v
retrieving revision 1.1
diff -c -p -r1.1 array-size-annotated.patch
*** examples/Sequential/array-size-annotated.patch 2002/01/25 03:27:30 1.1
--- examples/Sequential/array-size-annotated.patch 2002/01/31 21:52:13
***************
*** 1,21 ****
! *** 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>
--- 1,16 ----
! *** array-size.cpp Tue Jan 15 13:30:53 2002
! --- array-size-annotated.cpp Thu Jan 31 09:24:16 2002
***************
! *** 1,25 ****
#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>
***************
*** 27,65 ****
! 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;
--- 22,78 ----
! 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;
! --- 1,27 ----
! + <programlisting id="array-size-program" linenumbering="numbered" format="linespecific">
! #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> <co id="arrays-arrays_use-members-example-template_parameters"></co>
inline
! long computeArraySize(const Array<Dim,Type,EngineTag>& a)
{
! ! const Loc<Dim> fs = a.firsts(); <co id="arrays-arrays_use-members-example-function_call"></co>
! 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(); <co id="arrays-arrays_use-members-example-loc_use"></co>
// Check that lengths() and our computed lengths agree.
+ ! PAssert((ls[d]-fs[d]+1).first()==a.length(d)); <co id="arrays-arrays_use-members-example-check_length"></co>
+ }
+ return size;
***************
*** 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;
}
! --- 32,42 ----
Pooma::initialize(argc,argv);
! Array<3,int,Brick> a(3,4,5, ModelElement<int>(4));
! ! PAssert(computeArraySize(a) == a.size()); <co id="arrays-arrays_use-members-example-compare_size"></co>
! ! std::cout &openopen;
! ! "The array's size is " &openopen; a.size() &openopen; ".\n";
Pooma::finalize();
return 0;
Index: examples/Sequential/pairs-templated-annotated.patch
===================================================================
RCS file: /home/pooma/Repository/r2/docs/manual/programs/Attic/pairs-templated-annotated.patch,v
retrieving revision 1.4
diff -c -p -r1.4 pairs-templated-annotated.patch
*** examples/Sequential/pairs-templated-annotated.patch 2002/01/25 03:27:30 1.4
--- examples/Sequential/pairs-templated-annotated.patch 2002/01/31 21:52:13
***************
*** 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)
--- 1,8 ----
*** pairs-templated.cpp Mon Jan 7 16:11:56 2002
! --- pairs-templated-annotated.cpp Thu Jan 31 08:44:35 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)
***************
*** 17,25 ****
! // 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>
--- 17,26 ----
! // Define a class storing a pair of doubles;
! pair<double> pair2;
! --- 1,18 ----
! ! <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>
Index: examples/Sequential/pairs-untemplated-annotated.patch
===================================================================
RCS file: pairs-untemplated-annotated.patch
diff -N pairs-untemplated-annotated.patch
*** /dev/null Fri Mar 23 21:37:44 2001
--- pairs-untemplated-annotated.patch Thu Jan 31 14:52:13 2002
***************
*** 0 ****
--- 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>
Index: examples/Templates/Doof2d-Array-distributed-annotated.patch
===================================================================
RCS file: Doof2d-Array-distributed-annotated.patch
diff -N Doof2d-Array-distributed-annotated.patch
*** /tmp/cvsXqyFoA Thu Jan 31 14:52:13 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 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 ****
- // (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 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);
- ! 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 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);
- ! 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/Templates/Doof2d-Array-element-annotated.patch
===================================================================
RCS file: Doof2d-Array-element-annotated.patch
diff -N Doof2d-Array-element-annotated.patch
*** /tmp/cvsu9r3UC Thu Jan 31 14:52:13 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 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.
- 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 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);
-
- // 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 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);
-
- // 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/Templates/Doof2d-Array-parallel-annotated.patch
===================================================================
RCS file: Doof2d-Array-parallel-annotated.patch
diff -N Doof2d-Array-parallel-annotated.patch
*** /tmp/cvs9dVaoH Thu Jan 31 14:52:13 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 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 ****
- // 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 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);
-
- // 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 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);
-
- // 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/Templates/Doof2d-Array-stencil-annotated.patch
===================================================================
RCS file: Doof2d-Array-stencil-annotated.patch
diff -N Doof2d-Array-stencil-annotated.patch
*** /tmp/cvsasNZwL Thu Jan 31 14:52:13 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 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
- {
- --- 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 declarations
-
- // 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 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);
-
- // 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 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);
-
- // 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/Templates/Doof2d-C-element-annotated.patch
===================================================================
RCS file: Doof2d-C-element-annotated.patch
diff -N Doof2d-C-element-annotated.patch
*** /tmp/cvsT2P9dR Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,150 ****
- *** 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, ...
- ! #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 values 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 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: ";
- ! 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/Templates/Doof2d-Field-distributed-annotated.patch
===================================================================
RCS file: Doof2d-Field-distributed-annotated.patch
diff -N Doof2d-Field-distributed-annotated.patch
*** /tmp/cvsAOUbGW Thu Jan 31 14:52:13 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 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 ****
- // 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 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,
- ! 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 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,
- ! 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/Templates/Doof2d-Field-parallel-annotated.patch
===================================================================
RCS file: Doof2d-Field-parallel-annotated.patch
diff -N Doof2d-Field-parallel-annotated.patch
*** /tmp/cvsJmrxJ1 Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,120 ****
- *** 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.
- 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 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);
-
- // 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 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) {
- ! // 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) +
- ***************
- *** 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>
--- 0 ----
Index: examples/Templates/array-copy-annotated.patch
===================================================================
RCS file: array-copy-annotated.patch
diff -N array-copy-annotated.patch
*** /tmp/cvsmquTO8 Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: examples/Templates/array-size-annotated.patch
===================================================================
RCS file: array-size-annotated.patch
diff -N array-size-annotated.patch
*** /tmp/cvs3lu4Nf Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: examples/Templates/dynamicarray-annotated.patch
===================================================================
RCS file: dynamicarray-annotated.patch
diff -N dynamicarray-annotated.patch
*** /tmp/cvskK1Xwm Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: examples/Templates/initialize-finalize-annotated.patch
===================================================================
RCS file: initialize-finalize-annotated.patch
diff -N initialize-finalize-annotated.patch
*** /tmp/cvs9Bbo4s Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 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>
--- 0 ----
Index: examples/Templates/pairs-templated-annotated.patch
===================================================================
RCS file: pairs-templated-annotated.patch
diff -N pairs-templated-annotated.patch
*** /tmp/cvsAVPLxz Thu Jan 31 14:52:13 2002
--- /dev/null Fri Mar 23 21:37:44 2001
***************
*** 1,37 ****
- *** 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)
- : left_(left), right_(right) {}
-
- ! T left_;
- 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) {}
-
- ! 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 ----
More information about the pooma-dev
mailing list