freepooma-devel
[Top][All Lists]
Advanced

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

[PATCH] Extend ScalarCode to allow writing to guards


From: Richard Guenther
Subject: [PATCH] Extend ScalarCode to allow writing to guards
Date: Fri, 14 Feb 2003 23:07:46 +0100 (CET)

Hi!

The following patch adds write-to-(external)-guards capability to
ScalarCode. This allows one to use the same functor for ScalarCode
and the external guards filler. Ideally this would allow for n-stage
computation without internal guards update for n*m sized internal guards,
too, but this needs prevention of internal guards fill (working on it).
The problem remains, that ScalarCodeInfo::lower_m/upper_m are not per
argument, and such prevent from storing into full 1-guard-layer field
with reading from 2-guard-layer field (cannot take the neccesarry view
of the 1-guard-layer field).

The extension comes with a new test.

Ok?

Richard.

===== MultiArgEvaluator.h 1.5 vs edited =====
--- 1.5/r2/src/Evaluator/MultiArgEvaluator.h    Fri Feb 14 21:39:39 2003
+++ edited/MultiArgEvaluator.h  Fri Feb 14 23:05:22 2003
@@ -173,6 +173,8 @@

     Pooma::beginExpression();

+    // Should use info.readers() here - but readers/writers are mutually
+    // exclusive so this (or the latter) seems not to be a great idea.
     applyMultiArg(multiArg, UpdateNotifier());

     MultiArgEvaluator<Evaluator_t>::evaluate(multiArg, function,
===== ScalarCodeInfo.h 1.1 vs edited =====
--- 1.1/r2/src/Evaluator/ScalarCodeInfo.h       Mon May 13 17:47:34 2002
+++ edited/ScalarCodeInfo.h     Fri Feb 14 22:56:48 2003
@@ -105,12 +105,16 @@
     dimensions_m = n;
     lower_m.resize(n);
     upper_m.resize(n);
+    wlower_m.resize(n);
+    wupper_m.resize(n);

     int i;
     for (i = 0; i < n; ++i)
     {
       lower_m[i] = 0;
       upper_m[i] = 0;
+      wlower_m[i] = 0;
+      wupper_m[i] = 0;
     }
   }

@@ -123,6 +127,21 @@
   {
     return upper_m[i];
   }
+
+  // Extend the evaluation domain into the guard layers by the amount
+  // specified with g. Needs to be less or equal the guard layer specification
+  // with lowerExtent() and upperExtent().
+
+  template <int Dim>
+  void evaluationExtent(const GuardLayers<Dim> &g)
+  {
+    PAssert(dimensions_m == Dim);
+    for (int i = 0; i < Dim; ++i)
+    {
+      wlower_m[i] = g.lower(i);
+      wupper_m[i] = g.upper(i);
+    }
+  }

   void write(int i, bool f)
   {
@@ -175,8 +194,8 @@
     {
       ret[d] =
        Interval<1>(
-                   lower_m[d],
-                   domain[d].last() - domain[d].first()  + lower_m[d]
+                   lower_m[d]-wlower_m[d],
+                   domain[d].last() - domain[d].first()  + lower_m[d] + 
wupper_m[d]
                    );
     }
     return ret;
@@ -194,6 +213,8 @@
   int       dimensions_m;
   Extents_t upper_m;
   Extents_t lower_m;
+  Extents_t wupper_m;
+  Extents_t wlower_m;
   BoolVector_t useGuards_m;
   BoolVector_t writers_m;
   BoolVector_t readers_m;
===== tests/makefile 1.7 vs edited =====
--- 1.7/r2/src/Evaluator/tests/makefile Fri Feb 14 21:39:39 2003
+++ edited/tests/makefile       Fri Feb 14 21:57:09 2003
@@ -36,7 +36,7 @@

 TESTS = compressibleTest1 \
        evaluatorTest1 evaluatorTest2 evaluatorTest3 evaluatorTest4 \
-       evaluatorTest5 \
+       evaluatorTest5 evaluatorTest6 \
        ReductionTest1 ReductionTest2 ReductionTest3 ReductionTest4

 default:: build

// -*- 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

//-----------------------------------------------------------------------------
// evaluatorTest5 - testing ScalarCode and direct external bounds computation
//-----------------------------------------------------------------------------

#include "Pooma/Pooma.h"
#include "Pooma/Arrays.h"
#include "Pooma/Fields.h" // for PerformUpdateTag() only!
#include "Evaluator/ScalarCode.h"
#include "Utilities/Tester.h"
#include <iostream>


// dummy operation

template <int extent>
struct Store
{
  Store(int val) : val_m(val) {}

  template<class A>
  inline void operator()(const A &a, const Loc<1> &i) const
  {
          a(i) = val_m;
  }

  void scalarCodeInfo(ScalarCodeInfo& i) const
  {
    i.arguments(1);
    i.dimensions(1);
    i.lowerExtent(0) = 2;
    i.upperExtent(0) = 2;
    i.evaluationExtent(GuardLayers<1>(extent));
    i.write(0, true);
    i.useGuards(0, true);
  }

  const int val_m;
};


int main(int argc, char *argv[])
{
  // Initialize POOMA and output stream, using Tester class
  Pooma::initialize(argc, argv);
  Pooma::Tester tester(argc, argv);

  Pooma::blockingExpressions(true);

  Interval<1> domain(0, 7);
  DomainLayout<1> layout(domain, GuardLayers<1>(2));
  UniformRectilinearMesh<1> mesh(layout);
  Centering<1> cell = canonicalCentering<1>(VertexType, Continuous);

  Field<UniformRectilinearMesh<1>, int, Brick>
     a(cell, layout, mesh);

  // init all of a
  a.all() = 0;
  tester.out() << a.all() << std::endl;
  tester.check("guard init", a(-2) == 0 && a(-1) == 0
                             && a(8) == 0 && a(9) == 0);

  // zero-extent Store into a
  (ScalarCode<Store<0> >(1))(a);
  tester.out() << a.all() << std::endl;
  tester.check("guard init", a(-2) == 0 && a(-1) == 0
                             && a(8) == 0 && a(9) == 0);

  // one-extent Store into a
  (ScalarCode<Store<1> >(2))(a);
  tester.out() << a.all() << std::endl;
  tester.check("guard init", a(-2) == 0 && a(-1) == 2
                             && a(8) == 2 && a(9) == 0);

  // two-extent Store into a
  (ScalarCode<Store<2> >(3))(a);
  tester.out() << a.all() << std::endl;
  tester.check("guard init", a(-2) == 3 && a(-1) == 3
                             && a(8) == 3 && a(9) == 3);

  int retval = tester.results("evaluatorTest6 (ScalarCode)");
  Pooma::finalize();
  return retval;
}

// ACL:rcsinfo
// ----------------------------------------------------------------------
// $RCSfile: evaluatorTest2.cpp,v $   $Author: pooma $
// $Revision: 1.7 $   $Date: 2003/01/29 19:32:07 $
// ----------------------------------------------------------------------
// ACL:rcsinfo

reply via email to

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