freepooma-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Merge Array/Reductions.h and Field/FieldReductions.h


From: Richard Guenther
Subject: [PATCH] Merge Array/Reductions.h and Field/FieldReductions.h
Date: Thu, 20 Nov 2003 22:14:03 +0100 (CET)

Hi!

This patch merges the aforementioned files by providing a generic one
in Functions/Reductions.h.  Also generic PerformUpdate is split out of
Field.h and put into Utilities/PerformUpdate.h.  These changes will allow
for reductions over three- and two-arg where(), which is the next patch to
send.

Tested on (hopefully) all relevant tests on serial ppc-linux.

Ok?

Richard.


2003Nov20  Richard Guenther <address@hidden>

        * src/Field/Field.h: split generic
        LeafFunctor<Node, PerformUpdateTag> out ...
        src/Utilities/PerformUpdate.h: ... here (new file).
        src/Array/Reductions.h: remove.
        src/Field/FieldReductions.h: remove.
        src/Functions/Reductions.h: new, merged from Array and
        Field versions.
        src/Array/Array.h: use new include.
        src/Array/tests/array_test1.cpp: likewise.
        src/Array/tests/array_test20.cpp: likewise.
        src/Array/tests/array_test21.cpp: likewise.
        src/Array/tests/array_test26.cpp: likewise.
        src/Array/tests/array_test27.cpp: likewise.
        src/Array/tests/array_test28.cpp: likewise.
        src/Array/tests/array_test6.cpp: likewise.
        src/Array/tests/array_test7.cpp: likewise.
        src/IO/DiskLayout.cmpl.cpp: likewise.
        src/Pooma/Fields.h: likewise.
        src/Evaluator/Reduction.h: perform update on Fields, check
        for single subfield (checks moved from old *Reductions.h).


# This is a BitKeeper generated patch for the following project:
# Project Name: pooma/cheetah repository tracking CVS/tarball
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#                  ChangeSet    1.74    -> 1.75
#       r2/src/Pooma/Fields.h   1.2     -> 1.3
#       r2/src/Evaluator/MultiArgEvaluator.h    1.10    -> 1.11
#       r2/src/Array/tests/array_test6.cpp      1.1     -> 1.2
#       r2/src/Field/FieldReductions.h  1.4     -> 1.6     
r2/src/Functions/Reductions.h (moved)
#       r2/src/Array/tests/array_test21.cpp     1.1     -> 1.2
#       r2/src/Array/tests/array_test7.cpp      1.1     -> 1.2
#       r2/src/Array/Reductions.h       1.4     ->         (deleted)
#       r2/src/Array/tests/array_test28.cpp     1.1     -> 1.2
#       r2/src/Array/Array.h    1.9     -> 1.10
#       r2/src/Array/tests/array_test27.cpp     1.1     -> 1.2
#       r2/src/Evaluator/Reduction.h    1.4     -> 1.5
#       r2/src/Field/Field.h    1.16    -> 1.17
#       r2/src/Array/tests/array_test1.cpp      1.1     -> 1.2
#       r2/src/IO/DiskLayout.cmpl.cpp   1.2     -> 1.3
#       r2/src/Array/tests/array_test26.cpp     1.1     -> 1.2
#       r2/src/Array/tests/array_test20.cpp     1.1     -> 1.2
#                      (new)            -> 1.1     
r2/src/Utilities/PerformUpdate.h
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/11/20      address@hidden(none)    1.75
# Clean up reduction functions and connection to Reduction<>.
# Split out PerformUpdateTag() from Field.h.
# --------------------------------------------
#
diff -Nru a/r2/src/Array/Array.h b/r2/src/Array/Array.h
--- a/r2/src/Array/Array.h      Thu Nov 20 22:02:48 2003
+++ b/r2/src/Array/Array.h      Thu Nov 20 22:02:48 2003
@@ -83,6 +83,7 @@
 #include "Pooma/PETE/ExpressionTraits.h"
 #include "Pooma/View.h"
 #include "Utilities/Conform.h"
+#include "Utilities/PerformUpdate.h"
 #include "Utilities/ElementProperties.h"
 #include "Utilities/ModelElement.h"
 #include "Utilities/NotifyPreRead.h"
@@ -93,7 +94,7 @@
 #include "Array/ArrayOperatorSpecializations.h"
 #include "Array/VectorArrayOperators.h"
 #include "Array/CreateLeaf.h"
-#include "Array/Reductions.h"
+#include "Functions/Reductions.h"

 #include <iosfwd>

diff -Nru a/r2/src/Array/Reductions.h b/r2/src/Array/Reductions.h
--- a/r2/src/Array/Reductions.h Thu Nov 20 22:02:48 2003
+++ /dev/null   Wed Dec 31 16:00:00 1969
@@ -1,156 +0,0 @@
-// -*- C++ -*-
-// ACL:license
-// ----------------------------------------------------------------------
-// This software and ancillary information (herein called "SOFTWARE")
-// called POOMA (Parallel Object-Oriented Methods and Applications) is
-// made available under the terms described here.  The SOFTWARE has been
-// approved for release with associated LA-CC Number LA-CC-98-65.
-//
-// Unless otherwise indicated, this SOFTWARE has been authored by an
-// employee or employees of the University of California, operator of the
-// Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with
-// the U.S. Department of Energy.  The U.S. Government has rights to use,
-// reproduce, and distribute this SOFTWARE. The public may copy, distribute,
-// prepare derivative works and publicly display this SOFTWARE without
-// charge, provided that this Notice and any statement of authorship are
-// reproduced on all copies.  Neither the Government nor the University
-// makes any warranty, express or implied, or assumes any liability or
-// responsibility for the use of this SOFTWARE.
-//
-// If SOFTWARE is modified to produce derivative works, such modified
-// SOFTWARE should be clearly marked, so as not to confuse it with the
-// version available from LANL.
-//
-// For more information about POOMA, send e-mail to address@hidden,
-// or visit the POOMA web page at http://www.acl.lanl.gov/pooma/.
-// ----------------------------------------------------------------------
-// ACL:license
-//-----------------------------------------------------------------------------
-// Functions:
-//   sum             - sum all the elements in an array.
-//   prod            - multiply all of the elements in an array.
-//   max             - find the maximum value in an array.
-//   min             - find the minimum value in an array.
-//   all             - returns true if all of the array's elements are != 0.
-//   any             - returns true if any of the array's elements are != 0.
-//   bitOr           - does a bitwise or of all of the elements.
-//   bitAnd          - does a bitwise and of all of the elements.
-//-----------------------------------------------------------------------------
-
-/** @file
- * @ingroup Array
- * @brief
- * Array reduction functions.
- * These include sum, prod, max, min, all, any, bitOr and bitAnd.
- */
-
-#ifndef POOMA_ARRAY_REDUCTIONS_H
-#define POOMA_ARRAY_REDUCTIONS_H
-
-//-----------------------------------------------------------------------------
-// Includes
-//-----------------------------------------------------------------------------
-
-#include "Evaluator/Reduction.h"
-
-
-//-----------------------------------------------------------------------------
-// Forward definitions
-//-----------------------------------------------------------------------------
-
-template<int Dim, class T, class EngineTag>
-class Array;
-
-
-//-----------------------------------------------------------------------------
-// Specific global reduction functions.
-//-----------------------------------------------------------------------------
-
-/// Sum up the elements of an array.
-
-template<int Dim, class T, class EngineTag>
-T sum(const Array<Dim, T, EngineTag> &a)
-{
-  T ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, OpAddAssign(), a);
-  return ret;
-}
-
-/// Compute the product of the elements of an array.
-
-template<int Dim, class T, class EngineTag>
-T prod(const Array<Dim, T, EngineTag> &a)
-{
-  T ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, OpMultiplyAssign(), a);
-  return ret;
-}
-
-/// Find the smallest element of an array.
-
-template<int Dim, class T, class EngineTag>
-T min(const Array<Dim, T, EngineTag> &a)
-{
-  T ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, FnMinAssign(), a);
-  return ret;
-}
-
-/// Find the largest element of an array.
-
-template<int Dim, class T, class EngineTag>
-T max(const Array<Dim, T, EngineTag> &a)
-{
-  T ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, FnMaxAssign(), a);
-  return ret;
-}
-
-/// Report if all of the elments of the array are true.
-
-template<int Dim, class T, class EngineTag>
-bool all(const Array<Dim, T, EngineTag> &a)
-{
-  bool ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, FnAndAssign(), a);
-  return ret;
-}
-
-/// Report if some of the elments of the array are true.
-
-template<int Dim, class T, class EngineTag>
-bool any(const Array<Dim, T, EngineTag> &a)
-{
-  bool ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, FnOrAssign(), a);
-  return ret;
-}
-
-/// Bitwise-or all of the elements together.
-
-template<int Dim, class T, class EngineTag>
-T bitOr(const Array<Dim, T, EngineTag> &a)
-{
-  T ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, OpBitwiseOrAssign(), a);
-  return ret;
-}
-
-/// Bitwise-and all of the elements together.
-
-template<int Dim, class T, class EngineTag>
-T bitAnd(const Array<Dim, T, EngineTag> &a)
-{
-  T ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, OpBitwiseAndAssign(), a);
-  return ret;
-}
-
-#endif
-
-// ACL:rcsinfo
-// ----------------------------------------------------------------------
-// $RCSfile: Reductions.h,v $   $Author: pooma $
-// $Revision: 1.14 $   $Date: 2003/10/19 12:54:50 $
-// ----------------------------------------------------------------------
-// ACL:rcsinfo
diff -Nru a/r2/src/Array/tests/array_test1.cpp 
b/r2/src/Array/tests/array_test1.cpp
--- a/r2/src/Array/tests/array_test1.cpp        Thu Nov 20 22:02:48 2003
+++ b/r2/src/Array/tests/array_test1.cpp        Thu Nov 20 22:02:48 2003
@@ -43,7 +43,6 @@
 #include "Engine/CompressibleBrick.h"
 #include "Engine/MultiPatchEngine.h"
 #include "Array/Array.h"
-#include "Array/Reductions.h"

 static bool OK = true;

diff -Nru a/r2/src/Array/tests/array_test20.cpp 
b/r2/src/Array/tests/array_test20.cpp
--- a/r2/src/Array/tests/array_test20.cpp       Thu Nov 20 22:02:48 2003
+++ b/r2/src/Array/tests/array_test20.cpp       Thu Nov 20 22:02:48 2003
@@ -38,7 +38,6 @@
 #include "Engine/ConstantFunctionEngine.h"
 #include "Engine/IndexFunctionEngine.h"
 #include "Array/Array.h"
-#include "Array/Reductions.h"
 #include "Tiny/Vector.h"

 #include <iostream>
diff -Nru a/r2/src/Array/tests/array_test21.cpp 
b/r2/src/Array/tests/array_test21.cpp
--- a/r2/src/Array/tests/array_test21.cpp       Thu Nov 20 22:02:48 2003
+++ b/r2/src/Array/tests/array_test21.cpp       Thu Nov 20 22:02:48 2003
@@ -43,7 +43,6 @@
 #include "Engine/CompressibleBrick.h"
 #include "Engine/MultiPatchEngine.h"
 #include "Array/Array.h"
-#include "Array/Reductions.h"


 static bool OK = true;
diff -Nru a/r2/src/Array/tests/array_test26.cpp 
b/r2/src/Array/tests/array_test26.cpp
--- a/r2/src/Array/tests/array_test26.cpp       Thu Nov 20 22:02:48 2003
+++ b/r2/src/Array/tests/array_test26.cpp       Thu Nov 20 22:02:48 2003
@@ -36,7 +36,6 @@
 #include "Utilities/Tester.h"
 #include "Engine/BrickEngine.h"
 #include "Array/Array.h"
-#include "Array/Reductions.h"


 int main(int argc, char *argv[])
diff -Nru a/r2/src/Array/tests/array_test27.cpp 
b/r2/src/Array/tests/array_test27.cpp
--- a/r2/src/Array/tests/array_test27.cpp       Thu Nov 20 22:02:48 2003
+++ b/r2/src/Array/tests/array_test27.cpp       Thu Nov 20 22:02:48 2003
@@ -43,7 +43,6 @@
 #include "Engine/MultiPatchEngine.h"
 #include "Engine/RemoteEngine.h"
 #include "Array/Array.h"
-#include "Array/Reductions.h"


 int main(int argc, char *argv[])
diff -Nru a/r2/src/Array/tests/array_test28.cpp 
b/r2/src/Array/tests/array_test28.cpp
--- a/r2/src/Array/tests/array_test28.cpp       Thu Nov 20 22:02:48 2003
+++ b/r2/src/Array/tests/array_test28.cpp       Thu Nov 20 22:02:48 2003
@@ -42,7 +42,6 @@
 #include "Engine/MultiPatchEngine.h"
 #include "Engine/RemoteEngine.h"
 #include "Array/Array.h"
-#include "Array/Reductions.h"
 #include "Tiny/Vector.h"

 int main(int argc, char *argv[])
diff -Nru a/r2/src/Array/tests/array_test6.cpp 
b/r2/src/Array/tests/array_test6.cpp
--- a/r2/src/Array/tests/array_test6.cpp        Thu Nov 20 22:02:48 2003
+++ b/r2/src/Array/tests/array_test6.cpp        Thu Nov 20 22:02:48 2003
@@ -36,7 +36,6 @@
 #include "Domain/AllDomain.h"
 #include "Engine/BrickEngine.h"
 #include "Array/Array.h"
-#include "Array/Reductions.h"


 int main(int argc, char *argv[])
diff -Nru a/r2/src/Array/tests/array_test7.cpp 
b/r2/src/Array/tests/array_test7.cpp
--- a/r2/src/Array/tests/array_test7.cpp        Thu Nov 20 22:02:48 2003
+++ b/r2/src/Array/tests/array_test7.cpp        Thu Nov 20 22:02:48 2003
@@ -41,7 +41,6 @@
 #include "Engine/CompressibleBrick.h"
 #include "Engine/MultiPatchEngine.h"
 #include "Array/Array.h"
-#include "Array/Reductions.h"


 int main(int argc, char *argv[])
diff -Nru a/r2/src/Evaluator/MultiArgEvaluator.h 
b/r2/src/Evaluator/MultiArgEvaluator.h
--- a/r2/src/Evaluator/MultiArgEvaluator.h      Thu Nov 20 22:02:48 2003
+++ b/r2/src/Evaluator/MultiArgEvaluator.h      Thu Nov 20 22:02:48 2003
@@ -67,7 +67,7 @@
 #include "Evaluator/MultiArgKernel.h"
 #include "Evaluator/SimpleIntersector.h"
 #include "Evaluator/ScalarCodeInfo.h"
-#include "Field/Field.h" // for PerformUpdateTag only
+#include "Utilities/PerformUpdate.h"

 //-----------------------------------------------------------------------------
 // Forward Declarations:
diff -Nru a/r2/src/Evaluator/Reduction.h b/r2/src/Evaluator/Reduction.h
--- a/r2/src/Evaluator/Reduction.h      Thu Nov 20 22:02:48 2003
+++ b/r2/src/Evaluator/Reduction.h      Thu Nov 20 22:02:48 2003
@@ -93,16 +93,35 @@

   ~Reduction() { }

-  //---------------------------------------------------------------------------
-  // Input an expression and cause it to be reduced.
-  // We just pass the buck to a special reduction.
+  /// Helper to check validity of the expression, general version.
+
+  template <class Expr>
+  static inline bool checkValidity(const Expr &e, WrappedInt<false>)
+  {
+    return true;
+  }
+
+  /// Helper to check validity of the expression, version for fields.
+
+  template <class Expr>
+  static inline bool checkValidity(const Expr &e, WrappedInt<true>)
+  {
+    return e.centeringSize() == 1 && e.numMaterials() == 1;
+  }
+
+  /// Input an expression and cause it to be reduced.
+  /// We just pass the buck to a special reduction after updating
+  /// the expression leafs and checking its validity (we can handle
+  /// one subfield only).

   template<class T, class Op, class Expr>
   void evaluate(T &ret, const Op &op, const Expr &e) const
   {
     typedef typename EvaluatorTag1<Expr>::Evaluator_t Evaluator_t;
+    PAssert(checkValidity(e, WrappedInt<Expr::hasRelations>()));
+    forEach(e, PerformUpdateTag(), NullCombine());
     Reduction<Evaluator_t>().evaluate(ret, op, e());
-
+
     POOMA_INCREMENT_STATISTIC(NumReductions)
   }
 };
diff -Nru a/r2/src/Field/Field.h b/r2/src/Field/Field.h
--- a/r2/src/Field/Field.h      Thu Nov 20 22:02:48 2003
+++ b/r2/src/Field/Field.h      Thu Nov 20 22:02:48 2003
@@ -56,6 +56,7 @@
 #include "Pooma/View.h"
 #include "Utilities/PAssert.h"
 #include "Utilities/RefCountedBlockPtr.h"
+#include "Utilities/PerformUpdate.h"

 // NOTE:  The current order of includes puts FieldCreateLeaf after the
 // operators files to work around a bug with template instantiation in KCC.
@@ -1972,7 +1973,6 @@
 // These leaf functor specializations are used to notify a field or expression
 // that it is going to be read and, therefore, needs to update itself.
 //
-// The first LeafFunctor represents default behavior, which is to do nothing.
 // The second handles fields other than those with expression-engines by simply
 // calling applyRelations(). The third passes the tag to the leaves.
 //
@@ -1984,24 +1984,6 @@
 // operate on the engines.
 //
 //-----------------------------------------------------------------------------
-
-struct PerformUpdateTag
-{
-  POOMA_PURIFY_CONSTRUCTORS(PerformUpdateTag)
-};
-
-template<class Node>
-struct LeafFunctor<Node, PerformUpdateTag>
-{
-  typedef int Type_t;
-
-  inline static
-  Type_t apply(const Node &, const PerformUpdateTag &)
-    {
-      return 0;
-    }
-};
-

 template<class Mesh, class T, class EngineTag>
 struct LeafFunctor<Field<Mesh, T, EngineTag>,
diff -Nru a/r2/src/Field/FieldReductions.h b/r2/src/Field/FieldReductions.h
--- a/r2/src/Field/FieldReductions.h    Thu Nov 20 22:02:48 2003
+++ /dev/null   Wed Dec 31 16:00:00 1969
@@ -1,227 +0,0 @@
-// -*- C++ -*-
-// ACL:license
-// ----------------------------------------------------------------------
-// This software and ancillary information (herein called "SOFTWARE")
-// called POOMA (Parallel Object-Oriented Methods and Applications) is
-// made available under the terms described here.  The SOFTWARE has been
-// approved for release with associated LA-CC Number LA-CC-98-65.
-//
-// Unless otherwise indicated, this SOFTWARE has been authored by an
-// employee or employees of the University of California, operator of the
-// Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with
-// the U.S. Department of Energy.  The U.S. Government has rights to use,
-// reproduce, and distribute this SOFTWARE. The public may copy, distribute,
-// prepare derivative works and publicly display this SOFTWARE without
-// charge, provided that this Notice and any statement of authorship are
-// reproduced on all copies.  Neither the Government nor the University
-// makes any warranty, express or implied, or assumes any liability or
-// responsibility for the use of this SOFTWARE.
-//
-// If SOFTWARE is modified to produce derivative works, such modified
-// SOFTWARE should be clearly marked, so as not to confuse it with the
-// version available from LANL.
-//
-// For more information about POOMA, send e-mail to address@hidden,
-// or visit the POOMA web page at http://www.acl.lanl.gov/pooma/.
-// ----------------------------------------------------------------------
-// ACL:license
-//-----------------------------------------------------------------------------
-// Functions:
-//   sum             - sum all the elements in a subfield.
-//   prod            - multiply all of the elements in a subfield.
-//   max             - find the maximum value in a subfield.
-//   min             - find the minimum value in a subfield.
-//   all             - returns true if all of the subfield's elements are != 0.
-//   any             - returns true if any of the subfield's elements are != 0.
-//   bitOr           - does a bitwise or of all of the elements.
-//   bitAnd          - does a bitwise and of all of the elements.
-//-----------------------------------------------------------------------------
-
-/** @file
- * @ingroup Field
- * @brief
- * Field reduction functions.
- */
-
-#ifndef POOMA_FIELD_FIELDREDUCTIONS_H
-#define POOMA_FIELD_FIELDREDUCTIONS_H
-
-//-----------------------------------------------------------------------------
-// Includes
-//-----------------------------------------------------------------------------
-
-#include "Evaluator/Reduction.h"
-
-
-//-----------------------------------------------------------------------------
-// Forward definitions
-//-----------------------------------------------------------------------------
-
-template<class GeometryTag, class T, class EngineTag>
-class Field;
-
-
-//-----------------------------------------------------------------------------
-// Specific global reduction functions for Fields.
-//-----------------------------------------------------------------------------
-
-/// Sum up the elements of a Field.
-
-template<class GeometryTag, class T, class EngineTag>
-T sum(const Field<GeometryTag, T, EngineTag> &f)
-{
-  // These versions only work with fields with one value per cell.
-
-  PAssert(f.numMaterials() <= 1 && f.centering().size() <= 1);
-
-  // We need to notify the field that we are reducing that we are getting
-  // ready to read.
-
-  forEach(f, PerformUpdateTag(), NullCombine());
-
-  T ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, OpAddAssign(), f);
-  return ret;
-}
-
-/// Compute the product of the elements of a Field.
-
-template<class GeometryTag, class T, class EngineTag>
-T prod(const Field<GeometryTag, T, EngineTag> &f)
-{
-  // These versions only work with fields with one value per cell.
-
-  PAssert(f.numMaterials() <= 1 && f.centering().size() <= 1);
-
-  // We need to notify the field that we are reducing that we are getting
-  // ready to read.
-
-  forEach(f, PerformUpdateTag(), NullCombine());
-
-  T ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, OpMultiplyAssign(), f);
-  return ret;
-}
-
-/// Find the smallest element of a Field.
-
-template<class GeometryTag, class T, class EngineTag>
-T min(const Field<GeometryTag, T, EngineTag> &f)
-{
-  // These versions only work with fields with one value per cell.
-
-  PAssert(f.numMaterials() <= 1 && f.centering().size() <= 1);
-
-  // We need to notify the field that we are reducing that we are getting
-  // ready to read.
-
-  forEach(f, PerformUpdateTag(), NullCombine());
-
-  T ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, FnMinAssign(), f);
-  return ret;
-}
-
-/// Find the largest element of a Field.
-
-template<class GeometryTag, class T, class EngineTag>
-T max(const Field<GeometryTag, T, EngineTag> &f)
-{
-  // These versions only work with fields with one value per cell.
-
-  PAssert(f.numMaterials() <= 1 && f.centering().size() <= 1);
-
-  // We need to notify the field that we are reducing that we are getting
-  // ready to read.
-
-  forEach(f, PerformUpdateTag(), NullCombine());
-
-  T ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, FnMaxAssign(), f);
-  return ret;
-}
-
-/// Report if all of the elements of the Field are true.
-
-template<class GeometryTag, class T, class EngineTag>
-bool all(const Field<GeometryTag, T, EngineTag> &f)
-{
-  // These versions only work with fields with one value per cell.
-
-  PAssert(f.numMaterials() <= 1 && f.centering().size() <= 1);
-
-  // We need to notify the field that we are reducing that we are getting
-  // ready to read.
-
-  forEach(f, PerformUpdateTag(), NullCombine());
-
-  bool ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, FnAndAssign(), f);
-  return ret;
-}
-
-/// Report if some of the elements of the Field are true.
-
-template<class GeometryTag, class T, class EngineTag>
-bool any(const Field<GeometryTag, T, EngineTag> &f)
-{
-  // These versions only work with fields with one value per cell.
-
-  PAssert(f.numMaterials() <= 1 && f.centering().size() <= 1);
-
-  // We need to notify the field that we are reducing that we are getting
-  // ready to read.
-
-  forEach(f, PerformUpdateTag(), NullCombine());
-
-  bool ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, FnOrAssign(), f);
-  return ret;
-}
-
-/// Bitwise-or all of the elements together.
-
-template<class GeometryTag, class T, class EngineTag>
-T bitOr(const Field<GeometryTag, T, EngineTag> &f)
-{
-  // These versions only work with fields with one value per cell.
-
-  PAssert(f.numMaterials() <= 1 && f.centering().size() <= 1);
-
-  // We need to notify the field that we are reducing that we are getting
-  // ready to read.
-
-  forEach(f, PerformUpdateTag(), NullCombine());
-
-  T ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, OpBitwiseOrAssign(), f);
-  return ret;
-}
-
-// Bitwise-and all of the elements together.
-
-template<class GeometryTag, class T, class EngineTag>
-T bitAnd(const Field<GeometryTag, T, EngineTag> &f)
-{
-  // These versions only work with fields with one value per cell.
-
-  PAssert(f.numMaterials() <= 1 && f.centering().size() <= 1);
-
-  // We need to notify the field that we are reducing that we are getting
-  // ready to read.
-
-  forEach(f, PerformUpdateTag(), NullCombine());
-
-  T ret;
-  Reduction<MainEvaluatorTag>().evaluate(ret, OpBitwiseAndAssign(), f);
-  return ret;
-}
-
-#endif // POOMA_FIELD_FIELDREDUCTIONS_H
-
-// ACL:rcsinfo
-// ----------------------------------------------------------------------
-// $RCSfile: FieldReductions.h,v $   $Author: pooma $
-// $Revision: 1.2 $   $Date: 2003/10/25 13:31:34 $
-// ----------------------------------------------------------------------
-// ACL:rcsinfo
diff -Nru a/r2/src/Functions/Reductions.h b/r2/src/Functions/Reductions.h
--- /dev/null   Wed Dec 31 16:00:00 1969
+++ b/r2/src/Functions/Reductions.h     Thu Nov 20 22:02:48 2003
@@ -0,0 +1,148 @@
+// -*- C++ -*-
+// ACL:license
+// ----------------------------------------------------------------------
+// This software and ancillary information (herein called "SOFTWARE")
+// called POOMA (Parallel Object-Oriented Methods and Applications) is
+// made available under the terms described here.  The SOFTWARE has been
+// approved for release with associated LA-CC Number LA-CC-98-65.
+//
+// Unless otherwise indicated, this SOFTWARE has been authored by an
+// employee or employees of the University of California, operator of the
+// Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with
+// the U.S. Department of Energy.  The U.S. Government has rights to use,
+// reproduce, and distribute this SOFTWARE. The public may copy, distribute,
+// prepare derivative works and publicly display this SOFTWARE without
+// charge, provided that this Notice and any statement of authorship are
+// reproduced on all copies.  Neither the Government nor the University
+// makes any warranty, express or implied, or assumes any liability or
+// responsibility for the use of this SOFTWARE.
+//
+// If SOFTWARE is modified to produce derivative works, such modified
+// SOFTWARE should be clearly marked, so as not to confuse it with the
+// version available from LANL.
+//
+// For more information about POOMA, send e-mail to address@hidden,
+// or visit the POOMA web page at http://www.acl.lanl.gov/pooma/.
+// ----------------------------------------------------------------------
+// ACL:license
+//-----------------------------------------------------------------------------
+// Functions:
+//   sum             - sum all the elements.
+//   prod            - multiply all of the elements.
+//   max             - find the maximum value.
+//   min             - find the minimum value.
+//   all             - returns true if all of the elements are != 0.
+//   any             - returns true if any of the elements are != 0.
+//   bitOr           - does a bitwise or of all of the elements.
+//   bitAnd          - does a bitwise and of all of the elements.
+//-----------------------------------------------------------------------------
+
+/** @file
+ * @ingroup Functions
+ * @brief
+ * Reduction functions for Fields and Arrays.
+ */
+
+#ifndef POOMA_FUNCTIONS_REDUCTIONS_H
+#define POOMA_FUNCTIONS_REDUCTIONS_H
+
+//-----------------------------------------------------------------------------
+// Includes
+//-----------------------------------------------------------------------------
+
+#include "Evaluator/Reduction.h"
+#include "Utilities/WrappedInt.h"
+
+
+//-----------------------------------------------------------------------------
+// Specific global reduction functions for Fields.
+//-----------------------------------------------------------------------------
+
+/// Sum up the elements.
+
+template<class Subject>
+typename Subject::Element_t sum(const Subject &s)
+{
+  typename Subject::Element_t ret;
+  Reduction<MainEvaluatorTag>().evaluate(ret, OpAddAssign(), s);
+  return ret;
+}
+
+/// Compute the product of the elements.
+
+template<class Subject>
+typename Subject::Element_t prod(const Subject &s)
+{
+  typename Subject::Element_t ret;
+  Reduction<MainEvaluatorTag>().evaluate(ret, OpMultiplyAssign(), s);
+  return ret;
+}
+
+/// Find the smallest element.
+
+template<class Subject>
+typename Subject::Element_t min(const Subject &s)
+{
+  typename Subject::Element_t ret;
+  Reduction<MainEvaluatorTag>().evaluate(ret, FnMinAssign(), s);
+  return ret;
+}
+
+/// Find the largest element.
+
+template<class Subject>
+typename Subject::Element_t max(const Subject &s)
+{
+  typename Subject::Element_t ret;
+  Reduction<MainEvaluatorTag>().evaluate(ret, FnMaxAssign(), s);
+  return ret;
+}
+
+/// Report if all of the elements are true.
+
+template<class Subject>
+bool all(const Subject &s)
+{
+  bool ret;
+  Reduction<MainEvaluatorTag>().evaluate(ret, FnAndAssign(), s);
+  return ret;
+}
+
+/// Report if some of the elements are true.
+
+template<class Subject>
+bool any(const Subject &s)
+{
+  bool ret;
+  Reduction<MainEvaluatorTag>().evaluate(ret, FnOrAssign(), s);
+  return ret;
+}
+
+/// Bitwise-or all of the elements together.
+
+template<class Subject>
+typename Subject::Element_t bitOr(const Subject &s)
+{
+  typename Subject::Element_t ret;
+  Reduction<MainEvaluatorTag>().evaluate(ret, OpBitwiseOrAssign(), s);
+  return ret;
+}
+
+/// Bitwise-and all of the elements together.
+
+template<class Subject>
+typename Subject::Element_t bitAnd(const Subject &s)
+{
+  typename Subject::Element_t ret;
+  Reduction<MainEvaluatorTag>().evaluate(ret, OpBitwiseAndAssign(), s);
+  return ret;
+}
+
+#endif // POOMA_FUNCTIONS_REDUCTIONS_H
+
+// ACL:rcsinfo
+// ----------------------------------------------------------------------
+// $RCSfile: FieldReductions.h,v $   $Author: pooma $
+// $Revision: 1.2 $   $Date: 2003/10/25 13:31:34 $
+// ----------------------------------------------------------------------
+// ACL:rcsinfo
diff -Nru a/r2/src/IO/DiskLayout.cmpl.cpp b/r2/src/IO/DiskLayout.cmpl.cpp
--- a/r2/src/IO/DiskLayout.cmpl.cpp     Thu Nov 20 22:02:48 2003
+++ b/r2/src/IO/DiskLayout.cmpl.cpp     Thu Nov 20 22:02:48 2003
@@ -46,7 +46,6 @@
 // For checkLayout:

 #include "Array/Array.h"
-#include "Array/Reductions.h" // all
 #include "Engine/CompressibleBrick.h"
 #include "Engine/MultiPatchEngine.h"
 #include "Partition/UniformGridPartition.h"
diff -Nru a/r2/src/Pooma/Fields.h b/r2/src/Pooma/Fields.h
--- a/r2/src/Pooma/Fields.h     Thu Nov 20 22:02:48 2003
+++ b/r2/src/Pooma/Fields.h     Thu Nov 20 22:02:48 2003
@@ -71,7 +71,7 @@

 // Other stuff:

-#include "Field/FieldReductions.h"
+#include "Functions/Reductions.h"
 #include "Field/PrintField.h"
 #include "Field/FieldOperatorSpecializations.h"

diff -Nru a/r2/src/Utilities/PerformUpdate.h b/r2/src/Utilities/PerformUpdate.h
--- /dev/null   Wed Dec 31 16:00:00 1969
+++ b/r2/src/Utilities/PerformUpdate.h  Thu Nov 20 22:02:48 2003
@@ -0,0 +1,88 @@
+// -*- C++ -*-
+// ACL:license
+// ----------------------------------------------------------------------
+// This software and ancillary information (herein called "SOFTWARE")
+// called POOMA (Parallel Object-Oriented Methods and Applications) is
+// made available under the terms described here.  The SOFTWARE has been
+// approved for release with associated LA-CC Number LA-CC-98-65.
+//
+// Unless otherwise indicated, this SOFTWARE has been authored by an
+// employee or employees of the University of California, operator of the
+// Los Alamos National Laboratory under Contract No. W-7405-ENG-36 with
+// the U.S. Department of Energy.  The U.S. Government has rights to use,
+// reproduce, and distribute this SOFTWARE. The public may copy, distribute,
+// prepare derivative works and publicly display this SOFTWARE without
+// charge, provided that this Notice and any statement of authorship are
+// reproduced on all copies.  Neither the Government nor the University
+// makes any warranty, express or implied, or assumes any liability or
+// responsibility for the use of this SOFTWARE.
+//
+// If SOFTWARE is modified to produce derivative works, such modified
+// SOFTWARE should be clearly marked, so as not to confuse it with the
+// version available from LANL.
+//
+// For more information about POOMA, send e-mail to address@hidden,
+// or visit the POOMA web page at http://www.acl.lanl.gov/pooma/.
+// ----------------------------------------------------------------------
+// ACL:license
+
+/** @file
+ * @ingroup Utilities
+ * @brief
+ * A tag for updating leafs in an expression.
+ */
+
+#ifndef POOMA_UTILITIES_PERFORMUPDATE_H
+#define POOMA_UTILITIES_PERFORMUPDATE_H
+
+//-----------------------------------------------------------------------------
+// Typedefs:
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+// Includes:
+//-----------------------------------------------------------------------------
+
+//-----------------------------------------------------------------------------
+// Forward Declarations:
+//-----------------------------------------------------------------------------
+
+template<class T, class A> struct LeafFunctor;
+
+/**
+ * These leaf functor specializations are used to notify a field or expression
+ * that it is going to be read and, therefore, needs to update itself.
+ *
+ * The first LeafFunctor represents default behavior, which is to do nothing.
+ *
+ * Fields with engines that store internal fields AND don't copy those
+ * fields' relations to its list must provide a specialization to get the
+ * internal fields to update.
+ *
+ * NOTE: we don't use the ExpressionApply machinery here because this really
+ * operate on the engines.
+ */
+
+struct PerformUpdateTag {};
+
+template<class Node>
+struct LeafFunctor<Node, PerformUpdateTag>
+{
+  typedef int Type_t;
+
+  inline static
+  Type_t apply(const Node &, const PerformUpdateTag &)
+    {
+      return 0;
+    }
+};
+
+
+#endif // POOMA_UTILITIES_PERFORMUPDATE_H
+
+// ACL:rcsinfo
+// ----------------------------------------------------------------------
+// $RCSfile: Conform.h,v $   $Author: pooma $
+// $Revision: 1.4 $   $Date: 2003/10/19 21:35:55 $
+// ----------------------------------------------------------------------
+// ACL:rcsinfo

reply via email to

[Prev in Thread] Current Thread [Next in Thread]