[newfield_revision Patch] Rename Reduction Function Names
Jeffrey Oldham
oldham at codesourcery.com
Fri Aug 10 17:40:14 UTC 2001
This patch mixes two concepts:
1) Adding two comments explaining
a) how to use data-parallel FieldOffsets
b) an idea how to revise FieldOffsets
2) Renaming reduction functions so those using FieldOffsetLists and
those reducing an entire subfield have the same name.
2001-08-10 Jeffrey D. Oldham <oldham at codesourcery.com>
* FieldOffset.h: Add a FIXME comment listing an idea for revising
the FieldOffset.
(av): New function renamed from average().
(min): New function renamed from minimum().
(max): New function renamed from maximum().
* tests/FieldOffset.cpp: Add a comment how to use data parallel
statements.
* tests/FieldReductions.cpp (checkFieldPosition): Revise functions
names per FieldOffset.h change.
Tested on sequential Linux using gcc 3.0.1 by compiling Pooma library and
+NewField tests
Approved by Stephen Smith
Applied to newfield_revision branch
Thanks,
Jeffrey D. Oldham
oldham at codesourcery.com
-------------- next part --------------
Index: FieldOffset.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/NewField/Attic/FieldOffset.h,v
retrieving revision 1.1.2.2
diff -c -p -r1.1.2.2 FieldOffset.h
*** FieldOffset.h 2001/08/02 22:36:56 1.1.2.2
--- FieldOffset.h 2001/08/09 23:13:04
***************
*** 33,41 ****
// Functions:
// accumulate
// sum
! // average
! // minimum
! // maximum
//-----------------------------------------------------------------------------
#ifndef POOMA_NEWFIELD_OFFSET_H
--- 33,41 ----
// Functions:
// accumulate
// sum
! // av
! // min
! // max
//-----------------------------------------------------------------------------
#ifndef POOMA_NEWFIELD_OFFSET_H
***************
*** 52,57 ****
--- 52,63 ----
// - computations using the entries in a FieldOffsetList
//-----------------------------------------------------------------------------
+ // FIXME: Perhaps we wish to store pointers to input and output
+ // FIXME: centerings in a FieldOffset. Storing the input centering
+ // FIXME: will permit assertion checking when a FieldOffset is used to
+ // FIXME: reference a field. The stored output centering is used in
+ // FIXME: data-parallel uses.
+
//-----------------------------------------------------------------------------
// Includes:
//-----------------------------------------------------------------------------
*************** class FieldOffsetList;
*** 114,124 ****
// accumulate: Sequentially applies the given binary function to all
// field offsets in the list.
// sum: Adds the values indicated by the field offset list.
! // average: Averages the values indicated by the field offset
// list. Note the division is computed using the element
// type, e.g., integral or floating point division.
! // minimum: Returns the smallest of the indicated values.
! // maximum: Returns the largest of the indicated values.
//
//-----------------------------------------------------------------------------
--- 120,130 ----
// accumulate: Sequentially applies the given binary function to all
// field offsets in the list.
// sum: Adds the values indicated by the field offset list.
! // av: Averages the values indicated by the field offset
// list. Note the division is computed using the element
// type, e.g., integral or floating point division.
! // min: Returns the smallest of the indicated values.
! // max: Returns the largest of the indicated values.
//
//-----------------------------------------------------------------------------
*************** sum(const Field<GeometryTag, T, Expr>& f
*** 372,380 ****
template<class GeometryTag, class T, class Expr, int Dim>
inline
typename Field<GeometryTag, T, Expr>::T_t
! average(const Field<GeometryTag, T, Expr>& field,
! const FieldOffsetList<Dim> &lst,
! const Loc<Dim> &loc)
{
typedef typename Field<GeometryTag, T, Expr>::T_t T_t;
CTAssert((Field<GeometryTag, T, Expr>::dimensions == Dim));
--- 378,386 ----
template<class GeometryTag, class T, class Expr, int Dim>
inline
typename Field<GeometryTag, T, Expr>::T_t
! av(const Field<GeometryTag, T, Expr>& field,
! const FieldOffsetList<Dim> &lst,
! const Loc<Dim> &loc)
{
typedef typename Field<GeometryTag, T, Expr>::T_t T_t;
CTAssert((Field<GeometryTag, T, Expr>::dimensions == Dim));
*************** struct fomin : public std::binary_functi
*** 395,403 ****
template<class GeometryTag, class T, class Expr, int Dim>
inline
typename Field<GeometryTag, T, Expr>::T_t
! minimum(const Field<GeometryTag, T, Expr>& field,
! const FieldOffsetList<Dim> &lst,
! const Loc<Dim> &loc)
{
typedef typename Field<GeometryTag, T, Expr>::T_t T_t;
CTAssert((Field<GeometryTag, T, Expr>::dimensions == Dim));
--- 401,409 ----
template<class GeometryTag, class T, class Expr, int Dim>
inline
typename Field<GeometryTag, T, Expr>::T_t
! min(const Field<GeometryTag, T, Expr>& field,
! const FieldOffsetList<Dim> &lst,
! const Loc<Dim> &loc)
{
typedef typename Field<GeometryTag, T, Expr>::T_t T_t;
CTAssert((Field<GeometryTag, T, Expr>::dimensions == Dim));
*************** struct fomax : public std::binary_functi
*** 418,426 ****
template<class GeometryTag, class T, class Expr, int Dim>
inline
typename Field<GeometryTag, T, Expr>::T_t
! maximum(const Field<GeometryTag, T, Expr>& field,
! const FieldOffsetList<Dim> &lst,
! const Loc<Dim> &loc)
{
typedef typename Field<GeometryTag, T, Expr>::T_t T_t;
CTAssert((Field<GeometryTag, T, Expr>::dimensions == Dim));
--- 424,432 ----
template<class GeometryTag, class T, class Expr, int Dim>
inline
typename Field<GeometryTag, T, Expr>::T_t
! max(const Field<GeometryTag, T, Expr>& field,
! const FieldOffsetList<Dim> &lst,
! const Loc<Dim> &loc)
{
typedef typename Field<GeometryTag, T, Expr>::T_t T_t;
CTAssert((Field<GeometryTag, T, Expr>::dimensions == Dim));
Index: tests/FieldOffset.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/src/NewField/tests/Attic/FieldOffset.cpp,v
retrieving revision 1.1.2.3
diff -c -p -r1.1.2.3 FieldOffset.cpp
*** tests/FieldOffset.cpp 2001/08/06 17:02:50 1.1.2.3
--- tests/FieldOffset.cpp 2001/08/09 23:13:04
*************** int main(int argc, char *argv[])
*** 119,124 ****
--- 119,131 ----
f[0] = iota(f[0].domain()).comp(1) * iota(f[0].domain()).comp(1);
f[1] = iota(f[1].domain()).comp(0) * iota(f[1].domain()).comp(0);
+ // Test the data-parallel uses.
+
+ // Example data-parallel use:
+ // result_field = f(FieldOffset, result_centering). The FieldOffset
+ // should specify a location in the field f. The second parameter
+ // specifies the desired output centering.
+
FieldOffset<2> lowerXEdge(Loc<2>(0, 0), 0), upperXEdge(Loc<2>(0, 1), 0);
FieldOffset<2> leftYEdge(Loc<2>(0, 0), 1), rightYEdge(Loc<2>(1, 0), 1);
Index: tests/FieldReductions.cpp
===================================================================
RCS file: /home/pooma/Repository/r2/src/NewField/tests/Attic/FieldReductions.cpp,v
retrieving revision 1.1.2.1
diff -c -p -r1.1.2.1 FieldReductions.cpp
*** tests/FieldReductions.cpp 2001/08/02 22:36:56 1.1.2.1
--- tests/FieldReductions.cpp 2001/08/09 23:13:04
*************** checkFieldPosition(const Field<Geometry,
*** 49,57 ****
{
return
std::abs(sum(f, fol, loc) - sumAnswer) < tolerance &&
! std::abs(average(f, fol, loc) - avAnswer) < tolerance &&
! std::abs(minimum(f, fol, loc) - minAnswer) < tolerance &&
! std::abs(maximum(f, fol, loc) - maxAnswer) < tolerance;
}
--- 49,57 ----
{
return
std::abs(sum(f, fol, loc) - sumAnswer) < tolerance &&
! std::abs(av(f, fol, loc) - avAnswer) < tolerance &&
! std::abs(min(f, fol, loc) - minAnswer) < tolerance &&
! std::abs(max(f, fol, loc) - maxAnswer) < tolerance;
}
More information about the pooma-dev
mailing list