freepooma-devel
[Top][All Lists]
Advanced

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

[BUG] ScalarCode with Fields not honouring relations!


From: Richard Guenther
Subject: [BUG] ScalarCode with Fields not honouring relations!
Date: Thu, 13 Feb 2003 13:46:06 +0100 (CET)

Hi!

ScalarCode in its current form does not honour Fields relations.
I.e. it does not dirty them on write. Triggering them on reads
seems to work. Testcase below.

I suppose we should add something like

  enum { hasRelations = true };

to Field<> and

  enum { hasRelations = false };

to Array<>, so we can handle this in ScalarCode and maybe related places.

Anyway, the Relation machine seems to be suboptimal for doing boundary
conditions (but hey - those tend to be cheap compared to communicating of
the internal guards).

Any ideas?

Richard.

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


//-----------------------------------------------------------------------------
// 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);
  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());

  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());
  bupd = 0;

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


reply via email to

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