*** pooma-bk/r2/src/Evaluator/ScalarCodeInfo.h Thu Oct 23 14:39:32 2003 --- pooma-bib/r2/src/Evaluator/ScalarCodeInfo.h Thu Jul 15 11:31:53 2004 *************** *** 56,61 **** --- 56,62 ---- //----------------------------------------------------------------------------- #include "Layout/INode.h" + #include "Layout/GuardLayers.h" //----------------------------------------------------------------------------- // Forward Declarations: *************** *** 67,143 **** // //----------------------------------------------------------------------------- class ScalarCodeInfo { public: ! typedef std::vector Extents_t; typedef std::vector BoolVector_t; ScalarCodeInfo() { - arguments_m = 0; - dimensions_m = 0; - } - - /// The number of arguments of the ScalarCode functor. This needs to be - /// called before any of write() and useGuards(). - void arguments(int n) - { - PAssert(n > 0); - - arguments_m = n; - writers_m.resize(n); - readers_m.resize(n); - useGuards_m.resize(n); - - int i; - for (i = 0; i < n; ++i) - { - writers_m[i] = false; - readers_m[i] = true; - useGuards_m[i] = true; - } writers_m[0] = true; readers_m[0] = false; } ! /// The number of dimensions the arguments to the ScalarCode functor ! /// span. This needs to be specified before any of the lowerExtent() ! /// and upperExtent(). ! void dimensions(int n) ! { ! PAssert(n > 0); ! ! dimensions_m = n; ! lower_m.resize(n); ! upper_m.resize(n); ! int i; ! for (i = 0; i < n; ++i) ! { ! lower_m[i] = 0; ! upper_m[i] = 0; ! } } ! /// Lower extent for dimension i. This specifies the (maximum) stencil size. ! /// Note that you need to make sure a view extending the physical domain by ! /// this amount can be taken of every argument to the functor. ! ! int &lowerExtent(int i) { ! return lower_m[i]; } ! /// Upper extent for dimension i. This specifies the (maximum) stencil size. ! /// Note that you need to make sure a view extending the physical domain by ! /// this amount can be taken of every argument to the functor. ! ! int &upperExtent(int i) { ! return upper_m[i]; } ! /// Specify whether argument i is written to, writing allows reading. This /// triggers notifying the engine after writing and possibly dirtying /// relations attached to a written field. --- 68,111 ---- // //----------------------------------------------------------------------------- + template class ScalarCodeInfo { public: ! enum { dimensions = Dim }; ! enum { arguments = size }; ! typedef std::vector BoolVector_t; ScalarCodeInfo() + : extent_m(GuardLayers(0)), + useGuards_m(arguments, true), + writers_m(arguments, false), + readers_m(arguments, true) { writers_m[0] = true; readers_m[0] = false; } ! /// Specify the shape of the guard layers used. This is used for taking ! /// views of the arguments. ! void extent(const GuardLayers &g) ! { ! extent_m = g; } ! GuardLayers& extent() { ! return extent_m; } ! const GuardLayers& extent() const { ! return extent_m; } ! ! /// Specify whether argument i is written to, writing allows reading. This /// triggers notifying the engine after writing and possibly dirtying /// relations attached to a written field. *************** *** 170,220 **** /// The domain we take the view of before passing it to the functors /// operator() method. ! template ! inline Interval extendDomain(const Interval &domain) { ! Interval ret; ! int d; ! for (d = 0; d < D; ++d) ! { ! ret[d] = ! Interval<1>( ! domain[d].first() - lower_m[d], ! domain[d].last() + upper_m[d] ! ); ! } ! return ret; } /// The domain evaluation takes place on the viewed (zero-based!) engine. ! template ! inline Interval evaluationDomain(const Interval &domain) { ! Interval ret; ! int d; ! for (d = 0; d < D; ++d) { ! ret[d] = ! Interval<1>( ! lower_m[d], ! domain[d].last() - domain[d].first() + lower_m[d] ! ); } return ret; } ! template ! inline INode extendDomain(const INode &inode) { ! return INode(inode, extendDomain(inode.domain())); } private: ! int arguments_m; ! int dimensions_m; ! Extents_t upper_m; ! Extents_t lower_m; BoolVector_t useGuards_m; BoolVector_t writers_m; BoolVector_t readers_m; --- 138,169 ---- /// The domain we take the view of before passing it to the functors /// operator() method. ! inline Interval extendDomain(const Interval &domain) const { ! return grow(domain, extent_m); } /// The domain evaluation takes place on the viewed (zero-based!) engine. ! inline Interval evaluationDomain(const Interval &domain) const { ! Interval ret; ! for (int d = 0; d < Dim; ++d) { ! ret[d] = Interval<1>(extent_m.lower(d), ! domain[d].last() - domain[d].first() ! + extent_m.lower(d)); } return ret; } ! inline INode extendDomain(const INode &inode) const { ! return INode(inode, extendDomain(inode.domain())); } private: ! GuardLayers extent_m; BoolVector_t useGuards_m; BoolVector_t writers_m; BoolVector_t readers_m;