freepooma-devel
[Top][All Lists]
Advanced

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

[PATCH] Fix ScalarCode wrt Field Relations


From: Richard Guenther
Subject: [PATCH] Fix ScalarCode wrt Field Relations
Date: Fri, 14 Feb 2003 16:47:43 +0100 (CET)

Hi!

The following patch fixes ScalarCode which is not dirtying Field
Relations on arguments written to. Adds a new testcase.

Tested on x86-serial-linux with no regressions in Field, Evaluator
and Array.

Ok?

Richard.

--
Richard Guenther <address@hidden>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/

diff -Nru a/r2/src/Array/Array.h b/r2/src/Array/Array.h
--- a/r2/src/Array/Array.h      Fri Feb 14 16:26:13 2003
+++ b/r2/src/Array/Array.h      Fri Feb 14 16:26:13 2003
@@ -1433,6 +1433,9 @@
   enum { dimensions = Engine_t::dimensions };
   enum { rank = Engine_t::dimensions };

+  // Arrays dont support relations attached to them.
+
+  enum { hasRelations = false };

   //===========================================================================
   // Constructors
diff -Nru a/r2/src/Evaluator/MultiArgEvaluator.h 
b/r2/src/Evaluator/MultiArgEvaluator.h
--- a/r2/src/Evaluator/MultiArgEvaluator.h      Fri Feb 14 16:26:13 2003
+++ b/r2/src/Evaluator/MultiArgEvaluator.h      Fri Feb 14 16:26:13 2003
@@ -106,6 +106,17 @@
   }

   template<class A>
+  inline void dirtyRelations(const A &a, const WrappedInt<true>&) const
+  {
+    a.setDirty();
+  }
+
+  template<class A>
+  inline void dirtyRelations(const A &, const WrappedInt<false>&) const
+  {
+  }
+
+  template<class A>
   void operator()(const A &a, bool f) const
   {
     if (f)
@@ -117,6 +128,7 @@
       // all the engines in a field.

       notifyEngineWrite(a.engine());
+      dirtyRelations(a, WrappedInt<A::hasRelations>());
     }
   }
 };
diff -Nru a/r2/src/Evaluator/tests/evaluatorTest5.cpp 
b/r2/src/Evaluator/tests/evaluatorTest5.cpp
--- /dev/null   Wed Dec 31 16:00:00 1969
+++ b/r2/src/Evaluator/tests/evaluatorTest5.cpp Fri Feb 14 16:26:13 2003
@@ -0,0 +1,185 @@
+// -*- 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 boundary update
+//-----------------------------------------------------------------------------
+
+#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
+
+struct DirtyRelations
+{
+  DirtyRelations() {}
+
+  template<class A>
+  inline void operator()(const A &a, const Loc<1> &i) const
+  {
+  }
+
+  void scalarCodeInfo(ScalarCodeInfo& i) const
+  {
+    i.arguments(1);
+    i.dimensions(1);
+    i.lowerExtent(0) = 0;
+    i.upperExtent(0) = 0;
+    i.write(0, true);
+    i.useGuards(0, false);
+  }
+};
+struct TriggerRelations
+{
+  TriggerRelations() {}
+
+  template<class A>
+  inline void operator()(const A &a, const Loc<1> &i) const
+  {
+  }
+
+  void scalarCodeInfo(ScalarCodeInfo& i) const
+  {
+    i.arguments(1);
+    i.dimensions(1);
+    i.lowerExtent(0) = 1;
+    i.upperExtent(0) = 1;
+    i.write(0, false);
+    i.useGuards(0, true);
+  }
+};
+struct TriggerAndDirtyRelations
+{
+  TriggerAndDirtyRelations() {}
+
+  template<class A>
+  inline void operator()(const A &a, const Loc<1> &i) const
+  {
+  }
+
+  void scalarCodeInfo(ScalarCodeInfo& i) const
+  {
+    i.arguments(1);
+    i.dimensions(1);
+    i.lowerExtent(0) = 1;
+    i.upperExtent(0) = 1;
+    i.write(0, true); // umm - _and_ read...
+    i.useGuards(0, true);
+  }
+};
+
+// boundary condition just incementing a global counter
+
+static int bupd = 0;
+
+class DummyBC
+{
+public:
+  DummyBC() {}
+  DummyBC(const DummyBC &) {}
+  template <class Target>
+  DummyBC(const DummyBC &, const Target &) {}
+  DummyBC& operator=(const DummyBC&) {}
+  template <class Target>
+  void operator()(const Target&) const
+  {
+     bupd++;
+  }
+};
+
+
+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);
+
+  int size = 120;
+
+  Interval<1> domain(size);
+  DomainLayout<1> layout(domain, GuardLayers<1>(1));
+  UniformRectilinearMesh<1> mesh(layout);
+  Centering<1> cell = canonicalCentering<1>(CellType, Continuous);
+
+  Field<UniformRectilinearMesh<1>, double, Brick>
+     a(cell, layout, mesh), b(cell, layout, mesh);
+
+  tester.out() << "Adding relation\n";
+  Pooma::newRelation(DummyBC(), a);
+  RelationListItem *rel = a.fieldEngine().data(0, 0).relations()(0);
+
+  tester.check("a has dirty relation", rel->dirty());
+  tester.check("a did not have relations applied", bupd == 0);
+
+  bupd = 0;
+  rel->setDirty();
+  tester.out() << "Applying DirtyRelations()\n";
+  ScalarCode<DirtyRelations>()(a);
+  // not applying relations here is an optimization we're not able to do right 
now
+  //tester.check("a did not have relations applied", bupd == 0);
+  tester.check("a has dirty relation", rel->dirty());
+
+  bupd = 0;
+  rel->setDirty();
+  tester.out() << "Applying TriggerRelations()\n";
+  ScalarCode<TriggerRelations>()(a);
+  tester.check("a did have relations applied", bupd == 1);
+  tester.check("a has clean relation", !rel->dirty());
+
+  bupd = 0;
+  rel->clearDirty();
+  tester.out() << "Applying TriggerAndDirtyRelations()\n";
+  ScalarCode<TriggerAndDirtyRelations>()(a);
+  tester.check("a did not have relations applied", bupd == 0);
+  tester.check("a has dirty relation", rel->dirty());
+
+  bupd = 0;
+  rel->setDirty();
+  tester.out() << "Reading from a.all()\n";
+  b.all() = a.all();
+  tester.check("a did have relations applied", bupd == 1);
+  tester.check("a has clean relation", !rel->dirty());
+
+  int retval = tester.results("evaluatorTest5 (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
diff -Nru a/r2/src/Evaluator/tests/makefile b/r2/src/Evaluator/tests/makefile
--- a/r2/src/Evaluator/tests/makefile   Fri Feb 14 16:26:13 2003
+++ b/r2/src/Evaluator/tests/makefile   Fri Feb 14 16:26:13 2003
@@ -36,6 +36,7 @@

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

 default:: build
diff -Nru a/r2/src/Field/Field.h b/r2/src/Field/Field.h
--- a/r2/src/Field/Field.h      Fri Feb 14 16:26:13 2003
+++ b/r2/src/Field/Field.h      Fri Feb 14 16:26:13 2003
@@ -1132,6 +1132,10 @@

   typedef Centering<dimensions> Centering_t;

+  // Fields may have relations attached to them.
+
+  enum { hasRelations = true };
+
   //---------------------------------------------------------------------------
   // User-callable constructors. These ctors are meant to be called by users.


reply via email to

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