From oldham at codesourcery.com Thu Nov 1 01:21:19 2001 From: oldham at codesourcery.com (Jeffrey Oldham) Date: Wed, 31 Oct 2001 17:21:19 -0800 Subject: Reminder to Submit Timesheets Message-ID: <200111010121.fA11LJk25594@oz.codesourcery.com> This is a friendly reminder to submit your Pooma timesheets via OpenAir since it's the end of the month. Thanks, Jeffrey D. Oldham oldham at codesourcery.com From oldham at codesourcery.com Mon Nov 5 20:31:40 2001 From: oldham at codesourcery.com (Jeffrey Oldham) Date: Mon, 5 Nov 2001 12:31:40 -0800 Subject: Identifying Loop Invariant Data Members: Mark Mitchell's Approach Message-ID: <20011105123140.A19107@codesourcery.com> The attached patch partially implements Mark Mitchell's idea to mark loop-invariant Engine data members so the KCC optimizer can move them out of inner loops. Without this patch or a similar idea by Stephen Smith, the intermediate C code produced by KCC for the loops in src/Evaluator/InlineEvaluator.h's evaluate() reveals reloading of engine data members such as strides_m. These data values are invariant during the evaluate() loop. To notify the optimizer of the invariance, a separate constant structure containing these values is constructed just before the loop begins. This constant information is passed into the operations performed within the loop. Thus, the optimizer can determine the values are loop-invariant and may be hoisted out of the loop. For example, consider the evaluate() loop for the two-dimensional version of src/Evaluator/InlineEvaluator.h: for (int i1=0; i1 inline T Engine:: read(int i1, int i2) const { PAssert(Dim == 2); return data_m[offset(i1,i2)]; } to template inline T Engine:: read(const LoopInvariant_t& li, int i1, int i2) const { PAssert(Dim == 2); return li.data()[offset(li,i1,i2)]; } Here, li's data() returns a loop-invariant copy of the 'data_m' pointer and 'offset' also uses the loop-invariant object li. The PETE evaluation functions also need to support loop-invariant objects. The forEach functions in src/PETE/ForEach.h propagate evaluation through the expression objects. A copy of the ForEach 'apply' member functions accepting loop-invariant objects need to be added. Evaluation at the expression leaves are handled by 'apply' functions, which should be modified in a way similar to the 'read' and 'operator()' functions so the loop-invariant objects' contents are used. Stencil writers supply 'operator()' functions. Stephen Smith supplied a patch so these functions' parameters need not include loop-invariant objects. This idea is not incorporated in the first attached patch. Stephen Smith's patch is also attached. To permit Pooma users to directly call 'read' and 'operator()' functions, the original interface should be maintained, at least for containers. Thus, parallel code must be maintained, a disadvantage of this technique. Thanks, Jeffrey D. Oldham oldham at codesourcery.com -------------- next part -------------- Index: benchmarks/Doof2d/Doof2d.h =================================================================== RCS file: /home/pooma/Repository/r2/benchmarks/Doof2d/Doof2d.h,v retrieving revision 1.3 diff -c -p -r1.3 Doof2d.h *** benchmarks/Doof2d/Doof2d.h 2001/10/16 18:26:09 1.3 --- benchmarks/Doof2d/Doof2d.h 2001/11/05 19:28:25 *************** public: *** 360,373 **** for (k = 0; k < 5; ++k) { for (j = 2; j <= n_m - 1; j++) { for (i = 2; i <= n_m - 1; i++) { a_m(i,j) = fact * ! (b_m(i+1,j+1) + b_m(i+1,j ) + b_m(i+1,j-1) + ! b_m(i ,j+1) + b_m(i ,j ) + b_m(i ,j-1) + ! b_m(i-1,j+1) + b_m(i-1,j ) + b_m(i-1,j-1)); } } for (j = 2; j <= n_m-1; j++) --- 360,375 ---- for (k = 0; k < 5; ++k) { + const typename Store::LoopInvariant_t& ali = a_m.loopInvariant(); + const typename Store::LoopInvariant_t& bli = b_m.loopInvariant(); for (j = 2; j <= n_m - 1; j++) { for (i = 2; i <= n_m - 1; i++) { a_m(i,j) = fact * ! (b_m.read(bli,i+1,j+1) + b_m.read(bli,i+1,j ) + b_m.read(bli,i+1,j-1) + ! b_m.read(bli,i ,j+1) + b_m.read(bli,i ,j ) + b_m.read(bli,i ,j-1) + ! b_m.read(bli,i-1,j+1) + b_m.read(bli,i-1,j ) + b_m.read(bli,i-1,j-1)); } } for (j = 2; j <= n_m-1; j++) *************** public: *** 375,383 **** for (i = 2; i <= n_m-1; i++) { b_m(i,j) = fact * ! (a_m(i+1,j+1) + a_m(i+1,j ) + a_m(i+1,j-1) + ! a_m(i ,j+1) + a_m(i ,j ) + a_m(i ,j-1) + ! a_m(i-1,j+1) + a_m(i-1,j ) + a_m(i-1,j-1)); } } } --- 377,385 ---- for (i = 2; i <= n_m-1; i++) { b_m(i,j) = fact * ! (a_m.read(ali,i+1,j+1) + a_m.read(ali,i+1,j ) + a_m.read(ali,i+1,j-1) + ! a_m.read(ali,i ,j+1) + a_m.read(ali,i ,j ) + a_m.read(ali,i ,j-1) + ! a_m.read(ali,i-1,j+1) + a_m.read(ali,i-1,j ) + a_m.read(ali,i-1,j-1)); } } } *************** public: *** 496,507 **** template inline typename A::Element_t ! operator()(const A& x, int i, int j) const { return ( (1.0/9.0) * ! ( x.read(i+1,j+1) + x.read(i+1,j ) + x.read(i+1,j-1) + ! x.read(i ,j+1) + x.read(i ,j ) + x.read(i ,j-1) + ! x.read(i-1,j+1) + x.read(i-1,j ) + x.read(i-1,j-1) ) ); } inline int lowerExtent(int) const { return 1; } --- 498,510 ---- template inline typename A::Element_t ! operator()(const A& x, const typename A::LoopInvariant_t& li, ! int i, int j) const { return ( (1.0/9.0) * ! ( x.read(li,i+1,j+1) + x.read(li,i+1,j ) + x.read(li,i+1,j-1) + ! x.read(li,i ,j+1) + x.read(li,i ,j ) + x.read(li,i ,j-1) + ! x.read(li,i-1,j+1) + x.read(li,i-1,j ) + x.read(li,i-1,j-1) ) ); } inline int lowerExtent(int) const { return 1; } Index: src/Array/Array.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Array/Array.h,v retrieving revision 1.144 diff -c -p -r1.144 Array.h *** src/Array/Array.h 2001/09/14 22:37:56 1.144 --- src/Array/Array.h 2001/11/05 19:28:26 *************** struct View1Implementation Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // The return types are pretty simple here. *************** struct View1Implementation inline static ! Type_t make(const Subject_t &a, const S1 &s1, const Combine &) ! { ! Domain s(Combine::make(a, s1)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine()(s); ! } template inline static Type_t make(const Subject_t &a, const S1 &s1, const S2 &s2, const Combine &) ! { ! Domain s(Combine::make(a, s1, s2)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine()(s); ! } template --- 147,177 ---- template inline static ! Type_t make(const Subject_t &a, ! const S1 &s1, const Combine &) ! { ! Domain s(Combine::make(a, s1)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine()(s); ! } template inline static Type_t make(const Subject_t &a, const S1 &s1, const S2 &s2, const Combine &) ! { ! Domain s(Combine::make(a, s1, s2)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine()(s); ! } template *************** struct View1Implementation --- 179,192 ---- Type_t make(const Subject_t &a, const S1 &s1, const S2 &s2, const S3 &s3, const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine()(s); ! } template *************** struct View1Implementation --- 195,208 ---- const S1 &s1, const S2 &s2, const S3 &s3, const S4 &s4, const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine()(s); ! } template *************** struct View1Implementation --- 211,224 ---- const S1 &s1, const S2 &s2, const S3 &s3, const S4 &s4, const S5 &s5, const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine()(s); ! } template *************** struct View1Implementation --- 227,240 ---- const S1 &s1, const S2 &s2, const S3 &s3, const S4 &s4, const S5 &s5, const S6 &s6, const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine()(s); ! } template *************** struct View1Implementation inline static ReadType_t makeRead(const Subject_t &a, const S1 &s1, ! const Combine &) ! { ! Domain s(Combine::make(a, s1)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(s); ! } template inline static ReadType_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(s); ! } template inline static ReadType_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(s); ! } template inline static ReadType_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(s); ! } template inline static ReadType_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(s); ! } template inline static ReadType_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(s); ! } template inline static ReadType_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const S7 &s7, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6, s7)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(s); ! } }; // Non-single-valued implementation. Works for general domains // including Nodes and INodes. --- 244,599 ---- const S4 &s4, const S5 &s5, const S6 &s6, const S7 &s7, const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6, s7)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine()(s); ! } ! ! template ! inline static ! Type_t make(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, ! const Combine &) ! { ! Domain s(Combine::make(a, s1)); ! #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); ! #endif ! return a.engine()(li, s); ! } ! ! template ! inline static ! Type_t make(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2)); ! #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); ! #endif ! return a.engine()(li, s); ! } ! ! template ! inline static ! Type_t make(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3)); ! #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); ! #endif ! return a.engine()(li, s); ! } ! ! template ! inline static ! Type_t make(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4)); ! #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); ! #endif ! return a.engine()(li, s); ! } ! ! template ! inline static ! Type_t make(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5)); ! #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); ! #endif ! return a.engine()(li, s); ! } + template + inline static + Type_t make(const Subject_t &a, + const LoopInvariant_t &li, + const S1 &s1, const S2 &s2, const S3 &s3, + const S4 &s4, const S5 &s5, const S6 &s6, + const Combine &) + { + Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6)); + #if POOMA_BOUNDS_CHECK + PInsist(contains(a.domain(), s), + "Array view bounds error."); + #endif + return a.engine()(li, s); + } + + template + inline static + Type_t make(const Subject_t &a, + const LoopInvariant_t &li, + const S1 &s1, const S2 &s2, const S3 &s3, + const S4 &s4, const S5 &s5, const S6 &s6, + const S7 &s7, + const Combine &) + { + Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6, s7)); + #if POOMA_BOUNDS_CHECK + PInsist(contains(a.domain(), s), + "Array view bounds error."); + #endif + return a.engine()(li, s); + } + // Read only versions. template inline static ReadType_t makeRead(const Subject_t &a, const S1 &s1, ! const Combine &) ! { ! Domain s(Combine::make(a, s1)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(s); ! } template inline static ReadType_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(s); ! } template inline static ReadType_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(s); ! } template inline static ReadType_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(s); ! } template inline static ReadType_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(s); ! } template inline static ReadType_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(s); ! } template inline static ReadType_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const S7 &s7, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6, s7)); ! #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); ! #endif ! return a.engine().read(s); ! } ! ! template ! inline static ! ReadType_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, ! const Combine &) ! { ! Domain s(Combine::make(a, s1)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); #endif ! return a.engine().read(li, s); ! } ! ! template ! inline static ! ReadType_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2)); ! #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); ! #endif ! return a.engine().read(li, s); ! } ! ! template ! inline static ! ReadType_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3)); ! #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); ! #endif ! return a.engine().read(li, s); ! } ! ! template ! inline static ! ReadType_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4)); ! #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); ! #endif ! return a.engine().read(li, s); ! } ! ! template ! inline static ! ReadType_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5)); ! #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); ! #endif ! return a.engine().read(li, s); ! } ! ! template ! inline static ! ReadType_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6)); ! #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); ! #endif ! return a.engine().read(li, s); ! } ! ! template ! inline static ! ReadType_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const S7 &s7, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6, s7)); ! #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), ! "Array view bounds error."); ! #endif ! return a.engine().read(li, s); ! } }; + // Non-single-valued implementation. Works for general domains // including Nodes and INodes. *************** struct View1Implementation Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // Deduce the template parameters for the output type. *************** struct View1Implementation static Type_t make(const Subject_t &a, const S1 &s1, ! const Combine &) ! { ! Domain s(Combine::make(a, s1)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } template static ! Type_t make(const Subject_t &a, const S1 &s1, ! const S2 &s2, const Combine &) ! { ! Domain s(Combine::make(a, s1, s2)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } template static Type_t make(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } template static Type_t make(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } template static Type_t make(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } template static Type_t make(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } template static Type_t make(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const S7 &s7, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6, s7)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } // Read-only versions. template inline static Type_t makeRead(const Subject_t &a, const S1 &s1, ! const Combine &c) ! { ! return make(a, s1, c); ! } template inline static Type_t makeRead(const Subject_t &a, const S1 &s1, ! const S2 &s2, const Combine &c) ! { ! return make(a, s1, s2, c); ! } template inline static Type_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const Combine &c) ! { ! return make(a, s1, s2, s3, c); ! } template inline static Type_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const Combine &c) ! { ! return make(a, s1, s2, s3, s4, c); ! } template inline static Type_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const Combine &c) ! { ! return make(a, s1, s2, s3, s4, s5, c); ! } template inline static Type_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const Combine &c) ! { ! return make(a, s1, s2, s3, s4, s5, s6, c); ! } template inline static Type_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const S7 &s7, const Combine &c) ! { ! return make(a, s1, s2, s3, s4, s5, s6, s7, c); ! } }; // General version. --- 627,906 ---- template static Type_t make(const Subject_t &a, const S1 &s1, ! const Combine &) ! { ! Domain s(Combine::make(a, s1)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } template static ! Type_t make(const Subject_t &a, ! const S1 &s1, const S2 &s2, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } template static Type_t make(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } template static Type_t make(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } template static Type_t make(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } template static Type_t make(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } template static Type_t make(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const S7 &s7, ! const Combine &) ! { ! Domain s(Combine::make(a, s1, s2, s3, s4, s5, s6, s7)); #if POOMA_BOUNDS_CHECK ! PInsist(contains(a.domain(), s), "Array view bounds error."); #endif ! return Type_t( ! NewEE_t::apply(a.engine(), s), ! NewED_t::apply(a.engine(), s)); ! } // Read-only versions. template inline static Type_t makeRead(const Subject_t &a, const S1 &s1, ! const Combine &c) ! { ! return make(a, s1, c); ! } template inline static Type_t makeRead(const Subject_t &a, const S1 &s1, ! const S2 &s2, const Combine &c) ! { ! return make(a, s1, s2, c); ! } template inline static Type_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const Combine &c) ! { ! return make(a, s1, s2, s3, c); ! } template inline static Type_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const Combine &c) ! { ! return make(a, s1, s2, s3, s4, c); ! } template inline static Type_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const Combine &c) ! { ! return make(a, s1, s2, s3, s4, s5, c); ! } template inline static Type_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const Combine &c) ! { ! return make(a, s1, s2, s3, s4, s5, s6, c); ! } template inline static Type_t makeRead(const Subject_t &a, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const S7 &s7, const Combine &c) ! { ! return make(a, s1, s2, s3, s4, s5, s6, s7, c); ! } ! ! template ! inline static ! Type_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, ! const Combine &c) ! { ! return make(a, li, s1, c); ! } ! ! template ! inline static ! Type_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const Combine &c) ! { ! return make(a, li, s1, s2, c); ! } ! ! template ! inline static ! Type_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const Combine &c) ! { ! return make(a, li, s1, s2, s3, c); ! } ! ! template ! inline static ! Type_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const Combine &c) ! { ! return make(a, li, s1, s2, s3, s4, c); ! } ! ! template ! inline static ! Type_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const Combine &c) ! { ! return make(a, li, s1, s2, s3, s4, s5, c); ! } ! ! template ! inline static ! Type_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const Combine &c) ! { ! return make(a, li, s1, s2, s3, s4, s5, s6, c); ! } ! ! template ! inline static ! Type_t makeRead(const Subject_t &a, ! const LoopInvariant_t &li, ! const S1 &s1, const S2 &s2, const S3 &s3, ! const S4 &s4, const S5 &s5, const S6 &s6, ! const S7 &s7, const Combine &c) ! { ! return make(a, li, s1, s2, s3, s4, s5, s6, s7, c); ! } }; // General version. *************** struct View1, D *** 598,603 **** --- 911,917 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // Deduce domains for the output type. // At some point, we need to fix NewDomain1; until then, use *************** struct View1, D *** 634,639 **** --- 948,961 ---- { return Dispatch_t::makeRead(a, s1, Combine_t()); } + + inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t &li, + const Domain &s1) + { + return Dispatch_t::makeRead(a, li, s1, Combine_t()); + } }; // View0 deals with the special case of read() and *************** struct View0 > *** 651,656 **** --- 973,979 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // Deduce domains for the output type. // At some point, we need to fix NewDomain1; until then, use *************** struct View0 > *** 686,691 **** --- 1009,1020 ---- { return make(a); } + + inline static ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t &li) + { + return make(a, li); + } }; // AltView0 avoids an instantiation problem that arises when two *************** struct View1, i *** 729,734 **** --- 1058,1064 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // The return types. *************** struct View1, i *** 756,761 **** --- 1086,1103 ---- #endif return a.engine().read(s1); } + + inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t &li, + int s1) + { + #if POOMA_BOUNDS_CHECK + PInsist(contains(a.domain(), Loc<1>(s1)), + "Array view bounds error."); + #endif + return a.engine().read(li, s1); + } }; template *************** struct View1, Array Array2_t; typedef IndirectionTag Tag_t; + // HERE // The return types. *************** struct View2, S *** 795,800 **** --- 1138,1144 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // Deduce domains for the output type. *************** struct View2, S *** 818,827 **** // Functions that create the view. inline static ! Type_t make(const Subject_t &a, const Sub1 &s1, const Sub2 &s2) { ! return Dispatch_t::make(a, s1, s2, Combine_t()); } inline static --- 1162,1180 ---- // Functions that create the view. + inline static + Type_t make(const Subject_t &a, const Sub1 &s1, const Sub2 &s2) + { + return Dispatch_t::make(a, s1, s2, Combine_t()); + } + + // FIXME: Convert other dimensions' versions. inline static ! Type_t make(const Subject_t &a, ! const LoopInvariant_t &li, ! const Sub1 &s1, const Sub2 &s2) { ! return Dispatch_t::make(a, li, s1, s2, Combine_t()); } inline static *************** struct View2, S *** 829,834 **** --- 1182,1195 ---- { return Dispatch_t::makeRead(a, s1, s2, Combine_t()); } + + inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t& li, + const Sub1 &s1, const Sub2 &s2) + { + return Dispatch_t::makeRead(a, li, s1, s2, Combine_t()); + } }; template *************** struct View2, i *** 837,842 **** --- 1198,1204 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // The return types. *************** struct View2, i *** 855,860 **** --- 1217,1236 ---- return a.engine()(s1, s2); } + // FIXME: Convert other dimensions' versions. + inline static + Type_t make(const Subject_t &a, + const LoopInvariant_t &li, + int s1, int s2) + { + #if POOMA_BOUNDS_CHECK + PInsist(contains(a.domain(), Loc<2>(s1, s2)), + "Array view bounds error."); + #endif + // HERE + return a.engine()(li, s1, s2); + } + inline static ReadType_t makeRead(const Subject_t &a, int s1, int s2) { *************** struct View2, i *** 864,869 **** --- 1240,1257 ---- #endif return a.engine().read(s1, s2); } + + inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t& li, + int s1, int s2) + { + #if POOMA_BOUNDS_CHECK + PInsist(contains(a.domain(), Loc<2>(s1, s2)), + "Array view bounds error."); + #endif + return a.engine().read(li, s1, s2); + } }; // These are for views of the form a(b, c, d). *************** struct View3, S *** 875,880 **** --- 1263,1269 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // Deduce domains for the output type. *************** struct View3, S *** 911,916 **** --- 1300,1314 ---- { return Dispatch_t::makeRead(a, s1, s2, s3, Combine_t()); } + + inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t& li, + const Sub1 &s1, const Sub2 &s2, + const Sub3 &s3) + { + return Dispatch_t::makeRead(a, li, s1, s2, s3, Combine_t()); + } }; template *************** struct View3, i *** 919,924 **** --- 1317,1323 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // The return types. *************** struct View3, i *** 946,951 **** --- 1345,1362 ---- #endif return a.engine().read(s1, s2, s3); } + + inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t& li, + int s1, int s2, int s3) + { + #if POOMA_BOUNDS_CHECK + PInsist(contains(a.domain(), Loc<3>(s1, s2, s3)), + "Array view bounds error."); + #endif + return a.engine().read(li, s1, s2, s3); + } }; // These are for views of the form a(b, c, d, e). *************** struct View4, *** 958,963 **** --- 1369,1375 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // Deduce domains for the output type. *************** struct View4, *** 989,999 **** } inline static ! ReadType_t makeRead(const Subject_t &a, const Sub1 &s1, const Sub2 &s2, ! const Sub3 &s3, const Sub4 &s4) { return Dispatch_t::makeRead(a, s1, s2, s3, s4, Combine_t()); } }; template --- 1401,1421 ---- } inline static ! ReadType_t makeRead(const Subject_t &a, ! const Sub1 &s1, const Sub2 &s2, ! const Sub3 &s3, const Sub4 &s4) { return Dispatch_t::makeRead(a, s1, s2, s3, s4, Combine_t()); } + + inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t& li, + const Sub1 &s1, const Sub2 &s2, + const Sub3 &s3, const Sub4 &s4) + { + return Dispatch_t::makeRead(a, li, s1, s2, s3, s4, Combine_t()); + } }; template *************** struct View4, i *** 1002,1007 **** --- 1424,1430 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // The return types. *************** struct View4, i *** 1029,1034 **** --- 1452,1469 ---- #endif return a.engine().read(s1, s2, s3, s4); } + + inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t& li, + int s1, int s2, int s3, int s4) + { + #if POOMA_BOUNDS_CHECK + PInsist(contains(a.domain(), Loc<4>(s1, s2, s3, s4)), + "Array view bounds error."); + #endif + return a.engine().read(li, s1, s2, s3, s4); + } }; // These are for views of the form a(b, c, d, e, f). *************** struct View5, *** 1041,1046 **** --- 1476,1482 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // Deduce domains for the output type. *************** struct View5, *** 1072,1082 **** } inline static ! ReadType_t makeRead(const Subject_t &a, const Sub1 &s1, const Sub2 &s2, ! const Sub3 &s3, const Sub4 &s4, const Sub5 &s5) { return Dispatch_t::makeRead(a, s1, s2, s3, s4, s5, Combine_t()); } }; template --- 1508,1528 ---- } inline static ! ReadType_t makeRead(const Subject_t &a, ! const Sub1 &s1, const Sub2 &s2, ! const Sub3 &s3, const Sub4 &s4, const Sub5 &s5) { return Dispatch_t::makeRead(a, s1, s2, s3, s4, s5, Combine_t()); } + + inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t& li, + const Sub1 &s1, const Sub2 &s2, + const Sub3 &s3, const Sub4 &s4, const Sub5 &s5) + { + return Dispatch_t::makeRead(a, li, s1, s2, s3, s4, s5, Combine_t()); + } }; template *************** struct View5, i *** 1085,1090 **** --- 1531,1537 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // The return types. *************** struct View5, i *** 1094,1101 **** // Functions that perform the indexing. inline static ! ReadType_t makeRead(const Subject_t &a, int s1, int s2, int s3, ! int s4, int s5) { #if POOMA_BOUNDS_CHECK PInsist(contains(a.domain(), Loc<5>(s1, s2, s3, s4, s5)), --- 1541,1549 ---- // Functions that perform the indexing. inline static ! ReadType_t makeRead(const Subject_t &a, ! int s1, int s2, int s3, ! int s4, int s5) { #if POOMA_BOUNDS_CHECK PInsist(contains(a.domain(), Loc<5>(s1, s2, s3, s4, s5)), *************** struct View5, i *** 1105,1110 **** --- 1553,1571 ---- } inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t& li, + int s1, int s2, int s3, + int s4, int s5) + { + #if POOMA_BOUNDS_CHECK + PInsist(contains(a.domain(), Loc<5>(s1, s2, s3, s4, s5)), + "Array view bounds error."); + #endif + return a.engine().read(li, s1, s2, s3, s4, s5); + } + + inline static Type_t make(const Subject_t &a, int s1, int s2, int s3, int s4, int s5) { #if POOMA_BOUNDS_CHECK *************** struct View6, *** 1126,1131 **** --- 1587,1593 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // Deduce domains for the output type. *************** struct View6, *** 1157,1167 **** } inline static ! ReadType_t makeRead(const Subject_t &a, const Sub1 &s1, const Sub2 &s2, ! const Sub3 &s3, const Sub4 &s4, const Sub5 &s5, const Sub6 &s6) { return Dispatch_t::makeRead(a, s1, s2, s3, s4, s5, s6, Combine_t()); } }; template --- 1619,1641 ---- } inline static ! ReadType_t makeRead(const Subject_t &a, ! const Sub1 &s1, const Sub2 &s2, ! const Sub3 &s3, const Sub4 &s4, ! const Sub5 &s5, const Sub6 &s6) { return Dispatch_t::makeRead(a, s1, s2, s3, s4, s5, s6, Combine_t()); } + + inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t& li, + const Sub1 &s1, const Sub2 &s2, + const Sub3 &s3, const Sub4 &s4, + const Sub5 &s5, const Sub6 &s6) + { + return Dispatch_t::makeRead(a, li, s1, s2, s3, s4, s5, s6, Combine_t()); + } }; template *************** struct View6, i *** 1170,1175 **** --- 1644,1650 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // The return types. *************** struct View6, i *** 1190,1197 **** } inline static ! ReadType_t makeRead(const Subject_t &a, int s1, int s2, int s3, ! int s4, int s5, int s6) { #if POOMA_BOUNDS_CHECK PInsist(contains(a.domain(), Loc<6>(s1, s2, s3, s4, s5, s6)), --- 1665,1673 ---- } inline static ! ReadType_t makeRead(const Subject_t &a, ! int s1, int s2, int s3, ! int s4, int s5, int s6) { #if POOMA_BOUNDS_CHECK PInsist(contains(a.domain(), Loc<6>(s1, s2, s3, s4, s5, s6)), *************** struct View6, i *** 1199,1204 **** --- 1675,1693 ---- #endif return a.engine().read(s1, s2, s3, s4, s5, s6); } + + inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t& li, + int s1, int s2, int s3, + int s4, int s5, int s6) + { + #if POOMA_BOUNDS_CHECK + PInsist(contains(a.domain(), Loc<6>(s1, s2, s3, s4, s5, s6)), + "Array view bounds error."); + #endif + return a.engine().read(li, s1, s2, s3, s4, s5, s6); + } }; // These are for views of the form a(b, c, d, e, f, g, h). *************** struct View7, *** 1212,1217 **** --- 1701,1707 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // Deduce domains for the output type. *************** struct View7, *** 1245,1257 **** } inline static ! ReadType_t makeRead(const Subject_t &a, const Sub1 &s1, const Sub2 &s2, ! const Sub3 &s3, const Sub4 &s4, const Sub5 &s5, const Sub6 &s6, ! const Sub7 &s7) { return Dispatch_t::makeRead(a, s1, s2, s3, s4, s5, s6, s7, Combine_t()); } }; template --- 1735,1761 ---- } inline static ! ReadType_t makeRead(const Subject_t &a, ! const Sub1 &s1, const Sub2 &s2, ! const Sub3 &s3, const Sub4 &s4, ! const Sub5 &s5, const Sub6 &s6, ! const Sub7 &s7) { return Dispatch_t::makeRead(a, s1, s2, s3, s4, s5, s6, s7, Combine_t()); } + + inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t& li, + const Sub1 &s1, const Sub2 &s2, + const Sub3 &s3, const Sub4 &s4, + const Sub5 &s5, const Sub6 &s6, + const Sub7 &s7) + { + return Dispatch_t::makeRead(a, li, s1, s2, s3, s4, s5, s6, s7, + Combine_t()); + } }; template *************** struct View7, i *** 1260,1265 **** --- 1764,1770 ---- // Convenience typedef for the thing we're taking a view of. typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // The return types. *************** struct View7, i *** 1280,1287 **** } inline static ! ReadType_t makeRead(const Subject_t &a, int s1, int s2, int s3, ! int s4, int s5, int s6, int s7) { #if POOMA_BOUNDS_CHECK PInsist(contains(a.domain(), Loc<7>(s1, s2, s3, s4, s5, s6, s7)), --- 1785,1794 ---- } inline static ! ReadType_t makeRead(const Subject_t &a, ! int s1, int s2, int s3, ! int s4, int s5, int s6, ! int s7) { #if POOMA_BOUNDS_CHECK PInsist(contains(a.domain(), Loc<7>(s1, s2, s3, s4, s5, s6, s7)), *************** struct View7, i *** 1289,1294 **** --- 1796,1815 ---- #endif return a.engine().read(s1, s2, s3, s4, s5, s6, s7); } + + inline static + ReadType_t makeRead(const Subject_t &a, + const LoopInvariant_t& li, + int s1, int s2, int s3, + int s4, int s5, int s6, + int s7) + { + #if POOMA_BOUNDS_CHECK + PInsist(contains(a.domain(), Loc<7>(s1, s2, s3, s4, s5, s6, s7)), + "Array view bounds error."); + #endif + return a.engine().read(li, s1, s2, s3, s4, s5, s6, s7); + } }; //----------------------------------------------------------------------------- *************** struct ComponentView Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // Deduce the template parameters for the output type. *************** struct AltComponentView Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; // Deduce the template parameters for the output type. *************** public: *** 1430,1435 **** --- 1953,1959 ---- typedef typename Engine_t::ElementRef_t ElementRef_t; typedef typename Engine_t::Domain_t Domain_t; typedef typename Engine_t::Layout_t Layout_t; + typedef typename Engine_t::LoopInvariant_t LoopInvariant_t; enum { dimensions = Engine_t::dimensions }; enum { rank = Engine_t::dimensions }; *************** public: *** 1825,1832 **** { return engine_m.layout(); } ! //--------------------------------------------------------------------------- // View-creation operations. These operator() functions take one or more // sub-domains, which combine to form a domain with dimensionality identical // to the rank of the array. Views based on up to 7 subdomains are supported. --- 2349,2362 ---- { return engine_m.layout(); } ! //--------------------------------------------------------------------------- + // Loop invariants. + + inline const + LoopInvariant_t loopInvariant() const { return engine_m.loopInvariant(); } + + //--------------------------------------------------------------------------- // View-creation operations. These operator() functions take one or more // sub-domains, which combine to form a domain with dimensionality identical // to the rank of the array. Views based on up to 7 subdomains are supported. *************** public: *** 1905,1910 **** --- 2435,2510 ---- return Ret_t::makeRead(*this, s1, s2, s3, s4, s5, s6, s7); } + typename AltView0::ReadType_t + read(const LoopInvariant_t& li) const + { + typedef View0 Ret_t; + return Ret_t::makeRead(*this, li); + } + + template + inline typename View1::ReadType_t + read(const LoopInvariant_t& li, const Sub1 &s1) const + { + typedef View1 Ret_t; + return Ret_t::makeRead(*this, li, s1); + } + + template + inline typename View2::ReadType_t + read(const LoopInvariant_t& li, const Sub1 &s1, const Sub2 &s2) const + { + typedef View2 Ret_t; + return Ret_t::makeRead(*this, li, s1, s2); + } + + template + inline typename View3::ReadType_t + read(const LoopInvariant_t& li, const Sub1 &s1, const Sub2 &s2, const Sub3 &s3) const + { + typedef View3 Ret_t; + return Ret_t::makeRead(*this, li, s1, s2, s3); + } + + template + inline typename View4::ReadType_t + read(const LoopInvariant_t& li, const Sub1 &s1, const Sub2 &s2, const Sub3 &s3, + const Sub4 &s4) const + { + typedef View4 Ret_t; + return Ret_t::makeRead(*this, li, s1, s2, s3, s4); + } + + template + inline typename View5::ReadType_t + read(const LoopInvariant_t& li, const Sub1 &s1, const Sub2 &s2, const Sub3 &s3, + const Sub4 &s4, const Sub5 &s5) const + { + typedef View5 Ret_t; + return Ret_t::makeRead(*this, li, s1, s2, s3, s4, s5); + } + + template + inline typename View6::ReadType_t + read(const LoopInvariant_t& li, const Sub1 &s1, const Sub2 &s2, const Sub3 &s3, + const Sub4 &s4, const Sub5 &s5, const Sub6 &s6) const + { + typedef View6 Ret_t; + return Ret_t::makeRead(*this, li, s1, s2, s3, s4, s5, s6); + } + + template + inline typename + View7::ReadType_t + read(const LoopInvariant_t& li, const Sub1 &s1, const Sub2 &s2, const Sub3 &s3, + const Sub4 &s4, const Sub5 &s5, const Sub6 &s6, const Sub7 &s7) const + { + typedef View7 Ret_t; + return Ret_t::makeRead(*this, li, s1, s2, s3, s4, s5, s6, s7); + } + typename AltView0::Type_t operator()() const { *************** public: *** 1927,1933 **** typedef View2 Ret_t; return Ret_t::make(*this, s1, s2); } ! template inline typename View3::Type_t operator()(const Sub1 &s1, const Sub2 &s2, const Sub3 &s3) const --- 2527,2533 ---- typedef View2 Ret_t; return Ret_t::make(*this, s1, s2); } ! template inline typename View3::Type_t operator()(const Sub1 &s1, const Sub2 &s2, const Sub3 &s3) const *************** public: *** 1976,1981 **** --- 2576,2640 ---- return Ret_t::make(*this, s1, s2, s3, s4, s5, s6, s7); } + // HERE + // FIXME: Convert other dimensions' versions. + // When we use LoopInvariant_t, we are guaranteed to have integral + // indices, not general indices. + inline ElementRef_t + operator()(const LoopInvariant_t &li) const + { + return engine()(li); + } + + inline ElementRef_t + operator()(const LoopInvariant_t &li, + int s1) const + { + return engine()(li, s1); + } + + inline ElementRef_t + operator()(const LoopInvariant_t &li, + int s1, int s2) const + { + return engine()(li, s1, s2); + } + + inline ElementRef_t + operator()(const LoopInvariant_t &li, + int s1, int s2, int s3) const + { + return engine()(li, s1, s2, s3); + } + + inline ElementRef_t + operator()(const LoopInvariant_t &li, + int s1, int s2, int s3, int s4) const + { + return engine()(li, s1, s2, s3, s4); + } + + inline ElementRef_t + operator()(const LoopInvariant_t &li, + int s1, int s2, int s3, int s4, int s5) const + { + return engine()(li, s1, s2, s3, s4, s5); + } + + inline ElementRef_t + operator()(const LoopInvariant_t &li, + int s1, int s2, int s3, int s4, int s5, int s6) const + { + return engine()(li, s1, s2, s3, s4, s5, s6); + } + + inline ElementRef_t + operator()(const LoopInvariant_t &li, + int s1, int s2, int s3, int s4, int s5, int s6, int s7) const + { + return engine()(li, s1, s2, s3, s4, s5, s6, s7); + } + //--------------------------------------------------------------------------- // Component forwarding function. This is used when Element_t has components, // as is the case for vectors, tensors, or arrays. A Forwarding engine *************** private: *** 2225,2236 **** template struct LeafFunctor, DomainFunctorTag> { typedef typename Engine::Domain_t Type_t; ! static Type_t apply(const Array &a, ! const DomainFunctorTag &) { return a.domain(); } }; //----------------------------------------------------------------------------- --- 2884,2906 ---- template struct LeafFunctor, DomainFunctorTag> { + typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef DomainFunctorTag Tag_t; typedef typename Engine::Domain_t Type_t; ! ! static Type_t apply(const Subject_t &a, ! const Tag_t &) { return a.domain(); } + + static Type_t apply(const Subject_t &a, + const LoopInvariant_t &li, + const Tag_t &t) + { + return apply(a,t); + } }; //----------------------------------------------------------------------------- *************** struct LeafFunctor struct LeafFunctor, ViewFunctorTag > { ! typedef typename View1, Domain>::Type_t Type_t; ! inline static Type_t apply(const Array &a, ! const ViewFunctorTag &t) ! { ! typedef View1, Domain> Ret_t; ! return Ret_t::make(a, t.domain_m + a.firsts()); ! } }; //----------------------------------------------------------------------------- --- 2913,2939 ---- template struct LeafFunctor, ViewFunctorTag > { ! typedef Array Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef ViewFunctorTag Tag_t; ! typedef typename View1::Type_t Type_t; ! ! inline static ! Type_t apply(const Subject_t &a, ! const Tag_t &t) ! { ! typedef View1, Domain> Ret_t; ! return Ret_t::make(a, t.domain_m + a.firsts()); ! } ! ! inline static ! Type_t apply(const Subject_t &a, ! const LoopInvariant_t &, ! const Tag_t &t) ! { ! // HERE FIXME: Is this correct? ! return apply(a,t); ! } }; //----------------------------------------------------------------------------- *************** struct LeafFunctor struct LeafFunctor, EvalLeaf > { ! typedef typename Array::Element_t Type_t; inline static ! Type_t apply(const Array &a, const EvalLeaf &t) { return t.eval(a.engine()); } }; //----------------------------------------------------------------------------- // EngineView functor acting on array. The functor is applied to the contained // engine and the result is packed back inside the array. --- 2944,2970 ---- template struct LeafFunctor, EvalLeaf > { ! typedef Array Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef EvalLeaf Tag_t; ! typedef typename Subject_t::Element_t Type_t; ! inline static ! Type_t apply(const Subject_t &a, const Tag_t &t) { return t.eval(a.engine()); } + + inline static + Type_t apply(const Subject_t &a, + const LoopInvariant_t &li, + const Tag_t &t) + { + return t.eval(a.engine(), li); + } }; + //----------------------------------------------------------------------------- // EngineView functor acting on array. The functor is applied to the contained // engine and the result is packed back inside the array. *************** struct LeafFunctor struct LeafFunctor, EngineView > { + typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef EngineView Tag_t; typedef LeafFunctor, EngineView > LeafFunctor_t; typedef typename LeafFunctor_t::Type_t NewEngine_t; *************** struct LeafFunctor, Eng *** 2283,2293 **** typedef Array Type_t; inline static ! Type_t apply(const Array &array, ! const EngineView &tag) { return Type_t(LeafFunctor_t::apply(array.engine(), tag)); } }; //----------------------------------------------------------------------------- --- 2983,3001 ---- typedef Array Type_t; inline static ! Type_t apply(const Subject_t &array, ! const Tag_t &tag) { return Type_t(LeafFunctor_t::apply(array.engine(), tag)); } + + inline static + Type_t apply(const Subject_t &array, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return Type_t(LeafFunctor_t::apply(array.engine(), li, tag)); + } }; //----------------------------------------------------------------------------- *************** struct LeafFunctor, Eng *** 2298,2312 **** template struct LeafFunctor, ExpressionApply > { typedef LeafFunctor, ExpressionApply > LeafFunctor_t; typedef int Type_t; inline static ! Type_t apply(const Array &array, ! const ExpressionApply &tag) { return LeafFunctor_t::apply(array.engine(), tag); } }; //---------------------------------------------------------------------- --- 3006,3031 ---- template struct LeafFunctor, ExpressionApply > { + typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef ExpressionApply Tag_t; typedef LeafFunctor, ExpressionApply > LeafFunctor_t; typedef int Type_t; inline static ! Type_t apply(const Subject_t &array, ! const Tag_t &tag) { return LeafFunctor_t::apply(array.engine(), tag); } + + inline static + Type_t apply(const Subject_t &array, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return LeafFunctor_t::apply(array.engine(), li, tag); + } }; //---------------------------------------------------------------------- *************** struct LeafFunctor, Exp *** 2322,2333 **** template struct LeafFunctor, ConformTag > { typedef bool Type_t; ! static Type_t apply(const Array &array, ! const ConformTag &ct) { return conforms(array.domain(), ct); } }; // Now the case where the rank of the Array is not the same --- 3041,3065 ---- template struct LeafFunctor, ConformTag > { + typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef ConformTag Tag_t; typedef bool Type_t; ! ! inline static ! Type_t apply(const Subject_t &array, ! const Tag_t &ct) { return conforms(array.domain(), ct); } + + inline static + Type_t apply(const Subject_t &array, + const LoopInvariant_t &, + const Tag_t &ct) + { + return apply(array, ct); + } }; // Now the case where the rank of the Array is not the same *************** struct LeafFunctor struct LeafFunctor, ConformTag > { typedef bool Type_t; ! static Type_t apply(const Array &, ! const ConformTag &) { return false; } }; //---------------------------------------------------------------------- --- 3068,3092 ---- template struct LeafFunctor, ConformTag > { + typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef ConformTag Tag_t; typedef bool Type_t; ! ! inline static ! Type_t apply(const Subject_t &, ! const Tag_t &) { return false; } + + inline static + Type_t apply(const Subject_t &s, + const LoopInvariant_t &, + const Tag_t &t) + { + return apply(s,t); + } }; //---------------------------------------------------------------------- *************** struct LeafFunctor struct LeafFunctor, NotifyPreReadTag> { typedef bool Type_t; ! static Type_t apply(const Array &a, ! const NotifyPreReadTag &) { return true; } }; //----------------------------------------------------------------------------- --- 3097,3121 ---- template struct LeafFunctor, NotifyPreReadTag> { + typedef Array Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef NotifyPreReadTag Tag_t; typedef bool Type_t; ! ! inline static ! Type_t apply(const Subject_t &a, ! const Tag_t &) { return true; } + + inline static + Type_t apply(const Subject_t &s, + const LoopInvariant_t &, + const Tag_t &t) + { + return apply(s,t); + } }; //----------------------------------------------------------------------------- *************** struct LeafFunctor struct LeafFunctor, EngineFunctorTag > { ! typedef typename Array::Engine_t Engine_t; typedef typename EngineFunctor::Type_t Type_t; inline static ! Type_t apply(const Array &array, const EngineFunctorTag &tag) { return EngineFunctor::apply(array.engine(), tag.tag()); } }; --- 3125,3148 ---- template struct LeafFunctor, EngineFunctorTag > { ! typedef Array Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef EngineFunctorTag Tag_t; ! typedef typename Subject_t::Engine_t Engine_t; typedef typename EngineFunctor::Type_t Type_t; + inline static ! Type_t apply(const Subject_t &array, const Tag_t &tag) { return EngineFunctor::apply(array.engine(), tag.tag()); + } + + inline static + Type_t apply(const Subject_t &array, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return EngineFunctor::apply(array.engine(), li, tag.tag()); } }; Index: src/Array/PrintArray.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Array/PrintArray.h,v retrieving revision 1.21 diff -c -p -r1.21 PrintArray.h *** src/Array/PrintArray.h 2001/03/29 17:09:25 1.21 --- src/Array/PrintArray.h 2001/11/05 19:28:26 *************** class PrintArray; *** 120,126 **** // PRINTING ARRAY OBJECTS WITH A PrintArray: // ----------------------------------------- // PrintArray is not templated, so that you can reuse the same formatter ! // for different array's. It has one templated member function 'print': // // template // void print(S &s, const A &a) const --- 120,126 ---- // PRINTING ARRAY OBJECTS WITH A PrintArray: // ----------------------------------------- // PrintArray is not templated, so that you can reuse the same formatter ! // for different arrays. It has one templated member function 'print': // // template // void print(S &s, const A &a) const *************** PerformPrintArray::pri *** 412,422 **** Domain_t domain(d); ! // create an iterator over the domain of the array Iterator_t griditer = domain.begin(); Iterator_t enditer = domain.end(); // For a domain of total extent 1 (single Array element), treat specially: if (domain.size() == 1) { --- 412,425 ---- Domain_t domain(d); ! // Create an iterator over the domain of the array. Iterator_t griditer = domain.begin(); Iterator_t enditer = domain.end(); + // Obtain array data members that are invariant during array traversal. + typedef typename A::LoopInvariant_t LoopInvariant_t; + // For a domain of total extent 1 (single Array element), treat specially: if (domain.size() == 1) { *************** PerformPrintArray::pri *** 470,475 **** --- 473,479 ---- // loop over the elements, printing out values as necessary + const LoopInvariant_t li = a.loopInvariant(); int i, printed = 0; while (griditer != enditer) { *************** PerformPrintArray::pri *** 495,501 **** s.setf(std::ios::scientific); s.precision(p.dataPrecision()); s.width(p.dataWidth()); ! s << a.read(*griditer); // increment iterator and counter ++griditer; --- 499,505 ---- s.setf(std::ios::scientific); s.precision(p.dataPrecision()); s.width(p.dataWidth()); ! s << a.read(li, *griditer); // increment iterator and counter ++griditer; Index: src/Array/tests/ExpressionTest.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Array/tests/ExpressionTest.h,v retrieving revision 1.3 diff -c -p -r1.3 ExpressionTest.h *** src/Array/tests/ExpressionTest.h 2000/07/20 15:36:24 1.3 --- src/Array/tests/ExpressionTest.h 2001/11/05 19:28:26 *************** public: *** 223,231 **** template inline typename A::Element_t ! operator()(const A& x, int i) const { ! return ( x.read(i-1) + x.read(i) ); } inline int lowerExtent(int) const { return 1; } --- 223,233 ---- template inline typename A::Element_t ! operator()(const A& x, ! const typename A::LoopInvariant_t &li, ! int i) const { ! return ( x.read(li, i-1) + x.read(li, i) ); } inline int lowerExtent(int) const { return 1; } Index: src/Array/tests/array_test19.cpp =================================================================== RCS file: /home/pooma/Repository/r2/src/Array/tests/array_test19.cpp,v retrieving revision 1.20 diff -c -p -r1.20 array_test19.cpp *** src/Array/tests/array_test19.cpp 2001/10/05 01:29:02 1.20 --- src/Array/tests/array_test19.cpp 2001/11/05 19:28:26 *************** public: *** 108,116 **** template inline typename A::Element_t ! operator()(const A& x, int i) const { ! return ( x(i-1) + x(i) + x(i+1) ); } inline int lowerExtent(int) const { return 1; } --- 108,116 ---- template inline typename A::Element_t ! operator()(const A& x, const typename A::LoopInvariant_t& li, int i) const { ! return ( x.read(li,i-1) + x.read(li,i) + x.read(li,i+1) ); } inline int lowerExtent(int) const { return 1; } *************** public: *** 137,145 **** template inline typename NormResult::Type_t ! operator()(const A& x, int i) const { ! return ( 0.5*(dot(x(i-1), x(i)) + dot(x(i), x(i+1))) ); } inline int lowerExtent(int) const { return 1; } --- 137,145 ---- template inline typename NormResult::Type_t ! operator()(const A& x, const typename A::LoopInvariant_t& li, int i) const { ! return ( 0.5*(dot(x.read(li,i-1), x.read(li,i)) + dot(x.read(li,i), x.read(li,i+1))) ); } inline int lowerExtent(int) const { return 1; } *************** public: *** 167,178 **** template inline typename A::Element_t ! operator()(const A& x, int i, int j) const { return ( (1.0/15.0) * ! ( x(i+1,j+1) + 2*x(i+1,j ) + 3*x(i+1,j-1) + ! 3*x(i ,j+1) + x(i ,j ) + 2*x(i ,j-1) + ! 4*x(i-1,j+1) + 3*x(i-1,j ) + 5*x(i-1,j-1) ) ); } inline int lowerExtent(int) const { return 1; } --- 167,179 ---- template inline typename A::Element_t ! operator()(const A& x, const typename A::LoopInvariant_t& li, ! int i, int j) const { return ( (1.0/15.0) * ! ( x.read(li, i+1,j+1) + 2*x.read(li, i+1,j ) + 3*x.read(li, i+1,j-1) + ! 3*x.read(li, i ,j+1) + x.read(li, i ,j ) + 2*x.read(li, i ,j-1) + ! 4*x.read(li, i-1,j+1) + 3*x.read(li, i-1,j ) + 5*x.read(li, i-1,j-1) ) ); } inline int lowerExtent(int) const { return 1; } *************** public: *** 189,200 **** template inline typename A::Element_t ! operator()(const A& x, int i, int j) const { return ( (1.0/9.0) * ! ( x(i+1,j+1) + x(i+1,j ) + x(i+1,j-1) + ! x(i ,j+1) + x(i ,j ) + x(i ,j-1) + ! x(i-1,j+1) + x(i-1,j ) + x(i-1,j-1) ) ); } inline int lowerExtent(int) const { return 1; } --- 190,202 ---- template inline typename A::Element_t ! operator()(const A& x, const typename A::LoopInvariant_t& li, ! int i, int j) const { return ( (1.0/9.0) * ! ( x.read(li, i+1,j+1) + x.read(li, i+1,j ) + x.read(li, i+1,j-1) + ! x.read(li, i ,j+1) + x.read(li, i ,j ) + x.read(li, i ,j-1) + ! x.read(li, i-1,j+1) + x.read(li, i-1,j ) + x.read(li, i-1,j-1) ) ); } inline int lowerExtent(int) const { return 1; } *************** public: *** 213,223 **** template inline complex ! operator()(const A& x, int i, int j) const { return ( (1.0/3.0) * ! ( x(i ,j ) + alpha_m * x(i ,j-1) + ! alphaConj_m * x(i-1,j ) + x(i-1,j-1) ) ); } inline int lowerExtent(int) const { return 1; } --- 215,226 ---- template inline complex ! operator()(const A& x, const typename A::LoopInvariant_t& li, ! int i, int j) const { return ( (1.0/3.0) * ! ( x.read(li, i ,j ) + alpha_m * x.read(li, i ,j-1) + ! alphaConj_m * x.read(li, i-1,j ) + x.read(li, i-1,j-1) ) ); } inline int lowerExtent(int) const { return 1; } *************** public: *** 238,248 **** template inline complex ! operator()(const A& x, int i, int j) const { return ( (1.0/3.0) * ! ( x.read(i ,j ) + alpha_m * x.read(i ,j+1) + ! alphaConj_m * x.read(i+1,j ) + x.read(i+1,j+1) ) ); } inline int lowerExtent(int) const { return 0; } --- 241,252 ---- template inline complex ! operator()(const A& x, const typename A::LoopInvariant_t& li, ! int i, int j) const { return ( (1.0/3.0) * ! ( x.read(li, i ,j ) + alpha_m * x.read(li, i ,j+1) + ! alphaConj_m * x.read(li, i+1,j ) + x.read(li, i+1,j+1) ) ); } inline int lowerExtent(int) const { return 0; } Index: src/Array/tests/array_test23.cpp =================================================================== RCS file: /home/pooma/Repository/r2/src/Array/tests/array_test23.cpp,v retrieving revision 1.5 diff -c -p -r1.5 array_test23.cpp *** src/Array/tests/array_test23.cpp 2000/07/04 05:06:54 1.5 --- src/Array/tests/array_test23.cpp 2001/11/05 19:28:26 *************** public: *** 61,72 **** template inline typename A::Element_t ! operator()(const A& x, int i, int j) const { return ( (1.0/15.0) * ! ( x(i+1,j+1) + 2*x(i+1,j ) + 3*x(i+1,j-1) + ! 3*x(i ,j+1) + x(i ,j ) + 2*x(i ,j-1) + ! 4*x(i-1,j+1) + 3*x(i-1,j ) + 5*x(i-1,j-1) ) ); } inline int lowerExtent(int) const { return 1; } --- 61,73 ---- template inline typename A::Element_t ! operator()(const A& x, const typename A::LoopInvariant_t &li, ! int i, int j) const { return ( (1.0/15.0) * ! ( x.read(li,i+1,j+1) + 2*x.read(li,i+1,j ) + 3*x.read(li,i+1,j-1) + ! 3*x.read(li,i ,j+1) + x.read(li,i ,j ) + 2*x.read(li,i ,j-1) + ! 4*x.read(li,i-1,j+1) + 3*x.read(li,i-1,j ) + 5*x.read(li,i-1,j-1) ) ); } inline int lowerExtent(int) const { return 1; } Index: src/DynamicArray/DynamicArray.h =================================================================== RCS file: /home/pooma/Repository/r2/src/DynamicArray/DynamicArray.h,v retrieving revision 1.30 diff -c -p -r1.30 DynamicArray.h *** src/DynamicArray/DynamicArray.h 2001/04/30 18:26:34 1.30 --- src/DynamicArray/DynamicArray.h 2001/11/05 19:28:26 *************** struct LeafFunctor, E *** 882,895 **** { typedef typename DynamicArray::Engine_t Engine_t; typedef typename EngineFunctor::Type_t Type_t; inline static ! Type_t apply(const DynamicArray &array, const EngineFunctorTag &tag) { return EngineFunctor::apply(array.engine(), tag.tag()); } - }; #endif --- 882,905 ---- { typedef typename DynamicArray::Engine_t Engine_t; typedef typename EngineFunctor::Type_t Type_t; + typedef DynamicArray Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + inline static ! Type_t apply(const Subject_t &array, const EngineFunctorTag &tag) { return EngineFunctor::apply(array.engine(), tag.tag()); } + inline static + Type_t apply(const Subject_t &array, + const LoopInvariant_t &li, + const EngineFunctorTag &tag) + { + return EngineFunctor::apply(array.engine(), li, tag.tag()); + } + }; #endif Index: src/Engine/BrickBase.cpp =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/BrickBase.cpp,v retrieving revision 1.9 diff -c -p -r1.9 BrickBase.cpp *** src/Engine/BrickBase.cpp 2001/08/30 01:15:01 1.9 --- src/Engine/BrickBase.cpp 2001/11/05 19:28:26 *************** BrickBase::BrickBase(const Domain_t *** 77,94 **** { // Compute the strides and offset. ! strides_m[0] = 1; firsts_m[0] = domain()[0].first(); off_m = -firsts_m[0]; for (int d = 1; d < Dim; ++d) { firsts_m[d] = domain()[d].first(); ! strides_m[d] = strides_m[d-1]*domain()[d-1].length(); ! off_m -= domain()[d].first()*strides_m[d]; } ! for (int d = 0; d < Dim; ++d) ostrides_m[d] = strides_m[d]; } //----------------------------------------------------------------------------- --- 77,94 ---- { // Compute the strides and offset. ! invariant_m.strides()[0] = 1; firsts_m[0] = domain()[0].first(); off_m = -firsts_m[0]; for (int d = 1; d < Dim; ++d) { firsts_m[d] = domain()[d].first(); ! invariant_m.strides()[d] = invariant_m.strides()[d-1]*domain()[d-1].length(); ! off_m -= domain()[d].first()*invariant_m.strides()[d]; } ! for (int d = 0; d < Dim; ++d) ostrides_m[d] = invariant_m.strides()[d]; } //----------------------------------------------------------------------------- *************** BrickBase::BrickBase(const Node::BrickBase(const Layout_t *** 133,150 **** { // Compute the strides and offset. ! strides_m[0] = 1; firsts_m[0] = domain()[0].first(); off_m = -firsts_m[0]; for (int d = 1; d < Dim; ++d) { firsts_m[d] = domain()[d].first(); ! strides_m[d] = strides_m[d-1]*domain()[d-1].length(); ! off_m -= domain()[d].first()*strides_m[d]; } ! for (int d = 0; d < Dim; ++d) ostrides_m[d] = strides_m[d]; } //----------------------------------------------------------------------------- --- 133,150 ---- { // Compute the strides and offset. ! invariant_m.strides()[0] = 1; firsts_m[0] = domain()[0].first(); off_m = -firsts_m[0]; for (int d = 1; d < Dim; ++d) { firsts_m[d] = domain()[d].first(); ! invariant_m.strides()[d] = invariant_m.strides()[d-1]*domain()[d-1].length(); ! off_m -= domain()[d].first()*invariant_m.strides()[d]; } ! for (int d = 0; d < Dim; ++d) ostrides_m[d] = invariant_m.strides()[d]; } //----------------------------------------------------------------------------- *************** sliceInit(const This_t &bvbase, const Ra *** 275,285 **** for (int d = 0; d < Dim; ++d) { domain_m[d] = Interval<1>(domain[d].length()); ! strides_m[d] = bvbase.ostrides_m[d] * domain[d].stride(); baseOffset_m += domain[d].first() * bvbase.ostrides_m[d]; } ! for (int d = 0; d < Dim; ++d) ostrides_m[d] = strides_m[d]; } //----------------------------------------------------------------------------- --- 275,285 ---- for (int d = 0; d < Dim; ++d) { domain_m[d] = Interval<1>(domain[d].length()); ! invariant_m.strides()[d] = bvbase.ostrides_m[d] * domain[d].stride(); baseOffset_m += domain[d].first() * bvbase.ostrides_m[d]; } ! for (int d = 0; d < Dim; ++d) ostrides_m[d] = invariant_m.strides()[d]; } //----------------------------------------------------------------------------- Index: src/Engine/BrickBase.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/BrickBase.h,v retrieving revision 1.12 diff -c -p -r1.12 BrickBase.h *** src/Engine/BrickBase.h 2001/08/30 01:15:02 1.12 --- src/Engine/BrickBase.h 2001/11/05 19:28:26 *************** class BrickBase *** 105,111 **** public: //============================================================ ! // Exported typedefs and constants //============================================================ typedef Interval Domain_t; --- 105,111 ---- public: //============================================================ ! // Exported typedefs, constants, and classes //============================================================ typedef Interval Domain_t; *************** public: *** 117,122 **** --- 117,143 ---- enum { brick = true }; enum { zeroBased = false }; + // Values that do not change during the evaluation of a single + // data parallel statement. + + class LoopInvariant_t { + public: + + inline int *strides() { return strides_m; } + inline int& strides(const int i) { return strides_m[i]; } + inline const int *strides() const { return strides_m; } + inline int strides(const int i) const { return strides_m[i]; } + + private: + + // Strides through actual data block when stepping in different directions. + // We keep two copies - strides_m is used by the offset calculations. + // If we are compressible, then when compressed, these will all be + // set to zero. + + int strides_m[Dim]; + }; + //============================================================ // Constructors and Factory Methods //============================================================ *************** public: *** 165,173 **** inline const Layout_t &layout() const { return layout_m; } // Return the strides array. ! inline const int *strides() const { return &strides_m[0]; } // Return the true strides array. --- 186,198 ---- inline const Layout_t &layout() const { return layout_m; } + // Return the loop invariant object. + + inline const LoopInvariant_t loopInvariant() const { return invariant_m; } + // Return the strides array. ! inline const int *strides() const { return invariant_m.strides(); } // Return the true strides array. *************** public: *** 191,197 **** // offset0 treats the input domain as a zero-based domain giving // offsets from the beginning in each dimension, rather than as // points in the Brick's underlying domain. offsetC is similar, ! // except that it multiplies the first offset by strides_m[0]. // This is only for use in CompressibleBrick. template --- 216,222 ---- // offset0 treats the input domain as a zero-based domain giving // offsets from the beginning in each dimension, rather than as // points in the Brick's underlying domain. offsetC is similar, ! // except that it multiplies the first offset by invariant_m.strides(0). // This is only for use in CompressibleBrick. template *************** public: *** 203,208 **** --- 228,242 ---- template int offsetC(const Domain &) const; + template + int offset(const LoopInvariant_t &, const Domain &) const; + + template + int offset0(const LoopInvariant_t &, const Domain &) const; + + template + int offsetC(const LoopInvariant_t &, const Domain &) const; + // The "int" versions do not assert that their dimensionality is // correct. The inheriting class should make these checks. // These are fairly short and there are a lot of them so I define *************** public: *** 218,296 **** { return off_m + i0; } inline int offset(int i0, int i1) const ! { return off_m + i0 + i1*strides_m[1]; } inline int offset(int i0, int i1, int i2) const ! { return off_m + i0 + i1*strides_m[1] + i2*strides_m[2]; } inline int offset(int i0, int i1, int i2, int i3) const ! { return off_m + i0 + i1*strides_m[1] + i2*strides_m[2] + i3*strides_m[3]; } inline int offset(int i0, int i1, int i2, int i3, int i4) const ! { return off_m + i0 + i1*strides_m[1] + i2*strides_m[2] + i3*strides_m[3] ! + i4*strides_m[4]; } inline int offset(int i0, int i1, int i2, int i3, int i4, int i5) const ! { return off_m + i0 + i1*strides_m[1] + i2*strides_m[2] + i3*strides_m[3] ! + i4*strides_m[4] + i5*strides_m[5]; } inline int offset(int i0, int i1, int i2, int i3, int i4, int i5, int i6) const ! { return off_m + i0 + i1*strides_m[1] + i2*strides_m[2] + i3*strides_m[3] ! + i4*strides_m[4] + i5*strides_m[5] + i6*strides_m[6]; } inline int offset0(int i0) const { return i0; } inline int offset0(int i0, int i1) const ! { return i0 + i1*strides_m[1]; } inline int offset0(int i0, int i1, int i2) const ! { return i0 + i1*strides_m[1] + i2*strides_m[2]; } inline int offset0(int i0, int i1, int i2, int i3) const ! { return i0 + i1*strides_m[1] + i2*strides_m[2] + i3*strides_m[3]; } inline int offset0(int i0, int i1, int i2, int i3, int i4) const ! { return i0 + i1*strides_m[1] + i2*strides_m[2] + i3*strides_m[3] ! + i4*strides_m[4]; } inline int offset0(int i0, int i1, int i2, int i3, int i4, int i5) const ! { return i0 + i1*strides_m[1] + i2*strides_m[2] + i3*strides_m[3] ! + i4*strides_m[4] + i5*strides_m[5]; } inline int offset0(int i0, int i1, int i2, int i3, int i4, int i5, int i6) const ! { return i0 + i1*strides_m[1] + i2*strides_m[2] + i3*strides_m[3] ! + i4*strides_m[4] + i5*strides_m[5] + i6*strides_m[6]; } inline int offsetC(int i0) const ! { return i0*strides_m[0]; } inline int offsetC(int i0, int i1) const ! { return i0*strides_m[0] + i1*strides_m[1]; } inline int offsetC(int i0, int i1, int i2) const ! { return i0*strides_m[0] + i1*strides_m[1] + i2*strides_m[2]; } inline int offsetC(int i0, int i1, int i2, int i3) const ! { return i0*strides_m[0] + i1*strides_m[1] + i2*strides_m[2] ! + i3*strides_m[3]; } inline int offsetC(int i0, int i1, int i2, int i3, int i4) const ! { return i0*strides_m[0] + i1*strides_m[1] + i2*strides_m[2] ! + i3*strides_m[3] + i4*strides_m[4]; } inline int offsetC(int i0, int i1, int i2, int i3, int i4, int i5) const ! { return i0*strides_m[0] + i1*strides_m[1] + i2*strides_m[2] ! + i3*strides_m[3] + i4*strides_m[4] + i5*strides_m[5]; } inline int offsetC(int i0, int i1, int i2, int i3, int i4, int i5, int i6) const ! { return i0*strides_m[0] + i1*strides_m[1] + i2*strides_m[2] ! + i3*strides_m[3] + i4*strides_m[4] + i5*strides_m[5] ! + i6*strides_m[6]; } ! protected: //============================================================ --- 252,413 ---- { return off_m + i0; } inline int offset(int i0, int i1) const ! { return off_m + i0 + i1*invariant_m.strides(1); } inline int offset(int i0, int i1, int i2) const ! { return off_m + i0 + i1*invariant_m.strides(1) + i2*invariant_m.strides(2); } inline int offset(int i0, int i1, int i2, int i3) const ! { return off_m + i0 + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) + i3*invariant_m.strides(3); } inline int offset(int i0, int i1, int i2, int i3, int i4) const ! { return off_m + i0 + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) + i3*invariant_m.strides(3) ! + i4*invariant_m.strides(4); } inline int offset(int i0, int i1, int i2, int i3, int i4, int i5) const ! { return off_m + i0 + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) + i3*invariant_m.strides(3) ! + i4*invariant_m.strides(4) + i5*invariant_m.strides(5); } inline int offset(int i0, int i1, int i2, int i3, int i4, int i5, int i6) + const + { return off_m + i0 + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) + i3*invariant_m.strides(3) + + i4*invariant_m.strides(4) + i5*invariant_m.strides(5) + i6*invariant_m.strides(6); } + + inline int offset(const LoopInvariant_t&) const + { return off_m; } + + inline int baseOffset(const LoopInvariant_t&) const + { return off_m; } + + inline int offset(const LoopInvariant_t&, int i0) const + { return off_m + i0; } + + inline int offset(const LoopInvariant_t& li, int i0, int i1) const + { return off_m + i0 + i1*li.strides(1); } + + inline int offset(const LoopInvariant_t& li, int i0, int i1, int i2) const + { return off_m + i0 + i1*li.strides(1) + i2*li.strides(2); } + + inline int offset(const LoopInvariant_t& li, int i0, int i1, int i2, int i3) const + { return off_m + i0 + i1*li.strides(1) + i2*li.strides(2) + i3*li.strides(3); } + + inline int offset(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4) const + { return off_m + i0 + i1*li.strides(1) + i2*li.strides(2) + i3*li.strides(3) + + i4*li.strides(4); } + + inline int offset(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5) const + { return off_m + i0 + i1*li.strides(1) + i2*li.strides(2) + i3*li.strides(3) + + i4*li.strides(4) + i5*li.strides(5); } + + inline int offset(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5, int i6) const ! { return off_m + i0 + i1*li.strides(1) + i2*li.strides(2) + i3*li.strides(3) ! + i4*li.strides(4) + i5*li.strides(5) + i6*li.strides(6); } inline int offset0(int i0) const { return i0; } inline int offset0(int i0, int i1) const ! { return i0 + i1*invariant_m.strides(1); } inline int offset0(int i0, int i1, int i2) const ! { return i0 + i1*invariant_m.strides(1) + i2*invariant_m.strides(2); } inline int offset0(int i0, int i1, int i2, int i3) const ! { return i0 + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) + i3*invariant_m.strides(3); } inline int offset0(int i0, int i1, int i2, int i3, int i4) const ! { return i0 + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) + i3*invariant_m.strides(3) ! + i4*invariant_m.strides(4); } inline int offset0(int i0, int i1, int i2, int i3, int i4, int i5) const ! { return i0 + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) + i3*invariant_m.strides(3) ! + i4*invariant_m.strides(4) + i5*invariant_m.strides(5); } inline int offset0(int i0, int i1, int i2, int i3, int i4, int i5, int i6) const ! { return i0 + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) + i3*invariant_m.strides(3) ! + i4*invariant_m.strides(4) + i5*invariant_m.strides(5) + i6*invariant_m.strides(6); } + inline int offset0(const LoopInvariant_t& li, int i0) const + { return i0; } + + inline int offset0(const LoopInvariant_t& li, int i0, int i1) const + { return i0 + i1*li.strides(1); } + + inline int offset0(const LoopInvariant_t& li, int i0, int i1, int i2) const + { return i0 + i1*li.strides(1) + i2*li.strides(2); } + + inline int offset0(const LoopInvariant_t& li, int i0, int i1, int i2, int i3) const + { return i0 + i1*li.strides(1) + i2*li.strides(2) + i3*li.strides(3); } + + inline int offset0(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4) const + { return i0 + i1*li.strides(1) + i2*li.strides(2) + i3*li.strides(3) + + i4*li.strides(4); } + + inline int offset0(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5) const + { return i0 + i1*li.strides(1) + i2*li.strides(2) + i3*li.strides(3) + + i4*li.strides(4) + i5*li.strides(5); } + + inline int offset0(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5, int i6) + const + { return i0 + i1*li.strides(1) + i2*li.strides(2) + i3*li.strides(3) + + i4*li.strides(4) + i5*li.strides(5) + i6*li.strides(6); } + inline int offsetC(int i0) const ! { return i0*invariant_m.strides(0); } inline int offsetC(int i0, int i1) const ! { return i0*invariant_m.strides(0) + i1*invariant_m.strides(1); } inline int offsetC(int i0, int i1, int i2) const ! { return i0*invariant_m.strides(0) + i1*invariant_m.strides(1) + i2*invariant_m.strides(2); } inline int offsetC(int i0, int i1, int i2, int i3) const ! { return i0*invariant_m.strides(0) + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) ! + i3*invariant_m.strides(3); } inline int offsetC(int i0, int i1, int i2, int i3, int i4) const ! { return i0*invariant_m.strides(0) + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) ! + i3*invariant_m.strides(3) + i4*invariant_m.strides(4); } inline int offsetC(int i0, int i1, int i2, int i3, int i4, int i5) const ! { return i0*invariant_m.strides(0) + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) ! + i3*invariant_m.strides(3) + i4*invariant_m.strides(4) + i5*invariant_m.strides(5); } inline int offsetC(int i0, int i1, int i2, int i3, int i4, int i5, int i6) const ! { return i0*invariant_m.strides(0) + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) ! + i3*invariant_m.strides(3) + i4*invariant_m.strides(4) + i5*invariant_m.strides(5) ! + i6*invariant_m.strides(6); } ! ! inline int offsetC(const LoopInvariant_t& li, int i0) const ! { return i0*li.strides(0); } ! ! inline int offsetC(const LoopInvariant_t& li, int i0, int i1) const ! { return i0*li.strides(0) + i1*li.strides(1); } ! ! inline int offsetC(const LoopInvariant_t& li, int i0, int i1, int i2) const ! { return i0*li.strides(0) + i1*li.strides(1) + i2*li.strides(2); } ! ! inline int offsetC(const LoopInvariant_t& li, int i0, int i1, int i2, int i3) const ! { return i0*li.strides(0) + i1*li.strides(1) + i2*li.strides(2) ! + i3*li.strides(3); } ! ! inline int offsetC(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4) const ! { return i0*li.strides(0) + i1*li.strides(1) + i2*li.strides(2) ! + i3*li.strides(3) + i4*li.strides(4); } ! ! inline int offsetC(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5) const ! { return i0*li.strides(0) + i1*li.strides(1) + i2*li.strides(2) ! + i3*li.strides(3) + i4*li.strides(4) + i5*li.strides(5); } ! ! inline int offsetC(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5, int i6) ! const ! { return i0*li.strides(0) + i1*li.strides(1) + i2*li.strides(2) ! + i3*li.strides(3) + i4*li.strides(4) + i5*li.strides(5) ! + i6*li.strides(6); } ! protected: //============================================================ *************** protected: *** 302,311 **** // on a noncompressible engine. void zeroStrides() ! { for (int d = 0; d < Dim; ++d) strides_m[d] = 0; } void restoreStrides() ! { for (int d = 0; d < Dim; ++d) strides_m[d] = ostrides_m[d]; } //============================================================ // Protected data --- 419,428 ---- // on a noncompressible engine. void zeroStrides() ! { for (int d = 0; d < Dim; ++d) invariant_m.strides(d) = 0; } void restoreStrides() ! { for (int d = 0; d < Dim; ++d) invariant_m.strides(d) = ostrides_m[d]; } //============================================================ // Protected data *************** protected: *** 315,327 **** Layout_t layout_m; ! // Strides through actual data block when stepping in different directions. ! // We keep two copies - strides_m is used by the offset calculations. ! // If we are compressible, then when compressed, these will all be ! // set to zero. ! ! int strides_m[Dim]; ! int ostrides_m[Dim]; // First index values (cached to optimize indexing). --- 432,442 ---- Layout_t layout_m; ! // Values that do not change during the evaluation of a single ! // data parallel statement. ! ! LoopInvariant_t invariant_m; ! int ostrides_m[Dim]; // First index values (cached to optimize indexing). *************** public: *** 420,425 **** --- 535,561 ---- typedef Interval Domain_t; typedef DomainLayout Layout_t; + // Values that do not change during the evaluation of a single + // data parallel statement. + + class LoopInvariant_t { + public: + + inline int *strides() { return strides_m; } + inline int& strides(const int i) { return strides_m[i]; } + inline const int *strides() const { return strides_m; } + inline int strides(const int i) const { return strides_m[i]; } + + private: + + // Strides through actual data block when stepping in different directions. + // We keep two copies - strides_m is used by the offset calculations. + // If we are compressible, then when compressed, these will all be + // set to zero. + + int strides_m[Dim]; + }; + //============================================================ // Constructors //============================================================ *************** public: *** 491,499 **** baseOffset_m(bvbase.baseOffset()) { DoubleSliceHelper:: ! init(domain_m, strides_m, baseOffset_m, bvbase, dom); ! for (int d = 0; d < Dim; ++d) ostrides_m[d] = strides_m[d]; } template --- 627,635 ---- baseOffset_m(bvbase.baseOffset()) { DoubleSliceHelper:: ! init(domain_m, invariant_m.strides(), baseOffset_m, bvbase, dom); ! for (int d = 0; d < Dim; ++d) ostrides_m[d] = invariant_m.strides(d); } template *************** public: *** 503,511 **** baseOffset_m(bvbase.baseOffset()) { DoubleSliceHelper:: ! init(domain_m, strides_m, baseOffset_m, bvbase, dom); ! for (int d = 0; d < Dim; ++d) ostrides_m[d] = strides_m[d]; } //============================================================ --- 639,647 ---- baseOffset_m(bvbase.baseOffset()) { DoubleSliceHelper:: ! init(domain_m, invariant_m.strides(), baseOffset_m, bvbase, dom); ! for (int d = 0; d < Dim; ++d) ostrides_m[d] = invariant_m.strides(d); } //============================================================ *************** public: *** 530,539 **** inline Layout_t layout() const { return Layout_t(domain_m); } ! // Return the strides array. ! inline const int *strides() const { return &strides_m[0]; } // Return the true strides array. inline const int *originalStrides() const { return &ostrides_m[0]; } --- 666,679 ---- inline Layout_t layout() const { return Layout_t(domain_m); } ! // Return the loop invariant object. ! inline const LoopInvariant_t loopInvariant() const { return invariant_m; } ! ! // Return the strides array. + inline const int *strides() const { return invariant_m.strides(); } + // Return the true strides array. inline const int *originalStrides() const { return &ostrides_m[0]; } *************** public: *** 552,588 **** int baseOffset() const { return baseOffset_m; } // Offset calculations ! template int offset(const Domain &) const; inline int offset(int i0) const ! { return i0*strides_m[0]; } inline int offset(int i0, int i1) const ! { return i0*strides_m[0] + i1*strides_m[1]; } inline int offset(int i0, int i1, int i2) const ! { return i0*strides_m[0] + i1*strides_m[1] + i2*strides_m[2]; } inline int offset(int i0, int i1, int i2, int i3) const ! { return i0*strides_m[0] + i1*strides_m[1] + i2*strides_m[2] ! + i3*strides_m[3]; } inline int offset(int i0, int i1, int i2, int i3, int i4) const ! { return i0*strides_m[0] + i1*strides_m[1] + i2*strides_m[2] ! + i3*strides_m[3] + i4*strides_m[4]; } inline int offset(int i0, int i1, int i2, int i3, int i4, int i5) const ! { return i0*strides_m[0] + i1*strides_m[1] + i2*strides_m[2] ! + i3*strides_m[3] + i4*strides_m[4] + i5*strides_m[5]; } inline int offset(int i0, int i1, int i2, int i3, int i4, int i5, int i6) const ! { return i0*strides_m[0] + i1*strides_m[1] + i2*strides_m[2] ! + i3*strides_m[3] + i4*strides_m[4] + i5*strides_m[5] ! + i6*strides_m[6]; } protected: //============================================================ --- 692,758 ---- int baseOffset() const { return baseOffset_m; } // Offset calculations ! template int offset(const Domain &) const; inline int offset(int i0) const ! { return i0*invariant_m.strides(0); } inline int offset(int i0, int i1) const ! { return i0*invariant_m.strides(0) + i1*invariant_m.strides(1); } inline int offset(int i0, int i1, int i2) const ! { return i0*invariant_m.strides(0) + i1*invariant_m.strides(1) + i2*invariant_m.strides(2); } inline int offset(int i0, int i1, int i2, int i3) const ! { return i0*invariant_m.strides(0) + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) ! + i3*invariant_m.strides(3); } inline int offset(int i0, int i1, int i2, int i3, int i4) const ! { return i0*invariant_m.strides(0) + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) ! + i3*invariant_m.strides(3) + i4*invariant_m.strides(4); } inline int offset(int i0, int i1, int i2, int i3, int i4, int i5) const ! { return i0*invariant_m.strides(0) + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) ! + i3*invariant_m.strides(3) + i4*invariant_m.strides(4) + i5*invariant_m.strides(5); } inline int offset(int i0, int i1, int i2, int i3, int i4, int i5, int i6) const ! { return i0*invariant_m.strides(0) + i1*invariant_m.strides(1) + i2*invariant_m.strides(2) ! + i3*invariant_m.strides(3) + i4*invariant_m.strides(4) + i5*invariant_m.strides(5) ! + i6*invariant_m.strides(6); } ! ! template ! int offset(const LoopInvariant_t& li, const Domain &) const; + inline int offset(const LoopInvariant_t& li, int i0) const + { return i0*li.strides(0); } + + inline int offset(const LoopInvariant_t& li, int i0, int i1) const + { return i0*li.strides(0) + i1*li.strides(1); } + + inline int offset(const LoopInvariant_t& li, int i0, int i1, int i2) const + { return i0*li.strides(0) + i1*li.strides(1) + i2*li.strides(2); } + + inline int offset(const LoopInvariant_t& li, int i0, int i1, int i2, int i3) const + { return i0*li.strides(0) + i1*li.strides(1) + i2*li.strides(2) + + i3*li.strides(3); } + + inline int offset(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4) const + { return i0*li.strides(0) + i1*li.strides(1) + i2*li.strides(2) + + i3*li.strides(3) + i4*li.strides(4); } + + inline int offset(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5) const + { return i0*li.strides(0) + i1*li.strides(1) + i2*li.strides(2) + + i3*li.strides(3) + i4*li.strides(4) + i5*li.strides(5); } + + inline int offset(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5, int i6) + const + { return i0*li.strides(0) + i1*li.strides(1) + i2*li.strides(2) + + i3*li.strides(3) + i4*li.strides(4) + i5*li.strides(5) + + i6*li.strides(6); } + protected: //============================================================ *************** protected: *** 594,603 **** // on a noncompressible engine. void zeroStrides() ! { for (int d = 0; d < Dim; ++d) strides_m[d] = 0; } void restoreStrides() ! { for (int d = 0; d < Dim; ++d) strides_m[d] = ostrides_m[d]; } //============================================================ // Utility functions --- 764,773 ---- // on a noncompressible engine. void zeroStrides() ! { for (int d = 0; d < Dim; ++d) invariant_m.strides(d) = 0; } void restoreStrides() ! { for (int d = 0; d < Dim; ++d) invariant_m.strides(d) = ostrides_m[d]; } //============================================================ // Utility functions *************** protected: *** 625,631 **** { PAssert(d < Dim); domain_m[d] = Interval<1>(domain[dt].length()); ! strides_m[d] = baseStrides[dt] * domain[dt].stride(); ++d; } --- 795,801 ---- { PAssert(d < Dim); domain_m[d] = Interval<1>(domain[dt].length()); ! invariant_m.strides(d) = baseStrides[dt] * domain[dt].stride(); ++d; } *************** protected: *** 635,641 **** PAssert(d == Dim); ! for (int d = 0; d < Dim; ++d) ostrides_m[d] = strides_m[d]; } void sliceInit(const This_t &, const Range &domain); --- 805,811 ---- PAssert(d == Dim); ! for (int d = 0; d < Dim; ++d) ostrides_m[d] = invariant_m.strides(d); } void sliceInit(const This_t &, const Range &domain); *************** protected: *** 645,652 **** for (int d = 0; d < Dim; ++d) { domain_m[d] = Interval<1>(domain[d].length()); ! strides_m[d] = bbase.originalStrides()[d] * domain[d].stride(); ! ostrides_m[d] = strides_m[d]; baseOffset_m += domain[d].first() * bbase.originalStrides()[d]; } } --- 815,822 ---- for (int d = 0; d < Dim; ++d) { domain_m[d] = Interval<1>(domain[d].length()); ! invariant_m.strides(d) = bbase.originalStrides()[d] * domain[d].stride(); ! ostrides_m[d] = invariant_m.strides(d); baseOffset_m += domain[d].first() * bbase.originalStrides()[d]; } } *************** protected: *** 663,675 **** Domain_t domain_m; ! // Strides through actual data block when stepping in each direction. ! // We keep two copies - strides_m is used by the offset calculations. ! // If we are compressible, then when compressed, these will all be ! // set to zero. ! ! int strides_m[Dim]; int ostrides_m[Dim]; // Base offset - offset of beginning of view from underlying Brick's --- 833,843 ---- Domain_t domain_m; ! // Values that do not change during the evaluation of a single ! // data parallel statement. + LoopInvariant_t invariant_m; + int ostrides_m[Dim]; // Base offset - offset of beginning of view from underlying Brick's *************** inline int BrickBase::offset0(const *** 707,713 **** CTAssert(Domain::dimensions == Dim); int offset = dom[0].first(); for (int d = 1; d < Dim; ++d) ! offset += dom[d].first() * strides_m[d]; return offset; } --- 875,881 ---- CTAssert(Domain::dimensions == Dim); int offset = dom[0].first(); for (int d = 1; d < Dim; ++d) ! offset += dom[d].first() * invariant_m.strides(d); return offset; } *************** template *** 716,724 **** inline int BrickBase::offsetC(const Domain &dom) const { CTAssert(Domain::dimensions == Dim); ! int offset = dom[0].first() * strides_m[0]; for (int d = 1; d < Dim; ++d) ! offset += dom[d].first() * strides_m[d]; return offset; } --- 884,892 ---- inline int BrickBase::offsetC(const Domain &dom) const { CTAssert(Domain::dimensions == Dim); ! int offset = dom[0].first() * invariant_m.strides(0); for (int d = 1; d < Dim; ++d) ! offset += dom[d].first() * invariant_m.strides(d); return offset; } *************** inline int BrickBase::offset(const *** 729,735 **** --- 897,936 ---- return off_m + offset0(dom); } + // HERE + template + template + inline int BrickBase::offset0(const LoopInvariant_t &li, + const Domain &dom) const + { + CTAssert(Domain::dimensions == Dim); + int offset = dom[0].first(); + for (int d = 1; d < Dim; ++d) + offset += dom[d].first() * li.strides(d); + return offset; + } + template + template + inline int BrickBase::offsetC(const LoopInvariant_t &li, + const Domain &dom) const + { + CTAssert(Domain::dimensions == Dim); + int offset = dom[0].first() * li.strides(0); + for (int d = 1; d < Dim; ++d) + offset += dom[d].first() * li.strides(d); + return offset; + } + + template + template + inline int BrickBase::offset(const LoopInvariant_t &, + const Domain &dom) const + { + return off_m + offset0(dom); + } + + ////////////////////////////////////////////////////////////////////// // // Inline implementation of the functions for BrickViewBase *************** template *** 745,754 **** inline int BrickViewBase:: offset(const Domain &dom) const { CTAssert(Domain::dimensions == Dim); ! int offset = dom[0].first() * strides_m[0]; for (int d = 1; d < Dim; ++d) ! offset += dom[d].first() * strides_m[d]; return offset; } --- 946,967 ---- inline int BrickViewBase:: offset(const Domain &dom) const { + CTAssert(Domain::dimensions == Dim); + int offset = dom[0].first() * invariant_m.strides(0); + for (int d = 1; d < Dim; ++d) + offset += dom[d].first() * invariant_m.strides(d); + return offset; + } + + template + template + inline int BrickViewBase:: + offset(const LoopInvariant_t& li, const Domain &dom) const + { CTAssert(Domain::dimensions == Dim); ! int offset = dom[0].first() * li.strides(0); for (int d = 1; d < Dim; ++d) ! offset += dom[d].first() * li.strides(d); return offset; } Index: src/Engine/BrickEngine.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/BrickEngine.h,v retrieving revision 1.131 diff -c -p -r1.131 BrickEngine.h *** src/Engine/BrickEngine.h 2001/10/17 17:47:35 1.131 --- src/Engine/BrickEngine.h 2001/11/05 19:28:26 *************** public: *** 147,152 **** --- 147,153 ---- typedef T Element_t; typedef T& ElementRef_t; typedef Brick Tag_t; + typedef typename Base_t::LoopInvariant_t BaseLoopInvariant_t; enum { brick = true }; enum { dimensions = Dim }; *************** public: *** 155,160 **** --- 156,182 ---- enum { zeroBased = false }; enum { multiPatch = false }; + // Values that do not change during the evaluation of a single + // data parallel statement. + + class LoopInvariant_t : public BaseLoopInvariant_t { + public: + + LoopInvariant_t(const BaseLoopInvariant_t& bli, + T* data) + : BaseLoopInvariant_t(bli), data_m(data) + {} + + inline + T* data() const { return data_m; } + + private: + + // This points to the same data as dataBlock_m but permits faster access. + + T* data_m; + }; + //============================================================ // Constructors and Factory Methods //============================================================ *************** public: *** 224,230 **** --- 246,255 ---- // Element access via Loc. Element_t read(const Loc &) const; + Element_t read(const LoopInvariant_t&, const Loc &) const; + ElementRef_t operator()(const Loc &) const; + ElementRef_t operator()(const LoopInvariant_t&, const Loc &) const; // Element access via ints for speed. *************** public: *** 236,241 **** --- 261,274 ---- Element_t read(int, int, int, int, int, int) const; Element_t read(int, int, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int) const; + Element_t read(const LoopInvariant_t&, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int, int, int) const; + ElementRef_t operator()(int) const; ElementRef_t operator()(int, int) const; ElementRef_t operator()(int, int, int) const; *************** public: *** 244,249 **** --- 277,290 ---- ElementRef_t operator()(int, int, int, int, int, int) const; ElementRef_t operator()(int, int, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int, int, int) const; + // Get a private copy of data viewed by this Engine. Engine_t &makeOwnCopy(); *************** public: *** 266,271 **** --- 307,318 ---- bool isShared() const { return dataBlock_m.isValid() && dataBlock_m.count() > 1; } + // Values that do not change during the evaluation of a single + // data parallel statement. + + inline const LoopInvariant_t loopInvariant() const + { return LoopInvariant_t(Base_t::loopInvariant(), data_m); } + private: //============================================================ *************** public: *** 324,329 **** --- 371,377 ---- typedef T Element_t; typedef T& ElementRef_t; typedef BrickView Tag_t; + typedef typename Base_t::LoopInvariant_t BaseLoopInvariant_t; enum { dimensions = Dim }; enum { hasDataObject = true }; *************** public: *** 331,336 **** --- 379,400 ---- enum { zeroBased = true }; enum { multiPatch = false }; + // Values that do not change during the evaluation of a single + // data parallel statement. + + class LoopInvariant_t : public BaseLoopInvariant_t { + public: + + LoopInvariant_t(const BaseLoopInvariant_t& bli, + T* data) + : Base_t::LoopInvariant_t(bli), data_m(data) {} + + T* data() const { return data_m; } + + private: + T* data_m; + }; + //============================================================ // Constructors //============================================================ *************** public: *** 360,366 **** template Engine(const Engine &e, const Domain &dom) ! : Base_t(e, dom.unwrap()), dataBlock_m(e.dataBlock(), e.offset(dom.unwrap())), data_m(dataBlock_m.currentPointer()) { // The engine's data pointer should be at the beginning. --- 424,430 ---- template Engine(const Engine &e, const Domain &dom) ! : Base_t(e, dom.unwrap()), dataBlock_m(e.dataBlock(), e.offset(dom.unwrap())), data_m(dataBlock_m.currentPointer()) { // The engine's data pointer should be at the beginning. *************** public: *** 470,476 **** --- 534,543 ---- // Element access via Loc. Element_t read(const Loc &) const; + Element_t read(const LoopInvariant_t&, const Loc &) const; + ElementRef_t operator()(const Loc &) const; + ElementRef_t operator()(const LoopInvariant_t&, const Loc &) const; // Element access via ints for speed. *************** public: *** 482,487 **** --- 549,562 ---- Element_t read(int, int, int, int, int, int) const; Element_t read(int, int, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int) const; + Element_t read(const LoopInvariant_t&, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int, int, int) const; + ElementRef_t operator()(int) const; ElementRef_t operator()(int, int) const; ElementRef_t operator()(int, int, int) const; *************** public: *** 490,495 **** --- 565,578 ---- ElementRef_t operator()(int, int, int, int, int, int) const; ElementRef_t operator()(int, int, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int, int, int) const; + // Return the DataBlockPtr. See comments in BrickEngine above. DataBlockPtr dataBlock() { return dataBlock_m; } *************** public: *** 501,506 **** --- 584,593 ---- inline Pooma::DataObject_t *dataObject() const { return dataBlock_m.dataObject(); } + inline + const LoopInvariant_t loopInvariant() const + { return LoopInvariant_t(Base_t::loopInvariant(), data_m); } + private: //============================================================ *************** private: *** 513,518 **** --- 600,607 ---- DataBlockPtr dataBlock_m; + // This points to the same data as dataBlock_m but permits faster access. + T *data_m; }; *************** read(int i1, int i2, int i3, int i4, int *** 748,753 **** --- 837,905 ---- } template + inline T Engine:: + read(const LoopInvariant_t& li, const Loc &loc) const + { + return li.data()[offset(li, loc)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1) const + { + PAssert(Dim == 1); + return li.data()[offset(li, i1)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2) const + { + PAssert(Dim == 2); + return li.data()[offset(li,i1,i2)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3) const + { + PAssert(Dim == 3); + return li.data()[offset(li, i1,i2,i3)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4) const + { + PAssert(Dim == 4); + return li.data()[offset(li, i1,i2,i3,i4)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5) const + { + PAssert(Dim == 5); + return li.data()[offset(li, i1,i2,i3,i4,i5)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6) const + { + PAssert(Dim == 6); + return li.data()[offset(li, i1,i2,i3,i4,i5,i6)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6, int i7) const + { + PAssert(Dim == 7); + return li.data()[offset(li, i1,i2,i3,i4,i5,i6,i7)]; + } + + template inline T & Engine:: operator()(const Loc &loc) const { *************** operator()(int i1, int i2, int i3, int i *** 810,815 **** --- 962,1031 ---- return data_m[offset(i1,i2,i3,i4,i5,i6,i7)]; } + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, const Loc &loc) const + { + return li.data()[offset(li, loc)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1) const + { + PAssert(Dim == 1); + return li.data()[offset(li, i1)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2) const + { + PAssert(Dim == 2); + return li.data()[offset(li, i1,i2)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3) const + { + PAssert(Dim == 3); + return li.data()[offset(li, i1,i2,i3)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4) const + { + PAssert(Dim == 4); + return li.data()[offset(li, i1,i2,i3,i4)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5) const + { + PAssert(Dim == 5); + return li.data()[offset(li, i1,i2,i3,i4,i5)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6) const + { + PAssert(Dim == 6); + return li.data()[offset(li, i1,i2,i3,i4,i5,i6)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6, int i7) const + { + PAssert(Dim == 7); + return li.data()[offset(li, i1,i2,i3,i4,i5,i6,i7)]; + } + + ////////////////////////////////////////////////////////////////////// // // Inline implementation of the functions for Engine *************** read(int i1, int i2, int i3, int i4, int *** 873,879 **** return data_m[offset(i1,i2,i3,i4,i5,i6)]; } - template inline T Engine:: read(int i1, int i2, int i3, int i4, int i5, int i6, int i7) const --- 1089,1094 ---- *************** read(int i1, int i2, int i3, int i4, int *** 883,888 **** --- 1098,1166 ---- } template + inline T Engine:: + read(const LoopInvariant_t& li, const Loc &loc) const + { + return li.data()[offset(li, loc)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1) const + { + PAssert(Dim == 1); + return li.data()[offset(li, i1)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2) const + { + PAssert(Dim == 2); + return li.data()[offset(li, i1,i2)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3) const + { + PAssert(Dim == 3); + return li.data()[offset(li, i1,i2,i3)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4) const + { + PAssert(Dim == 4); + return li.data()[offset(li, i1,i2,i3,i4)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5) const + { + PAssert(Dim == 5); + return li.data()[offset(li, i1,i2,i3,i4,i5)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6) const + { + PAssert(Dim == 6); + return li.data()[offset(li, i1,i2,i3,i4,i5,i6)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6, int i7) const + { + PAssert(Dim == 7); + return li.data()[offset(li, i1,i2,i3,i4,i5,i6,i7)]; + } + + template inline T & Engine:: operator()(const Loc &loc) const { *************** operator()(int i1, int i2, int i3, int i *** 944,949 **** --- 1222,1291 ---- { PAssert(Dim == 7); return data_m[offset(i1,i2,i3,i4,i5,i6,i7)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, const Loc &loc) const + { + return li.data()[offset(li, loc)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1) const + { + PAssert(Dim == 1); + return li.data()[offset(li, i1)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2) const + { + PAssert(Dim == 2); + return li.data()[offset(li, i1,i2)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3) const + { + PAssert(Dim == 3); + return li.data()[offset(li, i1,i2,i3)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4) const + { + PAssert(Dim == 4); + return li.data()[offset(li, i1,i2,i3,i4)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5) const + { + PAssert(Dim == 5); + return li.data()[offset(li, i1,i2,i3,i4,i5)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6) const + { + PAssert(Dim == 6); + return li.data()[offset(li, i1,i2,i3,i4,i5,i6)]; + } + + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6, int i7) const + { + PAssert(Dim == 7); + return li.data()[offset(li, i1,i2,i3,i4,i5,i6,i7)]; } // } // namespace Pooma Index: src/Engine/CompressibleBrick.cpp =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/CompressibleBrick.cpp,v retrieving revision 1.26 diff -c -p -r1.26 CompressibleBrick.cpp *** src/Engine/CompressibleBrick.cpp 2001/05/23 21:13:30 1.26 --- src/Engine/CompressibleBrick.cpp 2001/11/05 19:28:26 *************** Engine(const Engine::in *** 212,218 **** template Engine::~Engine() { ! if (data0_m) { cblock_m.lock(); if (cblock_m.isControllerValidUnlocked()) --- 212,218 ---- template Engine::~Engine() { ! if (data_m) { cblock_m.lock(); if (cblock_m.isControllerValidUnlocked()) *************** Engine &Engine< *** 254,260 **** cblock_m.makeOwnCopy(); cblock_m.attach(this); ! data0_m = cblock_m.data() + (cblock_m.compressed() ? 0 : baseOffset()); } return *this; --- 254,260 ---- cblock_m.makeOwnCopy(); cblock_m.attach(this); ! data_m = cblock_m.data() + (cblock_m.compressed() ? 0 : baseOffset()); } return *this; *************** Engine &Engine< *** 269,275 **** // The notification comes with a pointer to the new data. // // Note: The CBC is locked when this is called, so we don't have to ! // worry about contention for changing strides_m/data0_m, but we // do need to make sure no one tries to make a copy of these data // while they are being changed. Thus we lock our mutex. // --- 269,275 ---- // The notification comes with a pointer to the new data. // // Note: The CBC is locked when this is called, so we don't have to ! // worry about contention for changing strides_m/data_m, but we // do need to make sure no one tries to make a copy of these data // while they are being changed. Thus we lock our mutex. // *************** notify(T* &data, const ObserverEvent &ev *** 294,306 **** case CompressibleBlock::notifyUncompress: lock(); restoreStrides(); ! data0_m = data + baseOffset(); unlock(); break; case CompressibleBlock::notifyCompress: lock(); zeroStrides(); ! data0_m = data; unlock(); break; } --- 294,306 ---- case CompressibleBlock::notifyUncompress: lock(); restoreStrides(); ! data_m = data + baseOffset(); unlock(); break; case CompressibleBlock::notifyCompress: lock(); zeroStrides(); ! data_m = data; unlock(); break; } *************** void Engine::re *** 323,334 **** if (cblock_m.compressed()) { zeroStrides(); ! data0_m = cblock_m.data(); } else { restoreStrides(); ! data0_m = cblock_m.data() + baseOffset(); } } --- 323,334 ---- if (cblock_m.compressed()) { zeroStrides(); ! data_m = cblock_m.data(); } else { restoreStrides(); ! data_m = cblock_m.data() + baseOffset(); } } *************** operator=(const Engine &) const; + ElementRef_t operator()(const LoopInvariant_t&, const Loc &) const; Element_t read(const Loc &) const; + Element_t read(const LoopInvariant_t&, const Loc &) const; //--------------------------------------------------------------------------- // Return the domain and base domain. *************** public: *** 302,307 **** --- 337,347 ---- bool compressedBrickIsWholeView() const { return true; } + // Loop invariants. + + inline const + LoopInvariant_t loopInvariant() const { return LoopInvariant_t(); } + private: //============================================================ *************** private: *** 317,326 **** // construction. If compressed, this simply points to the // compressed value. ! T *data0_m; // Mutex protection for the CompressibleBricks. ! // The strides_m and data0_m members can be changed asynchronously // by the notify method (when someone else compresses or uncompresses // a copy of the underlying CBC). Thus it is necessary to protect // most accesses to these members. Since Smarts will prevent an --- 357,366 ---- // construction. If compressed, this simply points to the // compressed value. ! T *data_m; // Mutex protection for the CompressibleBricks. ! // The strides_m and data_m members can be changed asynchronously // by the notify method (when someone else compresses or uncompresses // a copy of the underlying CBC). Thus it is necessary to protect // most accesses to these members. Since Smarts will prevent an *************** private: *** 344,350 **** // The notification comes with a pointer to the new data. // Note: The CBC is locked when this is called, so we don't have to ! // worry about contention for changing strides_m/data0_m, but we // do need to make sure no one tries to make a copy of these data // while they are being changed. Thus we lock our mutex. --- 384,390 ---- // The notification comes with a pointer to the new data. // Note: The CBC is locked when this is called, so we don't have to ! // worry about contention for changing strides_m/data_m, but we // do need to make sure no one tries to make a copy of these data // while they are being changed. Thus we lock our mutex. *************** public: *** 411,416 **** --- 451,457 ---- typedef T Element_t; typedef T& ElementRef_t; typedef CompressibleBrickView Tag_t; + typedef typename Base_t::LoopInvariant_t BaseLoopInvariant_t; enum { dimensions = Dim }; enum { hasDataObject = true }; *************** public: *** 418,423 **** --- 459,480 ---- enum { zeroBased = true }; enum { multiPatch = false }; + // Values that do not change during the evaluation of a single + // data parallel statement. + + class LoopInvariant_t : public BaseLoopInvariant_t { + public: + + LoopInvariant_t(const BaseLoopInvariant_t& bli, + T* data) + : Base_t::LoopInvariant_t(bli), data_m(data) {} + + T* data() const { return data_m; } + + private: + T* data_m; + }; + //============================================================ // Constructors and Factory Methods //============================================================ *************** public: *** 425,431 **** // Default constructor. Creates a CompressibleBrickView-Engine with no // data and an "empty" domain. ! Engine() : data0_m(0) { } // Copy constructor performs a SHALLOW copy: --- 482,488 ---- // Default constructor. Creates a CompressibleBrickView-Engine with no // data and an "empty" domain. ! Engine() : data_m(0) { } // Copy constructor performs a SHALLOW copy: *************** public: *** 550,555 **** --- 607,620 ---- ElementRef_t operator()(int, int, int, int, int, int) const; ElementRef_t operator()(int, int, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int, int, int) const; + // Read-only access. // Guaranteed to be fast since there's no if-test. *************** public: *** 561,570 **** --- 626,645 ---- Element_t read(int, int, int, int, int, int) const; Element_t read(int, int, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int) const; + Element_t read(const LoopInvariant_t&, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int, int, int) const; + // Element access via Loc. ElementRef_t operator()(const Loc &) const; + ElementRef_t operator()(const LoopInvariant_t&, const Loc &) const; Element_t read(const Loc &) const; + Element_t read(const LoopInvariant_t&, const Loc &) const; //--------------------------------------------------------------------------- // Return the domain and base domain. *************** public: *** 614,619 **** --- 689,699 ---- long elementsCompressed() const; + // Loop invariants. + + inline const LoopInvariant_t loopInvariant() const + { return LoopInvariant_t(Base_t::loopInvariant(), data_m); } + private: // Mutex functions *************** private: *** 627,633 **** // The notification comes with a pointer to the new data. // Note: The CBC is locked when this is called, so we don't have to ! // worry about contention for changind strides_m/data0_m, but we // do need to make sure no one tries to make a copy of these data // while they are being changed. Thus we lock our mutex. --- 707,713 ---- // The notification comes with a pointer to the new data. // Note: The CBC is locked when this is called, so we don't have to ! // worry about contention for changind strides_m/data_m, but we // do need to make sure no one tries to make a copy of these data // while they are being changed. Thus we lock our mutex. *************** private: *** 644,656 **** case CompressibleBlock::notifyUncompress: lock(); restoreStrides(); ! data0_m = data + baseOffset(); unlock(); break; case CompressibleBlock::notifyCompress: lock(); zeroStrides(); ! data0_m = data; unlock(); break; } --- 724,736 ---- case CompressibleBlock::notifyUncompress: lock(); restoreStrides(); ! data_m = data + baseOffset(); unlock(); break; case CompressibleBlock::notifyCompress: lock(); zeroStrides(); ! data_m = data; unlock(); break; } *************** private: *** 688,699 **** if (cblock_m.compressed()) { zeroStrides(); ! data0_m = cblock_m.data(); } else { restoreStrides(); ! data0_m = cblock_m.data() + baseOffset(); } } --- 768,779 ---- if (cblock_m.compressed()) { zeroStrides(); ! data_m = cblock_m.data(); } else { restoreStrides(); ! data_m = cblock_m.data() + baseOffset(); } } *************** private: *** 710,716 **** // construction. If compressed, this simply points to the // compressed value. ! T *data0_m; // Flag that tells whether we're viewing the entire domain. --- 790,796 ---- // construction. If compressed, this simply points to the // compressed value. ! T *data_m; // Flag that tells whether we're viewing the entire domain. *************** private: *** 719,725 **** // Mutex protection for the CompressibleBricks. // This must be locked when changes are made via a notify // method, which can happen asynchronously, and when ! // the items changed (strides_m and data0_m) are accessed. mutable Pooma::Mutex_t mutex_m; --- 799,805 ---- // Mutex protection for the CompressibleBricks. // This must be locked when changes are made via a notify // method, which can happen asynchronously, and when ! // the items changed (strides_m and data_m) are accessed. mutable Pooma::Mutex_t mutex_m; *************** template *** 833,839 **** inline T Engine:: read(const Loc &loc) const { ! return data0_m[offsetC(loc)]; } template --- 913,919 ---- inline T Engine:: read(const Loc &loc) const { ! return data_m[offsetC(loc)]; } template *************** inline T Engine *** 841,847 **** read(int i1) const { PAssert(Dim == 1); ! return data0_m[offsetC(i1)]; } template --- 921,927 ---- read(int i1) const { PAssert(Dim == 1); ! return data_m[offsetC(i1)]; } template *************** inline T Engine *** 849,855 **** read(int i1, int i2) const { PAssert(Dim == 2); ! return data0_m[offsetC(i1,i2)]; } template --- 929,935 ---- read(int i1, int i2) const { PAssert(Dim == 2); ! return data_m[offsetC(i1,i2)]; } template *************** inline T Engine *** 857,863 **** read(int i1, int i2, int i3) const { PAssert(Dim == 3); ! return data0_m[offsetC(i1,i2,i3)]; } template --- 937,943 ---- read(int i1, int i2, int i3) const { PAssert(Dim == 3); ! return data_m[offsetC(i1,i2,i3)]; } template *************** inline T Engine *** 865,871 **** read(int i1, int i2, int i3, int i4) const { PAssert(Dim == 4); ! return data0_m[offsetC(i1,i2,i3,i4)]; } template --- 945,951 ---- read(int i1, int i2, int i3, int i4) const { PAssert(Dim == 4); ! return data_m[offsetC(i1,i2,i3,i4)]; } template *************** inline T Engine *** 873,879 **** read(int i1, int i2, int i3, int i4, int i5) const { PAssert(Dim == 5); ! return data0_m[offsetC(i1,i2,i3,i4,i5)]; } template --- 953,959 ---- read(int i1, int i2, int i3, int i4, int i5) const { PAssert(Dim == 5); ! return data_m[offsetC(i1,i2,i3,i4,i5)]; } template *************** inline T Engine *** 881,887 **** read(int i1, int i2, int i3, int i4, int i5, int i6) const { PAssert(Dim == 6); ! return data0_m[offsetC(i1,i2,i3,i4,i5,i6)]; } template --- 961,967 ---- read(int i1, int i2, int i3, int i4, int i5, int i6) const { PAssert(Dim == 6); ! return data_m[offsetC(i1,i2,i3,i4,i5,i6)]; } template *************** inline T Engine *** 889,903 **** read(int i1, int i2, int i3, int i4, int i5, int i6, int i7) const { PAssert(Dim == 7); ! return data0_m[offsetC(i1,i2,i3,i4,i5,i6,i7)]; } template inline T & Engine:: operator()(const Loc &loc) const { if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offsetC(loc)]; } template --- 969,1046 ---- read(int i1, int i2, int i3, int i4, int i5, int i6, int i7) const { PAssert(Dim == 7); ! return data_m[offsetC(i1,i2,i3,i4,i5,i6,i7)]; ! } ! ! template ! inline T Engine:: ! read(const LoopInvariant_t& li, const Loc &loc) const ! { ! return li.data()[offsetC(li, loc)]; ! } ! ! template ! inline T Engine:: ! read(const LoopInvariant_t& li, int i1) const ! { ! PAssert(Dim == 1); ! return li.data()[offsetC(li, i1)]; } template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2) const + { + PAssert(Dim == 2); + return li.data()[offsetC(li, i1,i2)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3) const + { + PAssert(Dim == 3); + return li.data()[offsetC(li, i1,i2,i3)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4) const + { + PAssert(Dim == 4); + return li.data()[offsetC(li, i1,i2,i3,i4)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5) const + { + PAssert(Dim == 5); + return li.data()[offsetC(li, i1,i2,i3,i4,i5)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6) const + { + PAssert(Dim == 6); + return li.data()[offsetC(li, i1,i2,i3,i4,i5,i6)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6, int i7) const + { + PAssert(Dim == 7); + return li.data()[offsetC(li, i1,i2,i3,i4,i5,i6,i7)]; + } + + template inline T & Engine:: operator()(const Loc &loc) const { if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offsetC(loc)]; } template *************** operator()(int i1) const *** 906,912 **** { PAssert(Dim == 1); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offsetC(i1)]; } template --- 1049,1055 ---- { PAssert(Dim == 1); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offsetC(i1)]; } template *************** operator()(int i1, int i2) const *** 915,921 **** { PAssert(Dim == 2); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offsetC(i1,i2)]; } template --- 1058,1064 ---- { PAssert(Dim == 2); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offsetC(i1,i2)]; } template *************** operator()(int i1, int i2, int i3) const *** 924,930 **** { PAssert(Dim == 3); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offsetC(i1,i2,i3)]; } template --- 1067,1073 ---- { PAssert(Dim == 3); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offsetC(i1,i2,i3)]; } template *************** operator()(int i1, int i2, int i3, int i *** 933,939 **** { PAssert(Dim == 4); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offsetC(i1,i2,i3,i4)]; } template --- 1076,1082 ---- { PAssert(Dim == 4); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offsetC(i1,i2,i3,i4)]; } template *************** operator()(int i1, int i2, int i3, int i *** 942,948 **** { PAssert(Dim == 5); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offsetC(i1,i2,i3,i4,i5)]; } template --- 1085,1091 ---- { PAssert(Dim == 5); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offsetC(i1,i2,i3,i4,i5)]; } template *************** operator()(int i1, int i2, int i3, int i *** 951,957 **** { PAssert(Dim == 6); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offsetC(i1,i2,i3,i4,i5,i6)]; } template --- 1094,1100 ---- { PAssert(Dim == 6); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offsetC(i1,i2,i3,i4,i5,i6)]; } template *************** inline T & Engine inline bool Engine:: compressed() const --- 1102,1184 ---- operator()(int i1, int i2, int i3, int i4, int i5, int i6, int i7) const { PAssert(Dim == 7); + if (cblock_m.compressed()) cblock_m.uncompress(); + return data_m[offsetC(i1,i2,i3,i4,i5,i6,i7)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, const Loc &loc) const + { + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offsetC(li, loc)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1) const + { + PAssert(Dim == 1); + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offsetC(li, i1)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2) const + { + PAssert(Dim == 2); + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offsetC(li, i1,i2)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3) const + { + PAssert(Dim == 3); + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offsetC(li, i1,i2,i3)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4) const + { + PAssert(Dim == 4); + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offsetC(li, i1,i2,i3,i4)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5) const + { + PAssert(Dim == 5); + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offsetC(li, i1,i2,i3,i4,i5)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6) const + { + PAssert(Dim == 6); if (cblock_m.compressed()) cblock_m.uncompress(); ! return li.data()[offsetC(li, i1,i2,i3,i4,i5,i6)]; } template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6, int i7) const + { + PAssert(Dim == 7); + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offsetC(li, i1,i2,i3,i4,i5,i6,i7)]; + } + + + template inline bool Engine:: compressed() const *************** compressedRead() const *** 979,985 **** { PAssert(cblock_m.isControllerValidUnlocked()); PAssert(cblock_m.compressed()); ! return *data0_m; } template --- 1194,1200 ---- { PAssert(cblock_m.isControllerValidUnlocked()); PAssert(cblock_m.compressed()); ! return *data_m; } template *************** compressedReadWrite() const *** 989,995 **** { PAssert(cblock_m.isControllerValidUnlocked()); PAssert(cblock_m.compressed()); ! return *data0_m; } --- 1204,1210 ---- { PAssert(cblock_m.isControllerValidUnlocked()); PAssert(cblock_m.compressed()); ! return *data_m; } *************** template *** 1033,1039 **** inline T Engine:: read(const Loc &loc) const { ! return data0_m[offset(loc)]; } template --- 1248,1254 ---- inline T Engine:: read(const Loc &loc) const { ! return data_m[offset(loc)]; } template *************** inline T Engine --- 1256,1262 ---- read(int i1) const { PAssert(Dim == 1); ! return data_m[offset(i1)]; } template *************** inline T Engine --- 1264,1270 ---- read(int i1, int i2) const { PAssert(Dim == 2); ! return data_m[offset(i1,i2)]; } template *************** inline T Engine --- 1272,1278 ---- read(int i1, int i2, int i3) const { PAssert(Dim == 3); ! return data_m[offset(i1,i2,i3)]; } template *************** inline T Engine --- 1280,1286 ---- read(int i1, int i2, int i3, int i4) const { PAssert(Dim == 4); ! return data_m[offset(i1,i2,i3,i4)]; } template *************** inline T Engine --- 1288,1294 ---- read(int i1, int i2, int i3, int i4, int i5) const { PAssert(Dim == 5); ! return data_m[offset(i1,i2,i3,i4,i5)]; } template *************** inline T Engine *** 1089,1104 **** inline T Engine:: read(int i1, int i2, int i3, int i4, int i5, int i6, int i7) const { PAssert(Dim == 7); ! return data0_m[offset(i1,i2,i3,i4,i5,i6,i7)]; } template inline T & Engine:: operator()(const Loc &loc) const { if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offset(loc)]; } template --- 1304,1384 ---- inline T Engine:: read(int i1, int i2, int i3, int i4, int i5, int i6, int i7) const { + PAssert(Dim == 7); + return data_m[offset(i1,i2,i3,i4,i5,i6,i7)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, const Loc &loc) const + { + return li.data()[offset(li, loc)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1) const + { + PAssert(Dim == 1); + return li.data()[offset(li, i1)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2) const + { + PAssert(Dim == 2); + return li.data()[offset(li, i1,i2)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3) const + { + PAssert(Dim == 3); + return li.data()[offset(li, i1,i2,i3)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4) const + { + PAssert(Dim == 4); + return li.data()[offset(li, i1,i2,i3,i4)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5) const + { + PAssert(Dim == 5); + return li.data()[offset(li, i1,i2,i3,i4,i5)]; + } + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6) const + { + PAssert(Dim == 6); + return li.data()[offset(li, i1,i2,i3,i4,i5,i6)]; + } + + + template + inline T Engine:: + read(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6, int i7) const + { PAssert(Dim == 7); ! return li.data()[offset(li, i1,i2,i3,i4,i5,i6,i7)]; } + template inline T & Engine:: operator()(const Loc &loc) const { if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offset(loc)]; } template *************** operator()(int i1) const *** 1107,1113 **** { PAssert(Dim == 1); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offset(i1)]; } template --- 1387,1393 ---- { PAssert(Dim == 1); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offset(i1)]; } template *************** operator()(int i1, int i2) const *** 1116,1122 **** { PAssert(Dim == 2); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offset(i1,i2)]; } template --- 1396,1402 ---- { PAssert(Dim == 2); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offset(i1,i2)]; } template *************** operator()(int i1, int i2, int i3) const *** 1125,1131 **** { PAssert(Dim == 3); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offset(i1,i2,i3)]; } template --- 1405,1411 ---- { PAssert(Dim == 3); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offset(i1,i2,i3)]; } template *************** operator()(int i1, int i2, int i3, int i *** 1134,1140 **** { PAssert(Dim == 4); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offset(i1,i2,i3,i4)]; } template --- 1414,1420 ---- { PAssert(Dim == 4); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offset(i1,i2,i3,i4)]; } template *************** operator()(int i1, int i2, int i3, int i *** 1143,1149 **** { PAssert(Dim == 5); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offset(i1,i2,i3,i4,i5)]; } template --- 1423,1429 ---- { PAssert(Dim == 5); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offset(i1,i2,i3,i4,i5)]; } template *************** operator()(int i1, int i2, int i3, int i *** 1152,1158 **** { PAssert(Dim == 6); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data0_m[offset(i1,i2,i3,i4,i5,i6)]; } template --- 1432,1438 ---- { PAssert(Dim == 6); if (cblock_m.compressed()) cblock_m.uncompress(); ! return data_m[offset(i1,i2,i3,i4,i5,i6)]; } template *************** inline T & Engine + inline T & Engine:: + operator()(const LoopInvariant_t& li, const Loc &loc) const + { + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offset(li, loc)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1) const + { + PAssert(Dim == 1); + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offset(li, i1)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2) const + { + PAssert(Dim == 2); + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offset(li, i1,i2)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3) const + { + PAssert(Dim == 3); + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offset(li, i1,i2,i3)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4) const + { + PAssert(Dim == 4); + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offset(li, i1,i2,i3,i4)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5) const + { + PAssert(Dim == 5); + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offset(li, i1,i2,i3,i4,i5)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6) const + { + PAssert(Dim == 6); + if (cblock_m.compressed()) cblock_m.uncompress(); + return li.data()[offset(li, i1,i2,i3,i4,i5,i6)]; + } + + template + inline T & Engine:: + operator()(const LoopInvariant_t& li, int i1, int i2, int i3, int i4, int i5, int i6, int i7) const + { + PAssert(Dim == 7); if (cblock_m.compressed()) cblock_m.uncompress(); ! return li.data()[offset(li, i1,i2,i3,i4,i5,i6,i7)]; } *************** inline T Engine --- 1521,1527 ---- compressedRead() const { PAssert(cblock_m.compressed()); ! return *data_m; } template *************** inline T& Engine explicit Engine(const Layout &layout, T val = T()) ! : val_m(val), domain_m(layout.domain()) { for (int d = 0; d < Dim; ++d) firsts_m[d] = domain_m[d].first(); --- 127,133 ---- template explicit Engine(const Layout &layout, T val = T()) ! : invariant_m(val), domain_m(layout.domain()) { for (int d = 0; d < Dim; ++d) firsts_m[d] = domain_m[d].first(); *************** public: *** 125,131 **** // Copy constructor. Engine(const Engine &model) ! : val_m(model.constant()), domain_m(model.domain()) { for (int d = 0; d < Dim; ++d) { --- 137,143 ---- // Copy constructor. Engine(const Engine &model) ! : invariant_m(model.constant()), domain_m(model.domain()) { for (int d = 0; d < Dim; ++d) { *************** public: *** 138,144 **** template Engine(const Engine &e, const Domain &dom) ! : val_m(e.constant()), domain_m(Pooma::NoInit()) { const typename DT::Domain_t &domain = dom.unwrap(); for (int d = 0; d < Dim; ++d) --- 150,156 ---- template Engine(const Engine &e, const Domain &dom) ! : invariant_m(e.constant()), domain_m(Pooma::NoInit()) { const typename DT::Domain_t &domain = dom.unwrap(); for (int d = 0; d < Dim; ++d) *************** public: *** 151,157 **** template Engine(const Engine &e, const SliceDomain
&dom) ! : val_m(e.constant()), domain_m(Pooma::NoInit()) { // The domain's dimension should match ours. --- 163,169 ---- template Engine(const Engine &e, const SliceDomain
&dom) ! : invariant_m(e.constant()), domain_m(Pooma::NoInit()) { // The domain's dimension should match ours. *************** public: *** 168,174 **** template Engine(const Engine &e, const Node &node) ! : val_m(e.constant()), domain_m(Pooma::NoInit()) { // The nodes's dimension should match ours. --- 180,186 ---- template Engine(const Engine &e, const Node &node) ! : invariant_m(e.constant()), domain_m(Pooma::NoInit()) { // The nodes's dimension should match ours. *************** public: *** 183,189 **** } Engine(const Engine &e, const INode &inode) ! : val_m(e.constant()), domain_m(Pooma::NoInit()) { const typename INode::Domain_t &domain = inode.domain(); for (int d = 0; d < Dim; ++d) --- 195,201 ---- } Engine(const Engine &e, const INode &inode) ! : invariant_m(e.constant()), domain_m(Pooma::NoInit()) { const typename INode::Domain_t &domain = inode.domain(); for (int d = 0; d < Dim; ++d) *************** public: *** 200,234 **** inline Element_t read(int) const { ! return val_m; } inline Element_t read(int, int) const { ! return val_m; } inline Element_t read(int, int, int) const { ! return val_m; } inline Element_t read(int, int, int, int) const { ! return val_m; } inline Element_t read(int, int, int, int, int) const { ! return val_m; } inline Element_t read(int, int, int, int, int, int) const { ! return val_m; } inline Element_t read(int, int, int, int, int, int, int) const { ! return val_m; } inline Element_t read(const Loc &) const { ! return val_m; } //--------------------------------------------------------------------------- --- 212,279 ---- inline Element_t read(int) const { ! return invariant_m.val(); } inline Element_t read(int, int) const { ! return invariant_m.val(); } inline Element_t read(int, int, int) const { ! return invariant_m.val(); } inline Element_t read(int, int, int, int) const { ! return invariant_m.val(); } inline Element_t read(int, int, int, int, int) const { ! return invariant_m.val(); } inline Element_t read(int, int, int, int, int, int) const { ! return invariant_m.val(); } inline Element_t read(int, int, int, int, int, int, int) const { ! return invariant_m.val(); } inline Element_t read(const Loc &) const + { + return invariant_m.val(); + } + + inline Element_t read(const LoopInvariant_t& li, int) const + { + return li.val(); + } + inline Element_t read(const LoopInvariant_t& li, int, int) const + { + return li.val(); + } + inline Element_t read(const LoopInvariant_t& li, int, int, int) const + { + return li.val(); + } + inline Element_t read(const LoopInvariant_t& li, int, int, int, int) const + { + return li.val(); + } + inline Element_t read(const LoopInvariant_t& li, int, int, int, int, int) const + { + return li.val(); + } + inline Element_t read(const LoopInvariant_t& li, int, int, int, int, int, int) const + { + return li.val(); + } + inline Element_t read(const LoopInvariant_t& li, int, int, int, int, int, int, int) const + { + return li.val(); + } + inline Element_t read(const LoopInvariant_t& li, const Loc &) const { ! return li.val(); } //--------------------------------------------------------------------------- *************** public: *** 251,263 **** //--------------------------------------------------------------------------- // Accessors/modifiers. ! T constant() const { return val_m; } ! void setConstant(T val) { val_m = val; } private: ! T val_m; Domain_t domain_m; int firsts_m[Dim]; }; --- 296,313 ---- //--------------------------------------------------------------------------- // Accessors/modifiers. + + T constant() const { return invariant_m.val(); } + void setConstant(T val) { invariant_m.setVal(val); } + + //--------------------------------------------------------------------------- + // Loop invariants. ! LoopInvariant_t loopInvariant() const { return invariant_m; } private: ! LoopInvariant_t invariant_m; Domain_t domain_m; int firsts_m[Dim]; }; Index: src/Engine/DynamicEngine.cpp =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/DynamicEngine.cpp,v retrieving revision 1.14 diff -c -p -r1.14 DynamicEngine.cpp *** src/Engine/DynamicEngine.cpp 2001/05/08 23:34:40 1.14 --- src/Engine/DynamicEngine.cpp 2001/11/05 19:28:26 *************** template Engine<1,T,Dynamic>:: *** 54,83 **** template Engine<1,T,Dynamic>::Engine(const Domain_t &dom) : domain_m(dom), ! data_m(dom.size()), first_m(dom.first()) { } template Engine<1,T,Dynamic>::Engine(const Node &node) : domain_m(node.allocated()), ! data_m(node.allocated().size(), node.affinity(), DataBlockPtr::WithAffinity_t()), first_m(node.allocated().first()) { } template Engine<1,T,Dynamic>::Engine(const Layout_t &layout) : domain_m(layout.domain()), ! data_m(layout.domain().size()), first_m(layout.domain().first()) { } template Engine<1,T,Dynamic>::Engine(const Domain_t &dom, const T& model) : domain_m(dom), ! data_m(dom.size(), model), first_m(dom.first()) { } --- 54,86 ---- template Engine<1,T,Dynamic>::Engine(const Domain_t &dom) : domain_m(dom), ! dataBlock_m(dom.size()), ! data_m(dataBlock_m.currentPointer()), first_m(dom.first()) { } template Engine<1,T,Dynamic>::Engine(const Node &node) : domain_m(node.allocated()), ! dataBlock_m(node.allocated().size(), node.affinity(), DataBlockPtr::WithAffinity_t()), + data_m(dataBlock_m.currentPointer()), first_m(node.allocated().first()) { } template Engine<1,T,Dynamic>::Engine(const Layout_t &layout) : domain_m(layout.domain()), ! dataBlock_m(layout.domain().size()), ! data_m(dataBlock_m.currentPointer()), first_m(layout.domain().first()) { } template Engine<1,T,Dynamic>::Engine(const Domain_t &dom, const T& model) : domain_m(dom), ! dataBlock_m(dom.size(), model), first_m(dom.first()) { } *************** template *** 85,94 **** Engine<1,T,Dynamic>:: Engine(const This_t &modelEngine) : domain_m(modelEngine.domain_m), ! data_m(modelEngine.data_m), first_m(modelEngine.first_m) { ! PAssert(data_m.isAtBeginning()); } //----------------------------------------------------------------------------- --- 88,98 ---- Engine<1,T,Dynamic>:: Engine(const This_t &modelEngine) : domain_m(modelEngine.domain_m), ! dataBlock_m(modelEngine.dataBlock_m), ! data_m(dataBlock_m.currentPointer()), first_m(modelEngine.first_m) { ! PAssert(dataBlock_m.isAtBeginning()); } //----------------------------------------------------------------------------- *************** operator=(const This_t &modelEngine) *** 106,116 **** if (this != &modelEngine) { ! domain_m = modelEngine.domain_m; ! data_m = modelEngine.data_m; ! first_m = modelEngine.first_m; ! PAssert(data_m.isAtBeginning()); } return *this; } --- 110,121 ---- if (this != &modelEngine) { ! domain_m = modelEngine.domain_m; ! dataBlock_m = modelEngine.dataBlock_m; ! data_m = modelEngine.data_m; ! first_m = modelEngine.first_m; ! PAssert(dataBlock_m.isAtBeginning()); } return *this; } *************** Engine<1,T,Dynamic> & *** 139,148 **** Engine<1,T,Dynamic>:: makeOwnCopy() { ! if (data_m.isValid() && data_m.count() > 1) { ! PAssert(data_m.isAtBeginning()); ! data_m.makeOwnCopy(); } return *this; --- 144,154 ---- Engine<1,T,Dynamic>:: makeOwnCopy() { ! if (dataBlock_m.isValid() && dataBlock_m.count() > 1) { ! PAssert(dataBlock_m.isAtBeginning()); ! dataBlock_m.makeOwnCopy(); ! data_m = dataBlock_m.currentPointer(); } return *this; *************** create(CreateSize_t num) *** 169,179 **** // take place inside iterates which means the engine is a copy of another // engine, so the data is shared. // ! // PAssert(!data_m.isShared()); // Reallocate the storage ! data_m.resizeAndCopy(domain_m.size() + num); // initialize new elements! // Reset the domain (in the layout) to the new size --- 175,186 ---- // take place inside iterates which means the engine is a copy of another // engine, so the data is shared. // ! // PAssert(!dataBlock_m.isShared()); // Reallocate the storage ! dataBlock_m.resizeAndCopy(domain_m.size() + num); // initialize new elements! ! data_m = dataBlock_m.currentPointer(); // Reset the domain (in the layout) to the new size *************** template *** 203,209 **** template void Engine<1,T,Dynamic>::destroy(const Dom &killList) { ! // PAssert(!data_m.isShared()); performDestroy(killList, BackFill(), false); } --- 210,216 ---- template void Engine<1,T,Dynamic>::destroy(const Dom &killList) { ! // PAssert(!dataBlock_m.isShared()); performDestroy(killList, BackFill(), false); } *************** template *** 211,217 **** template void Engine<1,T,Dynamic>::destroy(Iter begin, Iter end) { ! // PAssert(!data_m.isShared()); performDestroy(begin, end, BackFill(), false); } --- 218,224 ---- template void Engine<1,T,Dynamic>::destroy(Iter begin, Iter end) { ! // PAssert(!dataBlock_m.isShared()); performDestroy(begin, end, BackFill(), false); } *************** template *** 220,226 **** void Engine<1,T,Dynamic>:: destroy(const Dom &killList, const DeleteMethod &method, bool offsetFlag) { ! // PAssert(!data_m.isShared()); performDestroy(killList, method, offsetFlag); } --- 227,233 ---- void Engine<1,T,Dynamic>:: destroy(const Dom &killList, const DeleteMethod &method, bool offsetFlag) { ! // PAssert(!dataBlock_m.isShared()); performDestroy(killList, method, offsetFlag); } *************** template :: destroy(Iter begin, Iter end, const DeleteMethod &method, bool offsetFlag) { ! // PAssert(!data_m.isShared()); performDestroy(begin, end, method, offsetFlag); } --- 236,242 ---- void Engine<1,T,Dynamic>:: destroy(Iter begin, Iter end, const DeleteMethod &method, bool offsetFlag) { ! // PAssert(!dataBlock_m.isShared()); performDestroy(begin, end, method, offsetFlag); } *************** performDestroy(const Iterator &killBegin *** 331,337 **** // Use the generic delete algorithm to do the work. int killed = ! Pooma::Algorithms::delete_backfill(data_m.begin(), data_m.end(), killBegin, killEnd, koffset); // Update the domain. --- 338,344 ---- // Use the generic delete algorithm to do the work. int killed = ! Pooma::Algorithms::delete_backfill(dataBlock_m.begin(), dataBlock_m.end(), killBegin, killEnd, koffset); // Update the domain. *************** performDestroy(const Iterator &killBegin *** 349,355 **** // Resize the data block to the new domain size. ! data_m.resize(domain().size(), DataBlockPtr::NoInitTag()); } // Now the version that takes a general domain. --- 356,363 ---- // Resize the data block to the new domain size. ! dataBlock_m.resize(domain().size(), DataBlockPtr::NoInitTag()); ! data_m = dataBlock_m.currentPointer(); } // Now the version that takes a general domain. *************** performDestroy(const Iterator &killBegin *** 409,415 **** int koffset = (offsetFlag ? 0 : first_m); int killed = ! Pooma::Algorithms::delete_shiftup(data_m.begin(), data_m.end(), killBegin, killEnd, koffset); Interval<1> newdom; --- 417,423 ---- int koffset = (offsetFlag ? 0 : first_m); int killed = ! Pooma::Algorithms::delete_shiftup(dataBlock_m.begin(), dataBlock_m.end(), killBegin, killEnd, koffset); Interval<1> newdom; *************** performDestroy(const Iterator &killBegin *** 419,425 **** domain_m = newdom; ! data_m.resize(domain().size(), DataBlockPtr::NoInitTag()); } template --- 427,434 ---- domain_m = newdom; ! dataBlock_m.resize(domain().size(), DataBlockPtr::NoInitTag()); ! data_m = dataBlock_m.currentPointer(); } template *************** performDestroy(const Domain &killList, c *** 453,459 **** // // void sync(Domain_t) // ! // modify the domain (but not the size) of this engine. // //----------------------------------------------------------------------------- --- 462,468 ---- // // void sync(Domain_t) // ! // Modify the domain (but not the size) of this engine. // //----------------------------------------------------------------------------- *************** Engine<1,T,Dynamic>::sync(const Domain_t *** 486,492 **** template Engine<1,T,DynamicView>:: Engine(const Engine<1,T,Dynamic> &engine, const Interval<1> &dom) ! : data_m(engine.dataBlock(), dom.first() - engine.domain().first()), domain_m(Interval<1>(dom.length())), stride_m(1) { --- 495,502 ---- template Engine<1,T,DynamicView>:: Engine(const Engine<1,T,Dynamic> &engine, const Interval<1> &dom) ! : dataBlock_m(engine.dataBlock(), dom.first() - engine.domain().first()), ! data_m(dataBlock_m.currentPointer()), domain_m(Interval<1>(dom.length())), stride_m(1) { *************** template *** 498,504 **** Engine<1,T,DynamicView>:: Engine(const Engine<1,T,Dynamic> &engine, const Range<1> &dom) : domain_m(Interval<1>(dom.length())), ! data_m(engine.dataBlock(), dom.first() - engine.domain().first()), stride_m(dom.stride()) { // The engine's data pointer should be at the beginning. --- 508,515 ---- Engine<1,T,DynamicView>:: Engine(const Engine<1,T,Dynamic> &engine, const Range<1> &dom) : domain_m(Interval<1>(dom.length())), ! dataBlock_m(engine.dataBlock(), dom.first() - engine.domain().first()), ! data_m(dataBlock_m.currentPointer()), stride_m(dom.stride()) { // The engine's data pointer should be at the beginning. *************** template *** 509,515 **** Engine<1,T,DynamicView>:: Engine(const This_t &engine, const Interval<1> &dom) : domain_m(Interval<1>(dom.length())), ! data_m(engine.dataBlock(), engine.stride_m * dom.first()), stride_m(engine.stride_m) { } --- 520,527 ---- Engine<1,T,DynamicView>:: Engine(const This_t &engine, const Interval<1> &dom) : domain_m(Interval<1>(dom.length())), ! dataBlock_m(engine.dataBlock(), engine.stride_m * dom.first()), ! data_m(dataBlock_m.currentPointer()), stride_m(engine.stride_m) { } *************** template *** 517,523 **** Engine<1,T,DynamicView>:: Engine(const This_t &engine, const Range<1> &dom) : domain_m(Interval<1>(dom.length())), ! data_m(engine.dataBlock(), engine.stride_m * dom.first()), stride_m(engine.stride_m*dom.stride()) { } --- 529,536 ---- Engine<1,T,DynamicView>:: Engine(const This_t &engine, const Range<1> &dom) : domain_m(Interval<1>(dom.length())), ! dataBlock_m(engine.dataBlock(), engine.stride_m * dom.first()), ! data_m(dataBlock_m.currentPointer()), stride_m(engine.stride_m*dom.stride()) { } *************** template *** 525,531 **** Engine<1,T,DynamicView>:: Engine(const Engine_t &engine, const INode<1> &inode) : domain_m(Interval<1>(inode.domain().length())), ! data_m(engine.dataBlock(), engine.stride_m * inode.domain().first()), stride_m(engine.stride_m) { } --- 538,545 ---- Engine<1,T,DynamicView>:: Engine(const Engine_t &engine, const INode<1> &inode) : domain_m(Interval<1>(inode.domain().length())), ! dataBlock_m(engine.dataBlock(), engine.stride_m * inode.domain().first()), ! data_m(dataBlock_m.currentPointer()), stride_m(engine.stride_m) { } *************** template *** 542,548 **** Engine<1,T,DynamicView>:: Engine(const This_t &modelEngine) : domain_m(modelEngine.domain_m), ! data_m(modelEngine.data_m), stride_m(modelEngine.stride_m) { } --- 556,563 ---- Engine<1,T,DynamicView>:: Engine(const This_t &modelEngine) : domain_m(modelEngine.domain_m), ! dataBlock_m(modelEngine.dataBlock_m), ! data_m(dataBlock_m.currentPointer()), stride_m(modelEngine.stride_m) { } *************** template *** 550,556 **** Engine<1,T,DynamicView>:: Engine(const This_t &modelEngine, const EngineConstructTag &) : domain_m(modelEngine.domain_m), ! data_m(modelEngine.data_m), stride_m(modelEngine.stride_m) { } --- 565,572 ---- Engine<1,T,DynamicView>:: Engine(const This_t &modelEngine, const EngineConstructTag &) : domain_m(modelEngine.domain_m), ! dataBlock_m(modelEngine.dataBlock_m), ! data_m(dataBlock_m.currentPointer()), stride_m(modelEngine.stride_m) { } *************** operator=(const This_t &modelEngine) *** 580,585 **** --- 596,602 ---- { if (this != &modelEngine) { + dataBlock_m = modelEngine.dataBlock_m; data_m = modelEngine.data_m; domain_m = modelEngine.domain_m; stride_m = modelEngine.stride_m; Index: src/Engine/DynamicEngine.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/DynamicEngine.h,v retrieving revision 1.16 diff -c -p -r1.16 DynamicEngine.h *** src/Engine/DynamicEngine.h 2001/04/09 21:34:27 1.16 --- src/Engine/DynamicEngine.h 2001/11/05 19:28:26 *************** public: *** 154,159 **** --- 154,188 ---- enum { zeroBased = false }; enum { multiPatch = false }; + // Values that do not change during the evaluation of a single + // data parallel statement. + + class LoopInvariant_t { + public: + + LoopInvariant_t(T* data, int first) + : data_m(data), first_m(first) + {} + + inline T* data() const { return data_m; } + + inline int& first() { return first_m; } + inline int first() const { return first_m; } + + private: + + // The domain could be added here, but it is not used anywhere so + // we defer adding it until the need to have it is shown. + + // This points to the same data as dataBlock_m but permits faster access. + + T* data_m; + + // Index of the first point. + + int first_m; + }; + //============================================================ // Constructors and Factory Methods //============================================================ *************** public: *** 224,234 **** --- 253,278 ---- inline ElementRef_t operator()(const Loc<1> &l) const { return data_m[l.first() - first_m]; } + inline + Element_t read(const LoopInvariant_t &li, const Loc<1> &l) const + { return li.data()[l.first() - li.first()]; } + + inline + ElementRef_t operator()(const LoopInvariant_t &li, const Loc<1> &l) const + { return li.data()[l.first() - li.first()]; } + // Element access via ints for speed. inline Element_t read(int i) const { return data_m[i - first_m]; }; inline ElementRef_t operator()(int i) const { return data_m[i - first_m]; }; + inline + Element_t read(const LoopInvariant_t &li, int i) const + { return li.data()[i - li.first()]; }; + inline + ElementRef_t operator()(const LoopInvariant_t &li, int i) const + { return li.data()[i - li.first()]; }; + // Return the domain. inline const Domain_t &domain() const { return domain_m; } *************** public: *** 239,245 **** // Return whether the block controlled by this engine is shared. ! bool isShared() const { return data_m.isValid() && data_m.count() > 1; } // Get a private copy of data viewed by this Engine. --- 283,289 ---- // Return whether the block controlled by this engine is shared. ! bool isShared() const { return dataBlock_m.isValid() && dataBlock_m.count() > 1; } // Get a private copy of data viewed by this Engine. *************** public: *** 247,260 **** // Provide access to the data object. ! Pooma::DataObject_t *dataObject() const { return data_m.dataObject(); } // Return access to our internal data block. This is ref-counted, // so a copy is fine. But you should really know what you're doing // if you call this method. ! const DataBlockPtr & dataBlock() const { return data_m; } ! DataBlockPtr dataBlock() { return data_m; } //============================================================ // Dynamic interface methods. --- 291,304 ---- // Provide access to the data object. ! Pooma::DataObject_t *dataObject() const { return dataBlock_m.dataObject(); } // Return access to our internal data block. This is ref-counted, // so a copy is fine. But you should really know what you're doing // if you call this method. ! const DataBlockPtr & dataBlock() const { return dataBlock_m; } ! DataBlockPtr dataBlock() { return dataBlock_m; } //============================================================ // Dynamic interface methods. *************** public: *** 338,343 **** --- 382,393 ---- #endif + // Values that do not change during the evaluation of a single + // data parallel statement. + + inline const LoopInvariant_t loopInvariant() const + { return LoopInvariant_t(data_m, first_m); } + private: //============================================================ *************** private: *** 395,402 **** // Smart-pointer to Block-controller that manages the data // and the Smarts DataObject. ! DataBlockPtr data_m; // Index of the first point. --- 445,456 ---- // Smart-pointer to Block-controller that manages the data // and the Smarts DataObject. + + DataBlockPtr dataBlock_m; + + // This points to the same data as dataBlock_m but permits faster access. ! T* data_m; // Index of the first point. *************** public: *** 445,451 **** --- 499,534 ---- enum { dynamic = false }; enum { zeroBased = true }; enum { multiPatch = false }; + + // Values that do not change during the evaluation of a single + // data parallel statement. + + class LoopInvariant_t { + public: + + LoopInvariant_t(T* data, int stride) + : data_m(data), stride_m(stride) + {} + + inline T* data() const { return data_m; } + + inline int& stride() { return stride_m; } + inline int stride() const { return stride_m; } + + private: + + // The domain could be added here, but it is not used anywhere so + // we defer adding it until the need to have it is shown. + + // This points to the same data as dataBlock_m but permits faster access. + + T* data_m; + + // Stride + int stride_m; + }; + //============================================================ // Constructors //============================================================ *************** public: *** 502,512 **** --- 585,608 ---- inline ElementRef_t operator()(const Loc<1> &l) const { return data_m[l.first()*stride_m]; } + inline Element_t read(const LoopInvariant_t &li, const Loc<1> &l) const + { return li.data()[l.first()*li.stride()]; } + + inline ElementRef_t operator()(const LoopInvariant_t &li, + const Loc<1> &l) const + { return li.data()[l.first()*li.stride()]; } + // Element access via ints for speed. inline Element_t read(int i) const { return data_m[i*stride_m]; } inline ElementRef_t operator()(int i) const { return data_m[i*stride_m]; } + // HERE + inline Element_t read(const LoopInvariant_t &li, int i) const + { return li.data()[i*li.stride()]; } + inline ElementRef_t operator()(const LoopInvariant_t &li, int i) const + { return li.data()[i*li.stride()]; } + // Return the domain: const Domain_t &domain() const { return domain_m; } *************** public: *** 521,534 **** // Provide access to the data object. ! Pooma::DataObject_t *dataObject() const { return data_m.dataObject(); } // Return access to our internal data block. This is ref-counted, // so a copy is fine. But you should really know what you're doing // if you call this method. ! const DataBlockPtr & dataBlock() const { return data_m; } ! DataBlockPtr dataBlock() { return data_m; } private: --- 617,630 ---- // Provide access to the data object. ! Pooma::DataObject_t *dataObject() const { return dataBlock_m.dataObject(); } // Return access to our internal data block. This is ref-counted, // so a copy is fine. But you should really know what you're doing // if you call this method. ! const DataBlockPtr & dataBlock() const { return dataBlock_m; } ! DataBlockPtr dataBlock() { return dataBlock_m; } private: *************** private: *** 540,549 **** Domain_t domain_m; - // Copy of the Block-controller that manages the data. ! DataBlockPtr data_m; // Stride. --- 636,648 ---- Domain_t domain_m; // Copy of the Block-controller that manages the data. + + DataBlockPtr dataBlock_m; + + // This points to the same data as dataBlock_m but permits faster access. ! T* data_m; // Stride. Index: src/Engine/EngineFunctor.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/EngineFunctor.h,v retrieving revision 1.11 diff -c -p -r1.11 EngineFunctor.h *** src/Engine/EngineFunctor.h 2001/10/12 18:52:40 1.11 --- src/Engine/EngineFunctor.h 2001/11/05 19:28:26 *************** template *** 193,199 **** struct EngineView; //----------------------------------------------------------------------------- ! // LeafFunctor specializations for EngineView. // // Applying EngineView to a general node is an error. // Applying EngineView to a scalar just returns the scalar. --- 193,199 ---- struct EngineView; //----------------------------------------------------------------------------- ! // LeafFunctor specialization for EngineView. // // Applying EngineView to a general node is an error. // Applying EngineView to a scalar just returns the scalar. *************** template *** 208,218 **** struct LeafFunctor, EngineView > { typedef Scalar Type_t; static inline ! Type_t apply(const Scalar &s, const EngineView &) { return s; } }; //----------------------------------------------------------------------------- --- 208,230 ---- struct LeafFunctor, EngineView > { typedef Scalar Type_t; + typedef Scalar Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef EngineView Tag_t; + static inline ! Type_t apply(const Subject_t &s, const Tag_t &) { return s; } + + static inline + Type_t apply(const Subject_t &s, + const LoopInvariant_t &, + const Tag_t &t) + { + return apply(s,t); + } }; //----------------------------------------------------------------------------- *************** struct LeafFunctor, EngineView *** 223,229 **** // result from attempting to provide the specializations: // // LeafFunctor> - // LeafFunctor> //----------------------------------------------------------------------------- template --- 235,240 ---- *************** template, EngineView > { typedef Engine Subject_t; typedef DefaultEngineView EngineView_t; typedef typename EngineView_t::Type_t Type_t; static inline Type_t apply(const Subject_t &engine, ! const EngineView &tag) { return EngineView_t::apply(engine, tag); } }; //----------------------------------------------------------------------------- --- 244,268 ---- struct LeafFunctor, EngineView > { typedef Engine Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef EngineView Tag_t; typedef DefaultEngineView EngineView_t; typedef typename EngineView_t::Type_t Type_t; static inline Type_t apply(const Subject_t &engine, ! const Tag_t &tag) { return EngineView_t::apply(engine, tag); } + + static inline + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return EngineView_t::apply(engine, li, tag); + } }; //----------------------------------------------------------------------------- *************** expressionApply(const A &a, const Tag &t *** 277,283 **** } //----------------------------------------------------------------------------- ! // LeafFunctor specializations for ExpressionApply. // // Applying EngineView to a general node is an error. //----------------------------------------------------------------------------- --- 298,305 ---- } //----------------------------------------------------------------------------- ! // LeafFunctor and LeafFunctorLoopInvariant specializations for ! // ExpressionApply. // // Applying EngineView to a general node is an error. //----------------------------------------------------------------------------- *************** template *** 291,301 **** struct LeafFunctor, ExpressionApply > { typedef int Type_t; static inline ! Type_t apply(const Scalar &, const ExpressionApply &) { return 0; } }; //----------------------------------------------------------------------------- --- 313,335 ---- struct LeafFunctor, ExpressionApply > { typedef int Type_t; + typedef Scalar Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef ExpressionApply Tag_t; + static inline ! Type_t apply(const Subject_t &, const Tag_t &) { return 0; } + + static inline + Type_t apply(const Subject_t &s, + const LoopInvariant_t &li, + const Tag_t &t) + { + return apply(s,t); + } }; //----------------------------------------------------------------------------- *************** struct LeafFunctor, Expression *** 306,312 **** // result from attempting to provide the specializations: // // LeafFunctor> ! // LeafFunctor> //----------------------------------------------------------------------------- template --- 340,346 ---- // result from attempting to provide the specializations: // // LeafFunctor> ! // LeafFunctorLoopInvariant> //----------------------------------------------------------------------------- template *************** template, ExpressionApply > { typedef Engine Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; typedef DefaultExpressionApply ExpressionApply_t; typedef int Type_t; *************** struct LeafFunctor, Ex *** 325,332 **** { return ExpressionApply_t::apply(engine, tag); } - }; ////////////////////////////////////////////////////////////////////// --- 360,374 ---- { return ExpressionApply_t::apply(engine, tag); } + static inline + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const ExpressionApply &tag) + { + return ExpressionApply_t::apply(engine, li, tag); + } + }; ////////////////////////////////////////////////////////////////////// Index: src/Engine/ExpressionEngine.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/ExpressionEngine.h,v retrieving revision 1.76 diff -c -p -r1.76 ExpressionEngine.h *** src/Engine/ExpressionEngine.h 2001/09/26 00:14:40 1.76 --- src/Engine/ExpressionEngine.h 2001/11/05 19:28:26 *************** *** 29,39 **** //----------------------------------------------------------------------------- // Classes: // DomainFunctorTag ! // LeafFunctor // EvalLeaf ! // LeafFunctor, Scalar > // ViewFunctorTag - // LeafFunctor< ViewFunctorTag, Scalar > // ExpressionTag // Engine // Combine2 --- 29,38 ---- //----------------------------------------------------------------------------- // Classes: // DomainFunctorTag ! // LeafFunctor // EvalLeaf ! // LeafFunctor, EvalLeaf > // ViewFunctorTag // ExpressionTag // Engine // Combine2 *************** template *** 84,94 **** struct LeafFunctor, EvalLeaf > { typedef T Type_t; inline static ! Type_t apply(const Scalar &s, const EvalLeaf &) { return s.value(); } }; //----------------------------------------------------------------------------- --- 83,105 ---- struct LeafFunctor, EvalLeaf > { typedef T Type_t; + typedef Scalar Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef EvalLeaf Tag_t; + inline static ! Type_t apply(const Subject_t &s, const Tag_t &) { return s.value(); } + + inline static + Type_t apply(const Subject_t &s, + const LoopInvariant_t &li, + const Tag_t &) + { + return s.value(li); + } }; //----------------------------------------------------------------------------- *************** template *** 100,111 **** struct LeafFunctor, EvalLeaf > { typedef T Type_t; inline static ! Type_t apply(const Engine &e, const EvalLeaf &t) { return t.eval(e); } }; template<> --- 111,133 ---- struct LeafFunctor, EvalLeaf > { typedef T Type_t; + typedef Engine Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef EvalLeaf Tag_t; inline static ! Type_t apply(const Subject_t &e, const Tag_t &t) { return t.eval(e); } + + inline static + Type_t apply(const Subject_t &e, + const LoopInvariant_t &li, + const Tag_t &t) + { + return t.eval(li, e); + } }; template<> *************** struct EvalLeaf<1> *** 128,133 **** --- 150,162 ---- { return e.read(val1()); } + + template + inline typename Engine::Element_t + eval(const Engine &e, const typename Engine::LoopInvariant_t &li) const + { + return e.read(li, val1()); + } }; template<> *************** struct EvalLeaf<2> *** 151,156 **** --- 180,192 ---- { return e.read(val1(), val2()); } + + template + inline typename Engine::Element_t + eval(const Engine &e, const typename Engine::LoopInvariant_t &li) const + { + return e.read(li, val1(), val2()); + } }; template<> *************** struct EvalLeaf<3> *** 175,180 **** --- 211,223 ---- { return e.read(val1(), val2(), val3()); } + + template + inline typename Engine::Element_t + eval(const Engine &e, const typename Engine::LoopInvariant_t &li) const + { + return e.read(li, val1(), val2(), val3()); + } }; template<> *************** struct EvalLeaf<4> *** 201,206 **** --- 244,256 ---- { return e.read(val1(), val2(), val3(), val4()); } + + template + inline typename Engine::Element_t + eval(const Engine &e, const typename Engine::LoopInvariant_t &li) const + { + return e.read(li, val1(), val2(), val3(), val4()); + } }; template<> *************** struct EvalLeaf<5> *** 228,233 **** --- 278,290 ---- { return e.read(val1(), val2(), val3(), val4(), val5()); } + + template + inline typename Engine::Element_t + eval(const Engine &e, const typename Engine::LoopInvariant_t &li) const + { + return e.read(li, val1(), val2(), val3(), val4(), val5()); + } }; template<> *************** struct EvalLeaf<6> *** 256,261 **** --- 313,325 ---- { return e.read(val1(), val2(), val3(), val4(), val5(), val6()); } + + template + inline typename Engine::Element_t + eval(const Engine &e, const typename Engine::LoopInvariant_t &li) const + { + return e.read(li, val1(), val2(), val3(), val4(), val5(), val6()); + } }; template<> *************** struct EvalLeaf<7> *** 286,291 **** --- 350,362 ---- { return e.read(val1(), val2(), val3(), val4(), val5(), val6(), val7()); } + + template + inline typename Engine::Element_t + eval(const Engine &e, const typename Engine::LoopInvariant_t &li) const + { + return e.read(li, val1(), val2(), val3(), val4(), val5(), val6(), val7()); + } }; //----------------------------------------------------------------------------- *************** template *** 311,321 **** struct LeafFunctor, ViewFunctorTag > { typedef Scalar Type_t; inline static ! Type_t apply(const Scalar &s, const ViewFunctorTag &) { return s; } }; --- 382,404 ---- struct LeafFunctor, ViewFunctorTag > { typedef Scalar Type_t; + typedef Scalar Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef ViewFunctorTag Tag_t; + inline static ! Type_t apply(const Subject_t &s, const Tag_t &) { return s; } + + inline static + Type_t apply(const Subject_t &s, + const LoopInvariant_t &, + const Tag_t &t) + { + return apply(s,t); + } }; *************** template *** 331,349 **** struct LeafFunctor, DomainFunctorTag> { typedef NullDomain Type_t; inline static ! Type_t apply(const Scalar &, const DomainFunctorTag &) { return NullDomain(); } }; template struct LeafFunctor { typedef typename T::Domain_t Type_t; inline static ! Type_t apply(const T &leaf, const DomainFunctorTag &) { return leaf.domain(); } --- 414,456 ---- struct LeafFunctor, DomainFunctorTag> { typedef NullDomain Type_t; + typedef Scalar Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef DomainFunctorTag Tag_t; + inline static ! Type_t apply(const Subject_t &, const Tag_t &) { return NullDomain(); } + + inline static + Type_t apply(const Subject_t &, + const LoopInvariant_t &, + const Tag_t &) + { + return NullDomain(); + } }; template struct LeafFunctor { typedef typename T::Domain_t Type_t; + typedef T Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef DomainFunctorTag Tag_t; + + inline static + Type_t apply(const Subject_t &leaf, const Tag_t &) + { + return leaf.domain(); + } + inline static ! Type_t apply(const Subject_t &leaf, ! const LoopInvariant_t &, ! const Tag_t &) { return leaf.domain(); } *************** public: *** 470,475 **** --- 577,587 ---- typedef Expr Expression_t; typedef DomainLayout Layout_t; + // Values that do not change during the evaluation of a single + // data parallel statement. + + typedef typename Expr::LoopInvariant_t LoopInvariant_t; + //--------------------------------------------------------------------------- // Was enum { dimensions = Domain_t::dimensions }; // It's possible for the dimension of an expression to be different from *************** public: *** 594,599 **** --- 706,757 ---- return forEach(expr_m, EvalLeaf(loc), OpCombine()); } + inline Element_t read(const LoopInvariant_t& li, int i0) const + { + return forEach(expr_m, li, EvalLeaf<1>(i0), OpCombine()); + } + + inline Element_t read(const LoopInvariant_t& li, int i0, int i1) const + { + return forEach(expr_m, li, EvalLeaf<2>(i0, i1), OpCombine()); + } + + inline Element_t read(const LoopInvariant_t& li, int i0, int i1, int i2) const + { + return forEach(expr_m, li, EvalLeaf<3>(i0, i1, i2), OpCombine()); + } + + inline Element_t read(const LoopInvariant_t& li, int i0, int i1, int i2, int i3) const + { + return forEach(expr_m, li, EvalLeaf<4>(i0, i1, i2, i3), + OpCombine()); + } + + inline Element_t read(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4) const + { + return forEach(expr_m, li, EvalLeaf<5>(i0, i1, i2, i3, i4), + OpCombine()); + } + + inline Element_t read(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5) const + { + return forEach(expr_m, li, EvalLeaf<6>(i0, i1, i2, i3, i4, i5), + OpCombine()); + } + + inline Element_t read(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5, + int i6) const + { + return forEach(expr_m, li, EvalLeaf<7>(i0, i1, i2, i3, i4, i5, i6), + OpCombine()); + } + + inline Element_t read(const LoopInvariant_t& li, const Loc &loc) const + { + return forEach(expr_m, li, EvalLeaf(loc), OpCombine()); + } + + //--------------------------------------------------------------------------- // Function to return the common domain. We recursively go through the // expression tree asking each node and leaf to return their domain and *************** public: *** 633,638 **** --- 791,800 ---- return forEach(expr_m,Functor_t(f),Combine_t()); } + inline + const LoopInvariant_t loopInvariant() const + { return expr_m.loopInvariant(); } + private: // The expression is stored here. *************** template *** 695,706 **** struct LeafFunctor, EngineFunctorTag > { typedef typename EngineFunctorScalar::Type_t Type_t; inline static ! Type_t apply(const Scalar &scalar, const EngineFunctorTag &tag) { return EngineFunctorScalar::apply(scalar.value(), tag.tag()); } }; //----------------------------------------------------------------------------- --- 857,879 ---- struct LeafFunctor, EngineFunctorTag > { typedef typename EngineFunctorScalar::Type_t Type_t; + typedef Scalar Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef EngineFunctorTag Tag_t; inline static ! Type_t apply(const Subject_t &scalar, const Tag_t &tag) { return EngineFunctorScalar::apply(scalar.value(), tag.tag()); } + + inline static + Type_t apply(const Subject_t &scalar, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return EngineFunctorScalar::apply(scalar.value(), li, tag.tag()); + } }; //----------------------------------------------------------------------------- *************** template, EngineFunctorTag > { typedef Engine Engine_t; typedef typename EngineFunctor::Type_t Type_t; inline static ! Type_t apply(const Engine_t &engine, ! const EngineFunctorTag &tag) { return EngineFunctor::apply(engine, tag.tag()); } }; //--------------------------------------------------------------------------- --- 884,908 ---- struct LeafFunctor, EngineFunctorTag > { typedef Engine Engine_t; + typedef Engine_t Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; typedef typename EngineFunctor::Type_t Type_t; + typedef EngineFunctorTag Tag_t; inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &tag) { return EngineFunctor::apply(engine, tag.tag()); } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return EngineFunctor::apply(engine, li, tag.tag()); + } }; //--------------------------------------------------------------------------- *************** struct LeafFunctor Functor_t; typedef typename Functor_t::Combine_t Combine_t; typedef typename ForEach::Type_t NewExpr_t; typedef Engine > Type_t; inline static ! Type_t apply(const Engine > &engine, ! const EngineView &tag) { return Type_t(forEach(engine.expression(), tag, Combine_t())); } }; //--------------------------------------------------------------------------- --- 957,982 ---- typedef EngineView Functor_t; typedef typename Functor_t::Combine_t Combine_t; typedef typename ForEach::Type_t NewExpr_t; + typedef Engine > Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef EngineView Tag_t; typedef Engine > Type_t; inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &tag) { return Type_t(forEach(engine.expression(), tag, Combine_t())); } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return Type_t(forEach(engine.expression(), li, tag, Combine_t())); + } }; //--------------------------------------------------------------------------- *************** template >, ExpressionApply > { typedef int Type_t; inline static ! Type_t apply(const Engine > &engine, ! const ExpressionApply &tag) { return forEach(engine.expression(), tag, NullCombine()); } }; --- 987,1009 ---- struct LeafFunctor >, ExpressionApply > { typedef int Type_t; + typedef Engine > Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef ExpressionApply Tag_t; inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &tag) { return forEach(engine.expression(), tag, NullCombine()); + } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return forEach(engine.expression(), li, tag, NullCombine()); } }; Index: src/Engine/ForwardingEngine.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/ForwardingEngine.h,v retrieving revision 1.44 diff -c -p -r1.44 ForwardingEngine.h *** src/Engine/ForwardingEngine.h 2001/10/12 18:52:40 1.44 --- src/Engine/ForwardingEngine.h 2001/11/05 19:28:26 *************** public: *** 108,113 **** --- 108,118 ---- enum { multiPatch = Eng::multiPatch }; //--------------------------------------------------------------------------- + // Values that do not change during the evaluation of a single + // data parallel statement. + typedef typename ElemEngine_t::LoopInvariant_t LoopInvariant_t; + + //--------------------------------------------------------------------------- // Empty constructor required for containers of engines. Engine() *************** public: *** 249,255 **** --- 254,314 ---- return CompAccess_t::index(elemEngine().read(i1, i2, i3, i4, i5, i6, i7), components()); } + // HERE + inline Element_t read(const LoopInvariant_t &li, + const Loc &eloc) const + { + return CompAccess_t::index(elemEngine().read(li, eloc), components()); + } + + inline Element_t read(const LoopInvariant_t &li, + int i1) const + { + return CompAccess_t::index(elemEngine().read(li, i1), components()); + } + + inline Element_t read(const LoopInvariant_t &li, + int i1, int i2) const + { + return CompAccess_t::index(elemEngine().read(li, i1, i2), components()); + } + + inline Element_t read(const LoopInvariant_t &li, + int i1, int i2, int i3) const + { + return CompAccess_t::index(elemEngine().read(li, i1, i2, i3), + components()); + } + + inline Element_t read(const LoopInvariant_t &li, + int i1, int i2, int i3, int i4) const + { + return CompAccess_t::index(elemEngine().read(li, i1, i2, i3, i4), + components()); + } + + inline Element_t read(const LoopInvariant_t &li, + int i1, int i2, int i3, int i4, int i5) const + { + return CompAccess_t::index(elemEngine().read(li, i1, i2, i3, i4, i5), + components()); + } + inline Element_t read(const LoopInvariant_t &li, + int i1, int i2, int i3, int i4, int i5, int i6) const + { + return CompAccess_t::index(elemEngine().read(li, i1, i2, i3, i4, i5, i6), + components()); + } + + inline Element_t read(const LoopInvariant_t &li, + int i1, int i2, int i3, int i4, int i5, + int i6, int i7) const + { + return CompAccess_t::index(elemEngine().read(li, i1, i2, i3, i4, i5, i6, i7), + components()); + } + //--------------------------------------------------------------------------- // Returns the domain, which is acquired from the contained engine. *************** public: *** 274,286 **** } //--------------------------------------------------------------------------- ! // Assessor functions that return the engine and components. Eng &elemEngine() { return engine_m; } const Eng &elemEngine() const { return engine_m; } const Components &components() const { return components_m; } private: Eng engine_m; --- 333,352 ---- } //--------------------------------------------------------------------------- ! // Accessor functions that return the engine and components. Eng &elemEngine() { return engine_m; } const Eng &elemEngine() const { return engine_m; } const Components &components() const { return components_m; } + //--------------------------------------------------------------------------- + // Access values that do not change during the evaluation of a single + // data parallel statement. + inline + const LoopInvariant_t loopInvariant() const + { return engine_m.loopInvariant(); } + private: Eng engine_m; *************** struct EngineFunctor::Type_t Type_t; ! static Type_t ! apply(const Engine > &engine, ! const EFTag &tag) { return engineFunctor(engine.elemEngine(), tag); } --- 376,384 ---- { typedef typename EngineFunctor::Type_t Type_t; ! inline static ! Type_t apply(const Engine > &engine, ! const EFTag &tag) { return engineFunctor(engine.elemEngine(), tag); } *************** struct LeafFunctor > LeafFunctor_t; typedef typename LeafFunctor_t::Type_t NewViewed_t; typedef Engine > Type_t; ! static ! Type_t apply(const Engine > &engine, const EngineView &tag) { return Type_t(LeafFunctor_t::apply(engine.elemEngine(), tag), engine.components()); } }; template --- 390,414 ---- typedef LeafFunctor > LeafFunctor_t; typedef typename LeafFunctor_t::Type_t NewViewed_t; typedef Engine > Type_t; + typedef Engine > Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! inline static ! Type_t apply(const Subject_t &engine, const EngineView &tag) { return Type_t(LeafFunctor_t::apply(engine.elemEngine(), tag), engine.components()); } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const EngineView &tag) + { + return Type_t(LeafFunctor_t::apply(engine.elemEngine(), li, tag), + engine.components()); + } }; template *************** struct LeafFunctor > LeafFunctor_t; typedef int Type_t; ! static ! Type_t apply(const Engine > &engine, const ExpressionApply &tag) { return LeafFunctor_t::apply(engine.elemEngine(), tag); } }; //--------------------------------------------------------------------------- // Tell contained engine that it's dirty. --- 416,440 ---- { typedef LeafFunctor > LeafFunctor_t; typedef int Type_t; + typedef Engine > Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! inline static ! Type_t apply(const Subject_t &engine, const ExpressionApply &tag) { return LeafFunctor_t::apply(engine.elemEngine(), tag); } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const ExpressionApply &tag) + { + return LeafFunctor_t::apply(engine.elemEngine(), li, tag); + } }; + //--------------------------------------------------------------------------- // Tell contained engine that it's dirty. Index: src/Engine/IndexFunctionEngine.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/IndexFunctionEngine.h,v retrieving revision 1.23 diff -c -p -r1.23 IndexFunctionEngine.h *** src/Engine/IndexFunctionEngine.h 2001/08/30 01:15:04 1.23 --- src/Engine/IndexFunctionEngine.h 2001/11/05 19:28:26 *************** public: *** 106,111 **** --- 106,112 ---- typedef DomainLayout Layout_t; typedef T Element_t; typedef ErrorType ElementRef_t; + struct LoopInvariant_t {}; enum { dimensions = Dim }; enum { hasDataObject = false }; *************** public: *** 225,230 **** --- 226,294 ---- loc[3].first(), loc[4].first(), loc[5].first(), loc[6].first()); } + inline Element_t read(const LoopInvariant_t &, int i0) const + { + return funct_m(i0); + } + inline Element_t read(const LoopInvariant_t &, int i0, int i1) const + { + return funct_m(i0, i1); + } + inline Element_t read(const LoopInvariant_t &, int i0, int i1, int i2) const + { + return funct_m(i0, i1, i2); + } + inline Element_t read(const LoopInvariant_t &, int i0, int i1, int i2, int i3) const + { + return funct_m(i0, i1, i2, i3); + } + inline Element_t read(const LoopInvariant_t &, int i0, int i1, int i2, int i3, int i4) const + { + return funct_m(i0, i1, i2, i3, i4); + } + inline Element_t read(const LoopInvariant_t &, int i0, int i1, int i2, int i3, int i4, + int i5) const + { + return funct_m(i0, i1, i2, i3, i4, i5); + } + inline Element_t read(const LoopInvariant_t &, int i0, int i1, int i2, int i3, int i4, + int i5, int i6) const + { + return funct_m(i0, i1, i2, i3, i4, i5, i6); + } + inline Element_t read(const LoopInvariant_t &, const Loc<1> &loc) const + { + return funct_m(loc[0].first()); + } + inline Element_t read(const LoopInvariant_t &, const Loc<2> &loc) const + { + return funct_m(loc[0].first(), loc[1].first()); + } + inline Element_t read(const LoopInvariant_t &, const Loc<3> &loc) const + { + return funct_m(loc[0].first(), loc[1].first(), loc[2].first()); + } + inline Element_t read(const LoopInvariant_t &, const Loc<4> &loc) const + { + return funct_m(loc[0].first(), loc[1].first(), loc[2].first(), + loc[3].first()); + } + inline Element_t read(const LoopInvariant_t &, const Loc<5> &loc) const + { + return funct_m(loc[0].first(), loc[1].first(), loc[2].first(), + loc[3].first(), loc[4].first()); + } + inline Element_t read(const LoopInvariant_t &, const Loc<6> &loc) const + { + return funct_m(loc[0].first(), loc[1].first(), loc[2].first(), + loc[3].first(), loc[4].first(), loc[5].first()); + } + inline Element_t read(const LoopInvariant_t &, const Loc<7> &loc) const + { + return funct_m(loc[0].first(), loc[1].first(), loc[2].first(), + loc[3].first(), loc[4].first(), loc[5].first(), loc[6].first()); + } + //--------------------------------------------------------------------------- // Return/set the domain. Also, return the base domain. *************** public: *** 245,250 **** --- 309,319 ---- const Functor &functor() const { return funct_m; } void setFunctor(const Functor &f) { funct_m = f; } + + //--------------------------------------------------------------------------- + // Loop invariants. + + LoopInvariant_t loopInvariant() const { return LoopInvariant_t(); } private: Index: src/Engine/IndirectionEngine.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/IndirectionEngine.h,v retrieving revision 1.24 diff -c -p -r1.24 IndirectionEngine.h *** src/Engine/IndirectionEngine.h 2001/10/12 18:52:40 1.24 --- src/Engine/IndirectionEngine.h 2001/11/05 19:28:26 *************** public: *** 94,99 **** --- 94,101 ---- typedef DomainLayout Layout_t; typedef typename A1::Engine_t Engine1_t; typedef typename A2::Engine_t Engine2_t; + typedef typename Engine1_t::LoopInvariant_t Engine1LoopInvariant_t; + typedef typename Engine2_t::LoopInvariant_t Engine2LoopInvariant_t; enum { dimensions = Dim }; enum { hasDataObject = Engine1_t::hasDataObject || *************** public: *** 103,108 **** --- 105,127 ---- enum { dynamic = false }; enum { zeroBased = Engine2_t::zeroBased }; + // Values that do not change during the evaluation of a single + // data parallel statement. + + class LoopInvariant_t { + public: + LoopInvariant_t(const Engine1LoopInvariant_t& li1, + const Engine2LoopInvariant_t& li2) + : li1_m(li1), li2_m(li2) {} + + Engine1LoopInvariant_t engine1() const { return li1_m; } + Engine2LoopInvariant_t engine2() const { return li2_m; } + + private: + Engine1LoopInvariant_t li1_m; + Engine2LoopInvariant_t li2_m; + }; + //--------------------------------------------------------------------------- // *************** public: *** 196,201 **** --- 215,270 ---- return array1_m.read(array2_m.read(loc)); } + inline Element_t read(const LoopInvariant_t &li, int i0) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0)); + } + + inline Element_t read(const LoopInvariant_t &li, int i0, int i1) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0,i1)); + } + + inline Element_t read(const LoopInvariant_t &li, int i0, int i1,int i2) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0,i1,i2)); + } + + inline Element_t read(const LoopInvariant_t &li, int i0, int i1,int i2,int i3) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0,i1,i2,i3)); + } + + inline Element_t read(const LoopInvariant_t &li, int i0, int i1, int i2, int i3, int i4) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0,i1,i2,i3,i4)); + } + + inline Element_t read(const LoopInvariant_t &li, int i0, int i1, int i2, int i3, int i4, int i5) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0,i1,i2,i3,i4,i5)); + } + + inline Element_t read(const LoopInvariant_t &li, int i0, int i1, int i2, int i3, int i4, int i5, + int i6) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0,i1,i2,i3,i4,i5,i6)); + } + + template + inline Element_t read(const LoopInvariant_t &li, const Domain &loc) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), loc)); + } + //--------------------------------------------------------------------------- // Accessor functions for a specific element. Normally these have read-write // semantics. However, the notion of writing to an expression makes no sense *************** public: *** 244,249 **** --- 313,377 ---- return array1_m(array2_m.read(loc)); } + inline ElementRef_t operator()(const LoopInvariant_t &li, + int i0) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0)); + } + + inline ElementRef_t operator()(const LoopInvariant_t &li, + int i0, int i1) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0,i1)); + } + + inline ElementRef_t operator()(const LoopInvariant_t &li, + int i0, int i1,int i2) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0,i1,i2)); + } + + inline ElementRef_t operator()(const LoopInvariant_t &li, + int i0, int i1,int i2,int i3) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0,i1,i2,i3)); + } + + inline ElementRef_t operator()(const LoopInvariant_t &li, + int i0, int i1, int i2, int i3, int i4) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0,i1,i2,i3,i4)); + } + + inline ElementRef_t operator()(const LoopInvariant_t &li, + int i0, int i1, int i2, int i3, int i4, + int i5) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0,i1,i2,i3,i4,i5)); + } + + inline ElementRef_t operator()(const LoopInvariant_t &li, + int i0, int i1, int i2, int i3, int i4, + int i5, int i6) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), i0,i1,i2,i3,i4,i5,i6)); + } + + template + inline ElementRef_t operator()(const LoopInvariant_t &li, + const Domain &loc) const + { + return array1_m.read(li.engine1(), + array2_m.read(li.engine2(), loc)); + } + //--------------------------------------------------------------------------- inline Domain_t domain() const *************** public: *** 259,271 **** return array2_m.first(i); } private: // The contained arrays are stored here. A1 array1_m; A2 array2_m; - }; //----------------------------------------------------------------------------- --- 387,408 ---- return array2_m.first(i); } + //--------------------------------------------------------------------------- + // Values that do not change during the evaluation of a single + // data parallel statement. + + inline + const LoopInvariant_t loopInvariant() const + { return LoopInvariant_t(array1().loopInvariant(), + array2().loopInvariant()); + } + private: // The contained arrays are stored here. A1 array1_m; A2 array2_m; }; //----------------------------------------------------------------------------- Index: src/Engine/MultiPatchEngine.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/MultiPatchEngine.h,v retrieving revision 1.117 diff -c -p -r1.117 MultiPatchEngine.h *** src/Engine/MultiPatchEngine.h 2001/04/09 21:35:47 1.117 --- src/Engine/MultiPatchEngine.h 2001/11/05 19:28:26 *************** public: *** 456,462 **** --- 456,467 ---- enum { zeroBased = false }; enum { multiPatch = true }; + // Values that do not change during the evaluation of a single + // data parallel statement. + class LoopInvariant_t { }; + // HERE + //=========================================================================== // Constructors and factory methods //=========================================================================== *************** public: *** 502,508 **** --- 507,516 ---- // Element access via Loc. Element_t read(const Loc &) const; + Element_t read(const LoopInvariant_t& li, const Loc &) const; + ElementRef_t operator()(const Loc &) const; + ElementRef_t operator()(const LoopInvariant_t& li, const Loc &) const; //--------------------------------------------------------------------------- // Element access via ints for speed. *************** public: *** 515,520 **** --- 523,536 ---- Element_t read(int, int, int, int, int, int) const; Element_t read(int, int, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int) const; + Element_t read(const LoopInvariant_t&, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int, int, int) const; + ElementRef_t operator()(int) const; ElementRef_t operator()(int, int) const; ElementRef_t operator()(int, int, int) const; *************** public: *** 523,528 **** --- 539,552 ---- ElementRef_t operator()(int, int, int, int, int, int) const; ElementRef_t operator()(int, int, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int, int, int) const; + //--------------------------------------------------------------------------- // Return a patch given a Node or INode. *************** public: *** 662,667 **** --- 686,698 ---- return *pDirty_m; } + //--------------------------------------------------------------------------- + // Return the loop invariant object. + + inline + const LoopInvariant_t loopInvariant() const { return LoopInvariant_t(); } + + //============================================================ // Observer methods //============================================================ *************** public: *** 971,976 **** --- 1002,1025 ---- enum { zeroBased = true }; enum { multiPatch = true }; + // Values that do not change during the evaluation of a single + // data parallel statement. + + class LoopInvariant_t { + public: + typedef typename ViewedEngine_t::LoopInvariant_t ViewedLoopInvariant_t; + + LoopInvariant_t(const ViewedLoopInvariant_t& li) + : li_m(li) {} + + inline + const LoopInvariant_t& viewed() const { return li_m; } + + private: + ViewedLoopInvariant_t li_m; + }; + + //=========================================================================== // Constructors and factory methods //=========================================================================== *************** public: *** 1053,1059 **** --- 1102,1111 ---- // Element access via Loc. Element_t read(const Loc &) const; + Element_t read(const LoopInvariant_t& li, const Loc &) const; + ElementRef_t operator()(const Loc &) const; + ElementRef_t operator()(const LoopInvariant_t& li, const Loc &) const; //--------------------------------------------------------------------------- // Element access via ints for speed. *************** public: *** 1066,1071 **** --- 1118,1131 ---- Element_t read(int, int, int, int, int, int) const; Element_t read(int, int, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int) const; + Element_t read(const LoopInvariant_t&, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int, int) const; + Element_t read(const LoopInvariant_t&, int, int, int, int, int, int, int) const; + ElementRef_t operator()(int) const; ElementRef_t operator()(int, int) const; ElementRef_t operator()(int, int, int) const; *************** public: *** 1074,1079 **** --- 1134,1147 ---- ElementRef_t operator()(int, int, int, int, int, int) const; ElementRef_t operator()(int, int, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int, int) const; + ElementRef_t operator()(const LoopInvariant_t&, int, int, int, int, int, int, int) const; + //--------------------------------------------------------------------------- // Return a patch given a Node or INode. This is different than in // MultiPatch because we really need to take a view here. *************** public: *** 1260,1265 **** --- 1328,1341 ---- return baseEngine_m; } + //--------------------------------------------------------------------------- + // Return the loop invariant object. + + inline + const LoopInvariant_t loopInvariant() const + { return LoopInvariant_t(baseEngine().loopInvariant()); } + // HERE + private: //=========================================================================== *************** private: *** 1270,1276 **** Layout_t layout_m; ! // Shallow copy of the underyling engine. // We have to have this to support filling guard cells. There // is only a single dirty flag, so guard cell fill requests must // fill the guards for the entire engine, and we need a reference --- 1346,1352 ---- Layout_t layout_m; ! // Shallow copy of the underlying engine. // We have to have this to support filling guard cells. There // is only a single dirty flag, so guard cell fill requests must // fill the guards for the entire engine, and we need a reference *************** Engine + inline typename Engine >::Element_t + Engine >::read(const LoopInvariant_t& li, const Loc &loc) const + { + return data()[layout_m.globalID(loc)].read(li, loc); + } + + template + inline typename Engine >::Element_t + Engine >::read(const LoopInvariant_t& li, int i0) const + { + return data()[layout_m.globalID(i0)].read(li, i0); + } + + template + inline typename Engine >::Element_t + Engine >::read(const LoopInvariant_t& li, int i0, int i1) const + { + return data()[layout_m.globalID(i0, i1)].read(li, i0, i1); + } + + template + inline typename Engine >::Element_t + Engine >::read(const LoopInvariant_t& li, int i0, int i1, int i2) + const + { + return data()[layout_m.globalID(i0, i1, i2)].read(li, i0, i1, i2); + } + + template + inline typename Engine >::Element_t + Engine >::read(const LoopInvariant_t& li, int i0, int i1, int i2, + int i3) const + { + return data()[layout_m.globalID(i0, i1, i2, i3)].read(li, i0, i1, i2, i3); + } + + template + inline typename Engine >::Element_t + Engine >::read(const LoopInvariant_t& li, int i0, int i1, int i2, + int i3, int i4) const + { + return data()[layout_m.globalID(i0, i1, i2, i3, i4)].read + (li, i0, i1, i2, i3, i4); + } + + template + inline typename Engine >::Element_t + Engine >::read(const LoopInvariant_t& li, int i0, int i1, int i2, + int i3, int i4, int i5) const + { + return data()[layout_m.globalID(i0, i1, i2, i3, i4, i5)].read + (li, i0, i1, i2, i3, i4, i5); + } + + template + inline typename Engine >::Element_t + Engine >::read(const LoopInvariant_t& li, int i0, int i1, int i2, + int i3, int i4, int i5, int i6) const + { + return data()[layout_m.globalID(i0, i1, i2, i3, i4, i5, i6)].read + (li, i0, i1, i2, i3, i4, i5, i6); + } + // Operator()'s: template *************** Engine + inline typename Engine >::ElementRef_t + Engine >::operator()(const LoopInvariant_t& li, const Loc &loc) + const + { + return data()[layout_m.globalID(loc)](li, loc); + } + + template + inline typename Engine >::ElementRef_t + Engine >::operator()(const LoopInvariant_t& li, int i0) const + { + return data()[layout_m.globalID(i0)](li, i0); + } + + template + inline typename Engine >::ElementRef_t + Engine >::operator()(const LoopInvariant_t& li, int i0, + int i1) const + { + return data()[layout_m.globalID(i0, i1)](li, i0, i1); + } + + template + inline typename Engine >::ElementRef_t + Engine >::operator()(const LoopInvariant_t& li, int i0, int i1, + int i2) const + { + return data()[layout_m.globalID(i0, i1, i2)](li, i0, i1, i2); + } + + template + inline typename Engine >::ElementRef_t + Engine >::operator()(const LoopInvariant_t& li, int i0, int i1, + int i2, int i3) const + { + return data()[layout_m.globalID(i0, i1, i2, i3)](li, i0, i1, i2, i3); + } + + template + inline typename Engine >::ElementRef_t + Engine >::operator()(const LoopInvariant_t& li, int i0, int i1, + int i2, int i3, int i4) const + { + return data()[layout_m.globalID(i0, i1, i2, i3, i4)] + (li, i0, i1, i2, i3, i4); + } + + template + inline typename Engine >::ElementRef_t + Engine >::operator()(const LoopInvariant_t& li, int i0, int i1, + int i2, int i3, int i4, int i5) const + { + return data()[layout_m.globalID(i0, i1, i2, i3, i4, i5)] + (li, i0, i1, i2, i3, i4, i5); + } + + template + inline typename Engine >::ElementRef_t + Engine >::operator()(const LoopInvariant_t& li, int i0, int i1, + int i2, int i3, int i4, int i5, int i6) const + { + return data()[layout_m.globalID(i0, i1, i2, i3, i4, i5, i6)] + (li, i0, i1, i2, i3, i4, i5, i6); + } + // Dynamic event handler for non-dynamic patch engines: template *************** dynamicHandler(Observable_t &, const Obs *** 1437,1442 **** --- 1644,1650 ---- } + /////////////////////////////////////////////////////////////////////////////// // // Engine > MEMBER FUNCTIONS *************** read(int i0, int i1, int i2, int i3, int *** 1585,1590 **** --- 1793,1886 ---- return data()[o].read(gloc); } + template + inline + typename Engine >::Element_t + Engine >:: + read(const LoopInvariant_t& li, const Loc &loc) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(loc, gloc); + return data()[o].read(li, gloc); + } + + template + inline + typename Engine >::Element_t + Engine >::read(const LoopInvariant_t& li, int i0) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, gloc); + return data()[o].read(li, gloc); + } + + template + inline + typename Engine >::Element_t + Engine >:: + read(const LoopInvariant_t& li, int i0, int i1) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, i1, gloc); + return data()[o].read(li, gloc); + } + + template + inline + typename Engine >::Element_t + Engine >:: + read(const LoopInvariant_t& li, int i0, int i1, int i2) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, i1, i2, gloc); + return data()[o].read(li, gloc); + } + + template + inline + typename Engine >::Element_t + Engine >:: + read(const LoopInvariant_t& li, int i0, int i1, int i2, int i3) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, i1, i2, i3, gloc); + return data()[o].read(li, gloc); + } + + template + inline + typename Engine >::Element_t + Engine >:: + read(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, i1, i2, i3, i4, gloc); + return data()[o](li, gloc); + } + + template + inline + typename Engine >::Element_t + Engine >:: + read(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, i1, i2, i3, i4, i5, gloc); + return data()[o].read(li, gloc); + } + + template + inline + typename Engine >::Element_t + Engine >:: + read(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5, int i6) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, i1, i2, i3, i4, i5, i6, gloc); + return data()[o].read(li, gloc); + } + + // Operator()'s: template *************** operator()(int i0, int i1, int i2, int i *** 1675,1680 **** --- 1971,2065 ---- return data()[o](gloc); } + template + inline typename + Engine >::ElementRef_t + Engine >:: + operator()(const LoopInvariant_t& li, const Loc &loc) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(loc, gloc); + return data()[o](li, gloc); + } + + template + inline typename + Engine >::ElementRef_t + Engine >:: + operator()(const LoopInvariant_t& li, int i0) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, gloc); + return data()[o](li, gloc); + } + + template + inline typename + Engine >::ElementRef_t + Engine >:: + operator()(const LoopInvariant_t& li, int i0, int i1) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, i1, gloc); + return data()[o](li, gloc); + } + + template + inline typename + Engine >::ElementRef_t + Engine >:: + operator()(const LoopInvariant_t& li, int i0, int i1, int i2) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, i1, i2, gloc); + return data()[o](li, gloc); + } + + template + inline typename + Engine >::ElementRef_t + Engine >:: + operator()(const LoopInvariant_t& li, int i0, int i1, int i2, int i3) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, i1, i2, i3, gloc); + return data()[o](li, gloc); + } + + template + inline typename + Engine >::ElementRef_t + Engine >:: + operator()(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, i1, i2, i3, i4, gloc); + return data()[o](li, gloc); + } + + template + inline typename + Engine >::ElementRef_t + Engine >:: + operator()(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, i1, i2, i3, i4, i5, gloc); + return data()[o](li, gloc); + } + + template + inline typename + Engine >::ElementRef_t + Engine >:: + operator()(const LoopInvariant_t& li, int i0, int i1, int i2, int i3, int i4, int i5, int i6) const + { + Loc gloc = Pooma::NoInit(); + int o = layout_m.globalID(i0, i1, i2, i3, i4, i5, i6, gloc); + return data()[o](li, gloc); + } + + //--------------------------------------------------------------------------- // Specialization of IntersectEngine because these engines contain multiple // patches. *************** struct LeafFunctor > > { typedef int Type_t; ! static Type_t ! apply(const Engine > &engine, ! const ExpressionApply > &tag) { bool useGuards = tag.tag().intersector_m.intersect(engine, --- 2072,2083 ---- ExpressionApply > > { typedef int Type_t; + typedef Engine > Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! inline static ! Type_t apply(const Subject_t &engine, ! const ExpressionApply > &tag) { bool useGuards = tag.tag().intersector_m.intersect(engine, *************** struct LeafFunctor > &tag) + { + return apply(engine, tag); + } }; template > > { typedef int Type_t; ! static Type_t ! apply(const Engine > &engine, ! const ExpressionApply > &tag) { typedef typename MultiPatchLayoutTraits::Layout_t Layout_t; return applyHandler(engine, tag, WrappedInt()); } ! inline static Type_t ! applyHandler(const Engine > &engine, ! const ExpressionApply > &tag, ! const WrappedInt &) { bool useGuards = tag.tag().intersector_m. --- 2104,2134 ---- ExpressionApply > > { typedef int Type_t; + typedef Engine > Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef ExpressionApply > Tag_t; ! inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &tag) { typedef typename MultiPatchLayoutTraits::Layout_t Layout_t; return applyHandler(engine, tag, WrappedInt()); } ! inline static ! Type_t apply(const Subject_t &engine, ! const LoopInvariant_t &li, ! const Tag_t &tag) ! { ! typedef typename MultiPatchLayoutTraits::Layout_t Layout_t; ! return applyHandler(engine, li, tag, WrappedInt()); ! } ! ! inline static ! Type_t applyHandler(const Subject_t &engine, ! const Tag_t &tag, ! const WrappedInt &) { bool useGuards = tag.tag().intersector_m. *************** struct LeafFunctor > &engine, ! const ExpressionApply > &tag, ! const WrappedInt &) { tag.tag().intersector_m.intersect(engine, GuardLayers()); return 0; } }; --- 2141,2171 ---- return 0; } ! inline static ! Type_t applyHandler(const Subject_t &engine, ! const LoopInvariant_t &, ! const Tag_t &tag, ! const WrappedInt &wi) ! { ! return applyHandler(engine, tag, wi); ! } ! ! inline static ! Type_t applyHandler(const Subject_t &engine, ! const Tag_t &tag, ! const WrappedInt &) { tag.tag().intersector_m.intersect(engine, GuardLayers()); return 0; + } + + inline static + Type_t applyHandler(const Subject_t &engine, + const LoopInvariant_t &, + const Tag_t &tag, + const WrappedInt &wi) + { + return applyHandler(engine, tag, wi); } }; Index: src/Engine/RemoteDynamicEngine.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/RemoteDynamicEngine.h,v retrieving revision 1.16 diff -c -p -r1.16 RemoteDynamicEngine.h *** src/Engine/RemoteDynamicEngine.h 2001/05/16 21:21:06 1.16 --- src/Engine/RemoteDynamicEngine.h 2001/11/05 19:28:26 *************** template *** 710,721 **** struct LeafFunctor >, EngineView > { typedef Engine<1, T, Remote > Subject_t; typedef Engine<1, T, Dynamic> Type_t; ! static inline Type_t apply(const Subject_t &engine, ! const EngineView &) { if (engine.engineIsLocal()) { --- 710,723 ---- struct LeafFunctor >, EngineView > { typedef Engine<1, T, Remote > Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef EngineView View_t; typedef Engine<1, T, Dynamic> Type_t; ! inline static Type_t apply(const Subject_t &engine, ! const View_t &) { if (engine.engineIsLocal()) { *************** struct LeafFunctor *************** struct LeafFunctor > { typedef Engine<1, T, Remote > Subject_t; typedef Engine<1, T, DynamicView> Type_t; ! static inline Type_t apply(const Subject_t &engine, ! const EngineView &) { if (engine.engineIsLocal()) { --- 747,760 ---- EngineView > { typedef Engine<1, T, Remote > Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef EngineView View_t; typedef Engine<1, T, DynamicView> Type_t; ! inline static Type_t apply(const Subject_t &engine, ! const View_t &) { if (engine.engineIsLocal()) { *************** struct LeafFunctor ElementRef_t; typedef Remote Tag_t; typedef DomainLayout Layout_t; + typedef typename LocalEngine_t::LoopInvariant_t + LoopInvariant_t; + // FIXME: Is this correct? Do I need to modify the read() functions? enum { dimensions = Dim }; enum { hasDataObject = true }; Index: src/Engine/Stencil.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/Stencil.h,v retrieving revision 1.44 diff -c -p -r1.44 Stencil.h *** src/Engine/Stencil.h 2001/09/14 22:37:56 1.44 --- src/Engine/Stencil.h 2001/11/05 19:28:26 *************** public: *** 273,278 **** --- 273,300 ---- enum { multiPatch = ExprEngine_t::multiPatch }; enum { zeroBased = true }; + class LoopInvariant_t { + public: + typedef typename Expression::LoopInvariant_t ExpressionLoopInvariant_t; + + LoopInvariant_t(const ExpressionLoopInvariant_t& eli, + const int* offset) + : eli_m(eli) { + for (int i = 0; i < D; ++i) + offset_m[i] = offset[i]; + } + + const ExpressionLoopInvariant_t& exprLoopInvariant() const + { return eli_m; } + + const int* offset() const { return offset_m; } + + private: + ExpressionLoopInvariant_t eli_m; + int offset_m[D]; + }; + + //============================================================ // Construct from a Function object (effectively a stencil) // and an expression (effectively the input array), and *************** public: *** 378,383 **** --- 400,444 ---- loc[2].first() + offset_m[2]); } + inline Element_t read(const LoopInvariant_t& li, int i) const + { + // Input index `i + offset_m[0]' corresponds to output index `i'. + return function()(expression_m, li.exprLoopInvariant(), + i + li.offset()[0]); + } + inline Element_t read(const LoopInvariant_t& li, int i, int j) const + { + return function()(expression_m, li.exprLoopInvariant(), + i + li.offset()[0], + j + li.offset()[1]); + } + inline Element_t read(const LoopInvariant_t& li, int i, int j, int k) const + { + return function()(expression_m, li.exprLoopInvariant(), + i + li.offset()[0], + j + li.offset()[1], + k + li.offset()[2]); + } + + inline Element_t read(const LoopInvariant_t& li, const Loc<1> &loc) const + { + return function()(expression_m, li.exprLoopInvariant(), + loc[0].first() + li.offset()[0]); + } + inline Element_t read(const LoopInvariant_t& li, const Loc<2> &loc) const + { + return function()(expression_m, li.exprLoopInvariant(), + loc[0].first() + li.offset()[0], + loc[1].first() + li.offset()[1]); + } + inline Element_t read(const LoopInvariant_t& li, const Loc<3> &loc) const + { + return function()(expression_m, li.exprLoopInvariant(), + loc[0].first() + li.offset()[0], + loc[1].first() + li.offset()[1], + loc[2].first() + li.offset()[2]); + } + //============================================================ // operator() are provided since users typically write stencils // as x(i, j) + x(i, j - 1), so for stencils of stencils to work *************** public: *** 474,479 **** --- 535,544 ---- inline const Function &function() const { return function_m; } inline const Expression &expression() const { return expression_m; } + inline const LoopInvariant_t loopInvariant() const + { return LoopInvariant_t(expression_m.loopInvariant(), + offset_m); } + private: Function function_m; *************** struct LeafFunctor > > { typedef int Type_t; ! ! static ! Type_t apply(const Engine > &engine, ! const ExpressionApply > &tag) { typedef StencilIntersector NewIntersector_t; NewIntersector_t newIntersector(engine.intersectDomain(), --- 920,932 ---- ExpressionApply > > { typedef int Type_t; ! typedef Engine > Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef ExpressionApply > Tag_t; ! ! inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &tag) { typedef StencilIntersector NewIntersector_t; NewIntersector_t newIntersector(engine.intersectDomain(), *************** struct LeafFunctor(newIntersector)); return 0; } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + typedef StencilIntersector NewIntersector_t; + NewIntersector_t newIntersector(engine.intersectDomain(), + tag.tag().intersector_m); + + // FIXME: Where is this defined? Revise it. + expressionApply(engine.expression(), li, + IntersectorTag(newIntersector)); + return 0; + } }; //--------------------------------------------------------------------------- *************** struct EngineFunctor struct LeafFunctor >, EngineView > { ! typedef LeafFunctor > LeafFunctor_t; typedef typename LeafFunctor_t::Type_t NewViewed_t; typedef Engine > Type_t; ! static ! Type_t apply(const Engine > &engine, ! const EngineView &tag) { return Type_t(engine.function(), LeafFunctor_t::apply(engine.expression(), tag)); } }; //----------------------------------------------------------------------------- --- 988,1016 ---- template struct LeafFunctor >, EngineView > { ! typedef Engine > Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef EngineView Tag_t; ! typedef LeafFunctor LeafFunctor_t; typedef typename LeafFunctor_t::Type_t NewViewed_t; typedef Engine > Type_t; ! inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &tag) { return Type_t(engine.function(), LeafFunctor_t::apply(engine.expression(), tag)); } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return Type_t(engine.function(), li, + LeafFunctor_t::apply(engine.expression(), tag)); + } }; //----------------------------------------------------------------------------- *************** struct LeafFunctor struct LeafFunctor >, ExpressionApply > { ! typedef LeafFunctor > LeafFunctor_t; typedef int Type_t; ! static ! Type_t apply(const Engine > &engine, ! const ExpressionApply &tag) { return LeafFunctor_t::apply(engine.expression(), tag); } }; --- 1023,1047 ---- template struct LeafFunctor >, ExpressionApply > { ! typedef Engine > Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef ExpressionApply Tag_t; ! typedef LeafFunctor LeafFunctor_t; typedef int Type_t; ! inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &tag) { return LeafFunctor_t::apply(engine.expression(), tag); + } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return LeafFunctor_t::apply(engine.expression(), li, tag); } }; Index: src/Engine/UserFunction.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/UserFunction.h,v retrieving revision 1.28 diff -c -p -r1.28 UserFunction.h *** src/Engine/UserFunction.h 2001/09/14 22:37:57 1.28 --- src/Engine/UserFunction.h 2001/11/05 19:28:26 *************** public: *** 142,147 **** --- 142,153 ---- typedef T Element_t; typedef ErrorType ElementRef_t; typedef typename Expression::Engine_t ExprEngine_t; + + // Values that do not change during the evaluation of a single + // data parallel statement. + + typedef typename Expression::LoopInvariant_t LoopInvariant_t; + enum { dimensions = D }; enum { hasDataObject = ExprEngine_t::hasDataObject }; enum { dynamic = false }; *************** public: *** 203,208 **** --- 209,256 ---- return userFunction_m(expression_m.read(i,j,k,l,m,n,o)); } + // HERE + inline Element_t read(const LoopInvariant_t &li, + const Loc &loc) const + { + return userFunction_m(expression_m.read(li, loc)); + } + inline Element_t read(const LoopInvariant_t &li, + int i) const + { + return userFunction_m(expression_m.read(li, i)); + } + inline Element_t read(const LoopInvariant_t &li, + int i, int j) const + { + return userFunction_m(expression_m.read(li, i,j)); + } + inline Element_t read(const LoopInvariant_t &li, + int i, int j, int k) const + { + return userFunction_m(expression_m.read(li, i,j,k)); + } + inline Element_t read(const LoopInvariant_t &li, + int i, int j, int k, int l) const + { + return userFunction_m(expression_m.read(li, i,j,k,l)); + } + inline Element_t read(const LoopInvariant_t &li, + int i, int j, int k, int l,int m) const + { + return userFunction_m(expression_m.read(li, i,j,k,l,m)); + } + inline Element_t read(const LoopInvariant_t &li, + int i, int j, int k, int l,int m,int n) const + { + return userFunction_m(expression_m.read(li, i,j,k,l,m,n)); + } + inline Element_t read(const LoopInvariant_t &li, + int i, int j, int k, int l,int m,int n,int o) const + { + return userFunction_m(expression_m.read(li, i,j,k,l,m,n,o)); + } + inline Element_t operator()(const Loc &loc) const { return userFunction_m(expression_m(loc)); *************** public: *** 271,276 **** --- 319,333 ---- return engineFunctor(expression_m.engine(),f); } + //--------------------------------------------------------------------------- + // Values that do not change during the evaluation of a single + // data parallel statement. + //--------------------------------------------------------------------------- + + inline + const LoopInvariant_t loopInvariant() const + { return expression_m.loopInvariant(); } + private: UserFunction userFunction_m; Expression expression_m; *************** struct EngineFunctor::Type_t Type_t; ! static Type_t apply(const Engine > &engine, const EFTag &tag) { --- 504,510 ---- { typedef typename EngineFunctor::Type_t Type_t; ! inline static Type_t apply(const Engine > &engine, const EFTag &tag) { *************** template >, EngineView > { ! typedef LeafFunctor > LeafFunctor_t; typedef typename LeafFunctor_t::Type_t NewViewed_t; typedef Engine > Type_t; ! static ! Type_t apply(const Engine > &engine, ! const EngineView &tag) { return Type_t(engine.userFunction(), LeafFunctor_t::apply(engine.expression(), tag)); } }; template struct LeafFunctor >, ExpressionApply > { ! typedef LeafFunctor > LeafFunctor_t; typedef int Type_t; ! static ! Type_t apply(const Engine > &engine, ! const ExpressionApply &tag) { return LeafFunctor_t::apply(engine.expression(), tag); } }; --- 516,569 ---- struct LeafFunctor >, EngineView > { ! typedef Engine > Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef EngineView Tag_t; ! typedef LeafFunctor LeafFunctor_t; typedef typename LeafFunctor_t::Type_t NewViewed_t; typedef Engine > Type_t; ! inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &tag) { return Type_t(engine.userFunction(), LeafFunctor_t::apply(engine.expression(), tag)); } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return Type_t(engine.userFunction(), li, + LeafFunctor_t::apply(engine.expression(), tag)); + } }; template struct LeafFunctor >, ExpressionApply > { ! typedef Engine > Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef ExpressionApply Tag_t; ! typedef LeafFunctor LeafFunctor_t; typedef int Type_t; ! inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &tag) { return LeafFunctor_t::apply(engine.expression(), tag); + } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return LeafFunctor_t::apply(engine.expression(), li, tag); } }; Index: src/Engine/ViewEngine.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/ViewEngine.h,v retrieving revision 1.23 diff -c -p -r1.23 ViewEngine.h *** src/Engine/ViewEngine.h 2001/08/30 01:15:04 1.23 --- src/Engine/ViewEngine.h 2001/11/05 19:28:26 *************** public: *** 99,104 **** --- 99,106 ---- typedef DomainLayout Layout_t; typedef T Element_t; typedef ErrorType ElementRef_t; + typedef typename ViewedEngine_t::LoopInvariant_t LoopInvariant_t; + // FIXME: modify read()? enum { dimensions = Dim }; enum { hasDataObject = ViewedEngine_t::hasDataObject }; *************** public: *** 260,265 **** --- 262,318 ---- return eng_m.read(oloc); } + // HERE + inline Element_t read(const LoopInvariant_t &li, int i0) const + { + Loc oloc; + indexer_m.translate(i0, oloc); + return eng_m.read(li, oloc); + } + inline Element_t read(const LoopInvariant_t &li, int i0, int i1) const + { + Loc oloc; + indexer_m.translate(i0, i1, oloc); + return eng_m.read(li, oloc); + } + inline Element_t read(const LoopInvariant_t &li, int i0, int i1, int i2) const + { + Loc oloc; + indexer_m.translate(i0, i1, i2, oloc); + return eng_m.read(li, oloc); + } + inline Element_t read(const LoopInvariant_t &li, int i0, int i1, int i2, int i3) const + { + Loc oloc; + indexer_m.translate(i0, i1, i2, i3, oloc); + return eng_m.read(li, oloc); + } + inline Element_t read(const LoopInvariant_t &li, int i0, int i1, int i2, int i3, int i4) const + { + Loc oloc; + indexer_m.translate(i0, i1, i2, i3, i4, oloc); + return eng_m.read(li, oloc); + } + inline Element_t read(const LoopInvariant_t &li, int i0, int i1, int i2, int i3, int i4, int i5) const + { + Loc oloc; + indexer_m.translate(i0, i1, i2, i3, i4, i5, oloc); + return eng_m.read(li, oloc); + } + inline Element_t read(const LoopInvariant_t &li, int i0, int i1, int i2, int i3, int i4, + int i5, int i6) const + { + Loc oloc; + indexer_m.translate(i0, i1, i2, i3, i4, i5, i6, oloc); + return eng_m.read(li, oloc); + } + inline Element_t read(const LoopInvariant_t &li, const Loc &loc) const + { + Loc oloc; + indexer_m.translate(loc, oloc); + return eng_m.read(li, oloc); + } + //--------------------------------------------------------------------------- // Return the domain. *************** public: *** 292,297 **** --- 345,357 ---- return eng_m.dataObjectRequest(f); } + //--------------------------------------------------------------------------- + // Yield values that do not change during the evaluation of a single + // data parallel statement. + inline + const LoopInvariant_t loopInvariant() const + { return eng_m.loopInvariant(); } + private: ViewedEngine_t eng_m; *************** struct LeafFunctor< Engine > Engine_t; ! ! static Type_t ! apply(const Engine_t &, ! const ExpressionApply > &, ! const WrappedInt &) { return 0; } ! static Type_t ! apply(const Engine_t &engine, ! const ExpressionApply > &tag, ! const WrappedInt &) { enum { d1 = Intersect::dimensions }; ViewIntersector newIntersector(engine.indexer(), --- 662,692 ---- { typedef int Type_t; typedef Engine > Engine_t; ! typedef Engine_t Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef ExpressionApply > Tag_t; ! ! inline static ! Type_t apply(const Engine_t &, ! const Tag_t &, ! const WrappedInt &) { return 0; } ! inline static ! Type_t apply(const Engine_t &e, ! const LoopInvariant_t &, ! const Tag_t &t, ! const WrappedInt &wi) ! { ! return apply(e,t,wi); ! } ! ! inline static ! Type_t apply(const Engine_t &engine, ! const Tag_t &tag, ! const WrappedInt &) { enum { d1 = Intersect::dimensions }; ViewIntersector newIntersector(engine.indexer(), *************** struct LeafFunctor< Engine > &tag) { enum { multiPatch = Engine >::multiPatch }; return apply(engine, tag, WrappedInt()); } }; //--------------------------------------------------------------------------- --- 698,739 ---- return 0; } ! inline static ! Type_t apply(const Engine_t &engine, ! const LoopInvariant_t &li, ! const Tag_t &tag, ! const WrappedInt &) { + enum { d1 = Intersect::dimensions }; + ViewIntersector newIntersector(engine.indexer(), + tag.tag().intersector_m); + ExpressionApply > > + newTag(newIntersector); + + forEach(engine.viewedEngine(), li, newTag, NullCombine()); + return 0; + } + + inline static + Type_t apply(const Engine_t &engine, + const Tag_t &tag) + { enum { multiPatch = Engine >::multiPatch }; return apply(engine, tag, WrappedInt()); } + + inline static + Type_t apply(const Engine_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + enum { multiPatch = + Engine >::multiPatch }; + + return apply(engine, li, tag, WrappedInt()); + } }; //--------------------------------------------------------------------------- *************** template >, ExpressionApply > { typedef Engine > Subject_t; typedef typename Subject_t::ViewedEngine_t Engine_t; ! typedef LeafFunctor > LeafFunctor_t; typedef int Type_t; ! static ! Type_t apply(const Subject_t &engine, const ExpressionApply &tag) { return LeafFunctor_t::apply(engine.viewedEngine(), tag); } }; --- 761,784 ---- struct LeafFunctor >, ExpressionApply > { typedef Engine > Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef ExpressionApply Tag_t; typedef typename Subject_t::ViewedEngine_t Engine_t; ! typedef LeafFunctor LeafFunctor_t; typedef int Type_t; ! inline static ! Type_t apply(const Subject_t &engine, const Tag_t &tag) { return LeafFunctor_t::apply(engine.viewedEngine(), tag); + } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return LeafFunctor_t::apply(engine.viewedEngine(), li, tag); } }; Index: src/Evaluator/EvaluatorTags.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Evaluator/EvaluatorTags.h,v retrieving revision 1.17 diff -c -p -r1.17 EvaluatorTags.h *** src/Evaluator/EvaluatorTags.h 2000/03/28 23:30:39 1.17 --- src/Evaluator/EvaluatorTags.h 2001/11/05 19:28:26 *************** struct Combine2 // ! // This struct computes the evaluator tag for a single expression.. //----------------------------------------------------------------------------- template --- 266,272 ---- //----------------------------------------------------------------------------- // EvaluatorTag // ! // This struct computes the evaluator tag for a single expression. //----------------------------------------------------------------------------- template Index: src/Evaluator/InlineEvaluator.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Evaluator/InlineEvaluator.h,v retrieving revision 1.26 diff -c -p -r1.26 InlineEvaluator.h *** src/Evaluator/InlineEvaluator.h 2001/04/13 02:15:06 1.26 --- src/Evaluator/InlineEvaluator.h 2001/11/05 19:28:26 *************** struct KernelEvaluator *** 157,165 **** { CTAssert(Domain::unitStride); PAssert(domain[0].first() == 0); int e0 = domain[0].length(); for (int i0=0; i0 --- 157,169 ---- { CTAssert(Domain::unitStride); PAssert(domain[0].first() == 0); + // TMP typedef typename LHS::Engine_t::LoopInvariant_t LHSLoopInvariant_t; + typedef typename RHS::Engine_t::LoopInvariant_t RHSLoopInvariant_t; + // TMP const LHSLoopInvariant_t lli = lhs.loopInvariant(); + const RHSLoopInvariant_t rli = rhs.loopInvariant(); int e0 = domain[0].length(); for (int i0=0; i0 *************** struct KernelEvaluator *** 169,179 **** CTAssert(Domain::unitStride); PAssert(domain[0].first() == 0); PAssert(domain[1].first() == 0); int e0 = domain[0].length(); int e1 = domain[1].length(); for (int i1=0; i1 --- 173,187 ---- CTAssert(Domain::unitStride); PAssert(domain[0].first() == 0); PAssert(domain[1].first() == 0); + // TMP typedef typename LHS::Engine_t::LoopInvariant_t LHSLoopInvariant_t; + typedef typename RHS::Engine_t::LoopInvariant_t RHSLoopInvariant_t; + // TMP const LHSLoopInvariant_t lli = lhs.loopInvariant(); + const RHSLoopInvariant_t rli = rhs.loopInvariant(); int e0 = domain[0].length(); int e1 = domain[1].length(); for (int i1=0; i1 *************** struct KernelEvaluator *** 184,196 **** PAssert(domain[0].first() == 0); PAssert(domain[1].first() == 0); PAssert(domain[2].first() == 0); int e0 = domain[0].length(); int e1 = domain[1].length(); int e2 = domain[2].length(); for (int i2=0; i2 --- 192,208 ---- PAssert(domain[0].first() == 0); PAssert(domain[1].first() == 0); PAssert(domain[2].first() == 0); + // TMP typedef typename LHS::Engine_t::LoopInvariant_t LHSLoopInvariant_t; + typedef typename RHS::Engine_t::LoopInvariant_t RHSLoopInvariant_t; + // TMP const LHSLoopInvariant_t lli = lhs.loopInvariant(); + const RHSLoopInvariant_t rli = rhs.loopInvariant(); int e0 = domain[0].length(); int e1 = domain[1].length(); int e2 = domain[2].length(); for (int i2=0; i2 *************** struct KernelEvaluator *** 202,207 **** --- 214,223 ---- PAssert(domain[1].first() == 0); PAssert(domain[2].first() == 0); PAssert(domain[3].first() == 0); + // TMP typedef typename LHS::Engine_t::LoopInvariant_t LHSLoopInvariant_t; + typedef typename RHS::Engine_t::LoopInvariant_t RHSLoopInvariant_t; + // TMP const LHSLoopInvariant_t lli = lhs.loopInvariant(); + const RHSLoopInvariant_t rli = rhs.loopInvariant(); int e0 = domain[0].length(); int e1 = domain[1].length(); int e2 = domain[2].length(); *************** struct KernelEvaluator *** 210,216 **** for (int i2=0; i2 --- 226,232 ---- for (int i2=0; i2 *************** struct KernelEvaluator *** 223,228 **** --- 239,248 ---- PAssert(domain[2].first() == 0); PAssert(domain[3].first() == 0); PAssert(domain[4].first() == 0); + // TMP typedef typename LHS::Engine_t::LoopInvariant_t LHSLoopInvariant_t; + typedef typename RHS::Engine_t::LoopInvariant_t RHSLoopInvariant_t; + // TMP const LHSLoopInvariant_t lli = lhs.loopInvariant(); + const RHSLoopInvariant_t rli = rhs.loopInvariant(); int e0 = domain[0].length(); int e1 = domain[1].length(); int e2 = domain[2].length(); *************** struct KernelEvaluator *** 233,239 **** for (int i2=0; i2 --- 253,259 ---- for (int i2=0; i2 *************** struct KernelEvaluator *** 247,252 **** --- 267,276 ---- PAssert(domain[3].first() == 0); PAssert(domain[4].first() == 0); PAssert(domain[5].first() == 0); + // TMP typedef typename LHS::Engine_t::LoopInvariant_t LHSLoopInvariant_t; + typedef typename RHS::Engine_t::LoopInvariant_t RHSLoopInvariant_t; + // TMP const LHSLoopInvariant_t lli = lhs.loopInvariant(); + const RHSLoopInvariant_t rli = rhs.loopInvariant(); int e0 = domain[0].length(); int e1 = domain[1].length(); int e2 = domain[2].length(); *************** struct KernelEvaluator *** 259,266 **** for (int i2=0; i2 --- 283,290 ---- for (int i2=0; i2 *************** struct KernelEvaluator *** 275,280 **** --- 299,308 ---- PAssert(domain[4].first() == 0); PAssert(domain[5].first() == 0); PAssert(domain[6].first() == 0); + // TMP typedef typename LHS::Engine_t::LoopInvariant_t LHSLoopInvariant_t; + typedef typename RHS::Engine_t::LoopInvariant_t RHSLoopInvariant_t; + // TMP const LHSLoopInvariant_t lli = lhs.loopInvariant(); + const RHSLoopInvariant_t rli = rhs.loopInvariant(); int e0 = domain[0].length(); int e1 = domain[1].length(); int e2 = domain[2].length(); *************** struct KernelEvaluator *** 289,296 **** for (int i2=0; i2 *** 477,491 **** struct LeafFunctor, ExpressionApply > { typedef int Type_t; inline static ! Type_t apply(const MultiArg1 &multiarg, ! const ExpressionApply &tag) { leafFunctor(multiarg.a1_m, tag); return 0; } }; template struct LeafFunctor, EngineView > --- 477,506 ---- struct LeafFunctor, ExpressionApply > { typedef int Type_t; + typedef MultiArg1 Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef ExpressionApply Tag_t; inline static ! Type_t apply(const Subject_t &multiarg, ! const Tag_t &tag) { leafFunctor(multiarg.a1_m, tag); return 0; } + + inline static + Type_t apply(const Subject_t &multiarg, + const LoopInvariant_t &li, + const Tag_t &tag) + { + // FIXME: Do I use li or some data member inside it? + leafFunctor(multiarg.a1_m, li, tag); + return 0; + } }; + + // HERE FIXME: Fix below. template struct LeafFunctor, EngineView > Index: src/Evaluator/OpMask.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Evaluator/OpMask.h,v retrieving revision 1.19 diff -c -p -r1.19 OpMask.h *** src/Evaluator/OpMask.h 2001/03/20 23:42:48 1.19 --- src/Evaluator/OpMask.h 2001/11/05 19:28:26 *************** struct ForEach< BinaryNode Type_t; // How to evaluate the expression. ! inline ! static Type_t ! apply(const BinaryNode& expr, ! const FTag &f, const OpCombine &c) { // Evaluate the left. bool mask = forEach(expr.left(), f, c); --- 217,231 ---- // The return type for the expression. typedef MaskAssign Type_t; + // Other useful typedefs. + typedef BinaryNode Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef OpCombine CTag; + // How to evaluate the expression. ! inline static ! Type_t apply(const Subject_t& expr, ! const FTag &f, const CTag &c) { // Evaluate the left. bool mask = forEach(expr.left(), f, c); *************** struct ForEach< BinaryNode --- 124,138 ---- { CTAssert(Domain::unitStride); PAssert(domain[0].first() == 0); ! // TMP typedef typename T::Engine_t::LoopInvariant_t TLoopInvariant_t; ! typedef typename Expr::Engine_t::LoopInvariant_t ExprLoopInvariant_t; ! // TMP const TLoopInvariant_t lli = ret.loopInvariant(); ! const ExprLoopInvariant_t rli = e.loopInvariant(); ! int e0 = domain[0].length(); ! ret = e.read(/* TMP lli, */ 0); for (int i0 = 1; i0 < e0; ++i0) ! op(ret, e.read(rli, i0)); } template *************** struct ReductionEvaluator > > { typedef int Type_t; ! ! static Type_t ! apply(const Engine > &engine, ! const ExpressionApply > &apply) { apply.tag().intersect(engine); --- 274,286 ---- ExpressionApply > > { typedef int Type_t; ! typedef Engine > Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef ExpressionApply > Tag_t; ! ! inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &apply) { apply.tag().intersect(engine); *************** struct LeafFunctor *************** struct LeafFunctor > > { typedef int Type_t; ! ! static Type_t ! apply(const Engine > &engine, ! const ExpressionApply > &apply) { apply.tag().intersect(engine); --- 304,316 ---- ExpressionApply > > { typedef int Type_t; ! typedef Engine > Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef ExpressionApply > Tag_t; ! ! inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &apply) { apply.tag().intersect(engine); *************** struct LeafFunctor + inline static + ReadType_t makeRead(const Subject_t &f, + const typename Subject_t::LoopInvariant_t& li, + const S1 &s1, const S2 &s2, + const Combine &) + { + PAssert(f.numSubFields() == 0); + + Domain s(Combine::make(f, s1, s2)); + #if POOMA_BOUNDS_CHECK + PInsist(contains(f.totalDomain(), s), + "Field view bounds error."); + #endif + return f.engine().read(li, s); + } + template inline static *************** struct View1Implementation + inline static + Type_t makeRead(const Subject_t &f, + const typename Subject_t::LoopInvariant_t& li, + const S1 &s1, const S2 &s2, + const Combine &c) + { + return make(f, li, s1, s2, c); + } + template inline static *************** struct View2, *** 743,748 **** --- 770,782 ---- { return Dispatch_t::makeRead(f, s1, s2, Combine_t()); } + + inline static + ReadType_t makeRead(const Subject_t &f, const typename Subject_t::LoopInvariant_t& li, + const Sub1 &s1, const Sub2 &s2) + { + return Dispatch_t::makeRead(f, li, s1, s2, Combine_t()); + } }; *************** struct View2, *** 788,793 **** --- 822,842 ---- #endif return f.engine().read(s1, s2); } + + inline static + ReadType_t makeRead(const Subject_t &f, + const typename Subject_t::LoopInvariant_t& li, + int s1, int s2) + { + PAssert(f.numSubFields() == 0); + + #if POOMA_BOUNDS_CHECK + PInsist(contains(f.totalDomain(), Loc<2>(s1, s2)), + "Field view bounds error."); + #endif + return f.engine().read(li, s1, s2); + } + }; *************** public: *** 1117,1130 **** typedef typename Engine_t::Layout_t Layout_t; ! // The types of the our domains. typedef typename Engine_t::Domain_t Domain_t; ! // The types of the our centering. typedef Centering Centering_t; //--------------------------------------------------------------------------- // User-callable constructors. These ctors are meant to be called by users. --- 1166,1184 ---- typedef typename Engine_t::Layout_t Layout_t; ! // The types of our domains. typedef typename Engine_t::Domain_t Domain_t; ! // The types of our centering. typedef Centering Centering_t; + // Values that do not change during the evaluation of a single + // data parallel statement. + + typedef typename Engine_t::LoopInvariant_t LoopInvariant_t; + //--------------------------------------------------------------------------- // User-callable constructors. These ctors are meant to be called by users. *************** public: *** 1330,1335 **** --- 1384,1394 ---- { return fieldEngine_m.engine().layout(); } + + inline LoopInvariant_t loopInvariant() const + { + return fieldEngine_m.engine().loopInvariant(); + } //--------------------------------------------------------------------------- // Instruct the field to make its own copy of its data. *************** public: *** 1415,1420 **** --- 1474,1488 ---- return Ret_t::makeRead(*this, s1, s2); } + template + inline typename View2::ReadType_t + read(const typename This_t::LoopInvariant_t& li, + const Sub1 &s1, const Sub2 &s2) const + { + typedef View2 Ret_t; + return Ret_t::makeRead(*this, li, s1, s2); + } + template inline typename View3::ReadType_t read(const Sub1 &s1, const Sub2 &s2, const Sub3 &s3) const *************** template, ConformTag > { typedef bool Type_t; ! static Type_t apply1(const Interval &d, ! const ConformTag &ct) { return conforms(d, ct); } template ! static Type_t apply1(const Interval &d, ! const ConformTag &ct) { return false; } ! static Type_t apply(const Field &f, ! const ConformTag &ct) { return apply1(f.physicalDomain(), ct); } }; --- 1770,1808 ---- struct LeafFunctor, ConformTag > { typedef bool Type_t; ! typedef Field Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef ConformTag Tag_t; ! ! inline static ! Type_t apply1(const Interval &d, ! const Tag_t &ct) { return conforms(d, ct); } + template ! inline static ! Type_t apply1(const Interval &d, ! const Tag_t &ct) { return false; } ! ! inline static ! Type_t apply(const Subject_t &f, ! const Tag_t &ct) { return apply1(f.physicalDomain(), ct); } + + inline static + Type_t apply(const Subject_t &f, + const LoopInvariant_t &li, + const Tag_t &ct) + { + return apply(f, ct); + } }; *************** struct LeafFunctor > { typedef Field Subject_t; typedef typename Subject_t::FieldEngine_t FieldEngine_t; ! typedef LeafFunctor > ! LeafFunctor_t; typedef typename LeafFunctor_t::Type_t Type_t; enum { dataObject = LeafFunctor_t::dataObject }; inline static Type_t apply(const Subject_t &f, ! const DataObjectRequest &functor) { return LeafFunctor_t::apply(field.fieldEngine(), functor); } }; template struct LeafFunctor, DataObjectRequest > { typedef typename FieldEngine::Engine_t Engine_t; enum { dataObject = Engine_t::dataObject }; ! typedef typename DataObjectRequest::Type_t Type_t; inline static ! Type_t apply(const FieldEngine &f, ! const DataObjectRequest &functor) { return DataObjectApply::apply(f.engine(), functor); } }; --- 1818,1872 ---- DataObjectRequest > { typedef Field Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef DataObjectRequest Tag_t; typedef typename Subject_t::FieldEngine_t FieldEngine_t; ! typedef LeafFunctor LeafFunctor_t; typedef typename LeafFunctor_t::Type_t Type_t; enum { dataObject = LeafFunctor_t::dataObject }; inline static Type_t apply(const Subject_t &f, ! const Tag_t &functor) { return LeafFunctor_t::apply(field.fieldEngine(), functor); } + + inline static + Type_t apply(const Subject_t &f, + const LoopInvariant_t &li, + const Tag_t &functor) + { + return LeafFunctor_t::apply(field.fieldEngine(), li, functor); + } }; template struct LeafFunctor, DataObjectRequest > { + typedef FieldEngine Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef DataObjectRequest Tag_t; typedef typename FieldEngine::Engine_t Engine_t; enum { dataObject = Engine_t::dataObject }; ! typedef typename Tag_t::Type_t Type_t; ! inline static ! Type_t apply(const Subject_t &f, ! const Tag_t &functor) { return DataObjectApply::apply(f.engine(), functor); } + + inline static + Type_t apply(const Subject_t &f, + const LoopInvariant_t &li, + const Tag_t &functor) + { + return DataObjectApply::apply(f.engine(), li, functor); + } }; *************** struct LeafFunctor struct LeafFunctor, DomainFunctorTag> { ! typedef typename Field::Domain_t Type_t; ! inline static Type_t apply(const Field &f, ! const DomainFunctorTag &) { // Return zero-based domain. return f.physicalDomain() - f.physicalDomain().firsts(); } }; //----------------------------------------------------------------------------- ! // This specialization of LeafFunctor is used to pass the ExpressionApply ! // functor ! // down into the FieldEngine. The default behavior, given in the functor ! // below, is to just pass it on to the fieldEngine's engine. //----------------------------------------------------------------------------- template struct LeafFunctor, ExpressionApply > { typedef Field Subject_t; typedef typename Subject_t::FieldEngine_t FieldEngine_t; ! typedef LeafFunctor > LeafFunctor_t; typedef int Type_t; inline static Type_t apply(const Subject_t &field, ! const ExpressionApply &tag) { return LeafFunctor_t::apply(field.fieldEngine(), tag); } }; template struct LeafFunctor, EngineView > { typedef Field Subject_t; typedef typename Subject_t::Engine_t Engine_t; ! typedef typename LeafFunctor >::Type_t NewEngine_t; typedef typename NewEngine_t::Tag_t NewEngineTag_t; // Don't bother computing NewGeometry tag yet. --- 1878,1948 ---- template struct LeafFunctor, DomainFunctorTag> { ! typedef Field Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef DomainFunctorTag Tag_t; ! typedef typename Subject_t::Domain_t Type_t; ! inline static ! Type_t apply(const Subject_t &f, ! const Tag_t &) { // Return zero-based domain. return f.physicalDomain() - f.physicalDomain().firsts(); } + + inline static + Type_t apply(const Subject_t &f, + const LoopInvariant_t &li, + const Tag_t &t) + { + return apply(f,t); + } }; //----------------------------------------------------------------------------- ! // This specialization of LeafFunctor is used to pass the ! // ExpressionApply functor down into the FieldEngine. The default ! // behavior, given in the functor below, is to just pass it on to the ! // fieldEngine's engine. //----------------------------------------------------------------------------- template struct LeafFunctor, ExpressionApply > { typedef Field Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; typedef typename Subject_t::FieldEngine_t FieldEngine_t; ! typedef ExpressionApply Tag_t; ! typedef LeafFunctor LeafFunctor_t; typedef int Type_t; inline static Type_t apply(const Subject_t &field, ! const Tag_t &tag) { return LeafFunctor_t::apply(field.fieldEngine(), tag); } + + inline static + Type_t apply(const Subject_t &field, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return LeafFunctor_t::apply(field.fieldEngine(), li, tag); + } }; template struct LeafFunctor, EngineView > { typedef Field Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; typedef typename Subject_t::Engine_t Engine_t; ! typedef EngineView Tag_t; ! typedef typename LeafFunctor::Type_t NewEngine_t; typedef typename NewEngine_t::Tag_t NewEngineTag_t; // Don't bother computing NewGeometry tag yet. *************** struct LeafFunctor &tag) { return Type_t(field, tag); } }; --- 1952,1969 ---- inline static Type_t apply(const Subject_t &field, ! const Tag_t &tag) { return Type_t(field, tag); } + + inline static + Type_t apply(const Subject_t &field, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return Type_t(field, li, tag); + } }; *************** struct LeafFunctor struct LeafFunctor, EngineFunctorTag > { ! typedef typename Field::Engine_t Engine_t; typedef typename EngineFunctor::Type_t Type_t; inline static ! Type_t apply(const Field &field, ! const EngineFunctorTag &tag) { return EngineFunctor::apply(field.engine(), tag.tag()); } }; --- 1974,1999 ---- template struct LeafFunctor, EngineFunctorTag > { ! typedef Field Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef typename Subject_t::Engine_t Engine_t; ! typedef EngineFunctorTag Tag_t; typedef typename EngineFunctor::Type_t Type_t; + inline static ! Type_t apply(const Subject_t &field, ! const Tag_t &tag) { return EngineFunctor::apply(field.engine(), tag.tag()); } + + inline static + Type_t apply(const Subject_t &field, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return EngineFunctor::apply(field.engine(), li, tag.tag()); + } }; *************** struct EngineFunctor struct LeafFunctor, EvalLeaf > { typedef typename Field::Element_t Type_t; inline static ! Type_t apply(const Field &f, ! const EvalLeaf &t) { return t.eval(f.engine()); } }; --- 2024,2048 ---- template struct LeafFunctor, EvalLeaf > { + typedef Field Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef EvalLeaf Tag_t; typedef typename Field::Element_t Type_t; + inline static ! Type_t apply(const Subject_t &f, ! const Tag_t &t) { return t.eval(f.engine()); } + + inline static + Type_t apply(const Subject_t &f, + const LoopInvariant_t &li, + const Tag_t &t) + { + return t.eval(f.engine(), li); + } }; *************** template *** 1910,1921 **** struct LeafFunctor { typedef int Type_t; inline static ! Type_t apply(const Node &, const PerformUpdateTag &) ! { ! return 0; ! } }; --- 2072,2094 ---- struct LeafFunctor { typedef int Type_t; + typedef Node Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef PerformUpdateTag Tag_t; inline static ! Type_t apply(const Subject_t &, const Tag_t &) ! { ! return 0; ! } ! ! inline static ! Type_t apply(const Subject_t &s, ! const LoopInvariant_t &, ! const Tag_t &t) ! { ! return apply(s,t); ! } }; *************** template, PerformUpdateTag> { - typedef Field Subject_t; typedef int Type_t; inline static ! Type_t apply(const Subject_t &f, const PerformUpdateTag &) { f.applyRelations(); return 0; } }; template struct LeafFunctor >, PerformUpdateTag> { - typedef Field > Subject_t; typedef int Type_t; inline static ! Type_t apply(const Subject_t &f, const PerformUpdateTag &tag) { forEach(f.engine().expression(), tag, NullCombine()); return 0; } }; --- 2096,2144 ---- struct LeafFunctor, PerformUpdateTag> { typedef int Type_t; + typedef Field Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef PerformUpdateTag Tag_t; inline static ! Type_t apply(const Subject_t &f, const Tag_t &) { f.applyRelations(); return 0; } + + inline static + Type_t apply(const Subject_t &s, + const LoopInvariant_t &, + const Tag_t &t) + { + return apply(s,t); + } }; template struct LeafFunctor >, PerformUpdateTag> { typedef int Type_t; + typedef Field > Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef PerformUpdateTag Tag_t; inline static ! Type_t apply(const Subject_t &f, const Tag_t &tag) { forEach(f.engine().expression(), tag, NullCombine()); + return 0; + } + + inline static + Type_t apply(const Subject_t &f, + const LoopInvariant_t &li, + const Tag_t &tag) + { + forEach(f.engine().expression(), li, tag, NullCombine()); return 0; } }; Index: src/PETE/ForEach.h =================================================================== RCS file: /home/pooma/Repository/r2/src/PETE/ForEach.h,v retrieving revision 1.25 diff -c -p -r1.25 ForEach.h *** src/PETE/ForEach.h 2000/12/04 21:19:37 1.25 --- src/PETE/ForEach.h 2001/11/05 19:28:26 *************** template::Type_t Type_t; + typedef typename Expr::LoopInvariant_t LoopInvariant_t; + inline static Type_t apply(const Expr &expr, const FTag &f, const CTag &) { return LeafFunctor::apply(expr, f); } + + inline static + Type_t apply(const Expr &expr, + const typename Expr::LoopInvariant_t &li, + const FTag &f, const CTag &) + { + return LeafFunctor::apply(expr, li, f); + } }; template *************** forEach(const Expr &e, const FTag &f, co *** 89,106 **** return ForEach::apply(e, f, c); } template struct ForEach, FTag, CTag> { typedef typename ForEach::Type_t TypeA_t; typedef typename Combine1::Type_t Type_t; inline static ! Type_t apply(const UnaryNode &expr, const FTag &f, ! const CTag &c) { return Combine1:: combine(ForEach::apply(expr.child(), f, c), c); } }; template --- 99,136 ---- return ForEach::apply(e, f, c); } + template + inline typename ForEach::Type_t + forEach(const Expr &e, const typename Expr::LoopInvariant_t &li, + const FTag &f, const CTag &c) + { + return ForEach::apply(e, li, f, c); + } + template struct ForEach, FTag, CTag> { typedef typename ForEach::Type_t TypeA_t; typedef typename Combine1::Type_t Type_t; + typedef UnaryNode Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + inline static ! Type_t apply(const Subject_t &expr, const FTag &f, ! const CTag &c) { return Combine1:: combine(ForEach::apply(expr.child(), f, c), c); } + + inline static + Type_t apply(const Subject_t &expr, + const LoopInvariant_t &li, + const FTag &f, const CTag &c) + { + return Combine1:: + combine(ForEach::apply(expr.child(), li.child(), f, c), c); + } }; template *************** struct ForEach, FTa *** 109,123 **** typedef typename ForEach::Type_t TypeA_t; typedef typename ForEach::Type_t TypeB_t; typedef typename Combine2::Type_t Type_t; inline static ! Type_t apply(const BinaryNode &expr, const FTag &f, ! const CTag &c) { return Combine2:: combine(ForEach::apply(expr.left(), f, c), ForEach::apply(expr.right(), f, c), c); } }; template --- 139,167 ---- typedef typename ForEach::Type_t TypeA_t; typedef typename ForEach::Type_t TypeB_t; typedef typename Combine2::Type_t Type_t; + typedef BinaryNode Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + inline static ! Type_t apply(const Subject_t &expr, ! const FTag &f, const CTag &c) { return Combine2:: combine(ForEach::apply(expr.left(), f, c), ForEach::apply(expr.right(), f, c), c); } + + inline static + Type_t apply(const Subject_t &expr, + const LoopInvariant_t &li, + const FTag &f, const CTag &c) + { + return Combine2:: + combine(ForEach::apply(expr.left(), li.left(), f, c), + ForEach::apply(expr.right(), li.right(), f, c), + c); + } }; template *************** struct ForEach, *** 128,136 **** typedef typename ForEach::Type_t TypeC_t; typedef typename Combine3::Type_t Type_t; inline static ! Type_t apply(const TrinaryNode &expr, const FTag &f, ! const CTag &c) { return Combine3:: combine(ForEach::apply(expr.left(), f, c), --- 172,183 ---- typedef typename ForEach::Type_t TypeC_t; typedef typename Combine3::Type_t Type_t; + typedef TrinaryNode Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + inline static ! Type_t apply(const Subject_t&expr, ! const FTag &f, const CTag &c) { return Combine3:: combine(ForEach::apply(expr.left(), f, c), *************** struct ForEach, *** 138,143 **** --- 185,202 ---- ForEach::apply(expr.right(), f, c), c); } + + inline static + Type_t apply(const Subject_t &expr, + const LoopInvariant_t &li, + const FTag &f, const CTag &c) + { + return Combine3:: + combine(ForEach::apply(expr.left(), li.left(), f, c), + ForEach::apply(expr.middle(), li.middle(), f, c), + ForEach::apply(expr.right(), li.right(), f, c), + c); + } }; #ifndef PETE_USER_DEFINED_EXPRESSION *************** template, FTag, CTag> { typedef typename ForEach::Type_t Type_t; inline static ! Type_t apply(const Expression &expr, const FTag &f, ! const CTag &c) { return ForEach::apply(expr.expression(), f, c); } }; #endif // !PETE_USER_DEFINED_EXPRESSION --- 207,229 ---- struct ForEach, FTag, CTag> { typedef typename ForEach::Type_t Type_t; + typedef Expression Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + inline static ! Type_t apply(const Subject_t &expr, ! const FTag &f, const CTag &c) { return ForEach::apply(expr.expression(), f, c); } + + inline static + Type_t apply(const Subject_t &expr, + const LoopInvariant_t &li, + const FTag &f, const CTag &c) + { + return ForEach::apply(expr.expression(), li, f, c); + } }; #endif // !PETE_USER_DEFINED_EXPRESSION *************** template, FTag, CTag> { typedef typename ForEach::Type_t Type_t; inline static ! Type_t apply(const Reference &ref, const FTag &f, ! const CTag &c) { return ForEach::apply(ref.reference(), f, c); } }; --- 234,255 ---- struct ForEach, FTag, CTag> { typedef typename ForEach::Type_t Type_t; + typedef Reference Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + inline static ! Type_t apply(const Subject_t &ref, ! const FTag &f, const CTag &c) { return ForEach::apply(ref.reference(), f, c); + } + + inline static + Type_t apply(const Subject_t &ref, + const LoopInvariant_t &li, + const FTag &f, const CTag &c) + { + return ForEach::apply(ref.reference(), li, f, c); } }; Index: src/PETE/Functors.h =================================================================== RCS file: /home/pooma/Repository/r2/src/PETE/Functors.h,v retrieving revision 1.8 diff -c -p -r1.8 Functors.h *** src/PETE/Functors.h 2001/04/10 23:13:25 1.8 --- src/PETE/Functors.h 2001/11/05 19:28:26 *************** leafFunctor(const LeafType &leaf, const *** 82,87 **** --- 82,97 ---- return LeafFunctor::apply(leaf, tag); } + template + inline + typename LeafFunctor::Type_t + leafFunctor(const LeafType &leaf, + const typename LeafType::LoopInvariant_t &li, + const LeafTag &tag) + { + return LeafFunctor::apply(leaf, li, tag); + } + //----------------------------------------------------------------------------- // // CLASS NAMES *************** template *** 107,117 **** --- 117,136 ---- struct LeafFunctor, EvalLeaf1> { typedef T Type_t; + typedef typename Scalar::LoopInvariant_t LoopInvariant_t; + inline static const Type_t &apply(const Scalar &s, const EvalLeaf1 &) { return s.value(); } + + inline static + const Type_t &apply(const Scalar &s, const LoopInvariant_t &li, + const EvalLeaf1 &) + { + return s.value(li); + } }; // 2D *************** template *** 128,138 **** --- 147,166 ---- struct LeafFunctor, EvalLeaf2> { typedef T Type_t; + typedef typename Scalar::LoopInvariant_t LoopInvariant_t; + inline static const Type_t &apply(const Scalar &s, const EvalLeaf2 &) { return s.value(); } + + inline static + const Type_t &apply(const Scalar &s, const LoopInvariant_t &li, + const EvalLeaf2 &) + { + return s.value(li); + } }; // 3D *************** template *** 151,161 **** --- 179,198 ---- struct LeafFunctor, EvalLeaf3> { typedef T Type_t; + typedef typename Scalar::LoopInvariant_t LoopInvariant_t; + inline static const Type_t &apply(const Scalar &s, const EvalLeaf3 &) { return s.value(); } + + inline static + const Type_t &apply(const Scalar &s, const LoopInvariant_t &li, + const EvalLeaf3 &) + { + return s.value(li); + } }; // 4D *************** template *** 175,185 **** --- 212,231 ---- struct LeafFunctor, EvalLeaf4> { typedef T Type_t; + typedef typename Scalar::LoopInvariant_t LoopInvariant_t; + inline static const Type_t &apply(const Scalar &s, const EvalLeaf4 &) { return s.value(); } + + inline static + const Type_t &apply(const Scalar &s, const LoopInvariant_t &li, + const EvalLeaf4 &) + { + return s.value(li); + } }; // 5D *************** template *** 200,210 **** --- 246,265 ---- struct LeafFunctor, EvalLeaf5> { typedef T Type_t; + typedef typename Scalar::LoopInvariant_t LoopInvariant_t; + inline static const Type_t &apply(const Scalar &s, const EvalLeaf5 &) { return s.value(); } + + inline static + const Type_t &apply(const Scalar &s, const LoopInvariant_t &li, + const EvalLeaf5 &) + { + return s.value(li); + } }; // 6D *************** template *** 226,236 **** --- 281,300 ---- struct LeafFunctor, EvalLeaf6> { typedef T Type_t; + typedef typename Scalar::LoopInvariant_t LoopInvariant_t; + inline static const Type_t &apply(const Scalar &s, const EvalLeaf6 &) { return s.value(); } + + inline static + const Type_t &apply(const Scalar &s, const LoopInvariant_t &li, + const EvalLeaf6 &) + { + return s.value(li); + } }; // 7D *************** template *** 254,264 **** --- 318,337 ---- struct LeafFunctor, EvalLeaf7> { typedef T Type_t; + typedef typename Scalar::LoopInvariant_t LoopInvariant_t; + inline static const Type_t &apply(const Scalar &s, const EvalLeaf7 &) { return s.value(); } + + inline static + const Type_t &apply(const Scalar &s, const LoopInvariant_t &li, + const EvalLeaf7 &) + { + return s.value(li); + } }; *************** template *** 280,292 **** struct LeafFunctor { typedef int Type_t; inline static ! Type_t apply(const T &cl, const IncrementLeaf &) { T &l = const_cast(cl); ++l; return 0; } }; #if defined(__MWERKS__) --- 353,377 ---- struct LeafFunctor { typedef int Type_t; + typedef T Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef IncrementLeaf Tag_t; + inline static ! Type_t apply(const Subject_t &cl, const Tag_t &) { T &l = const_cast(cl); ++l; return 0; } + + inline static + Type_t apply(const Subject_t &cl, + const LoopInvariant_t &, + const Tag_t &lf) + { + return apply(cl, lf); + } }; #if defined(__MWERKS__) *************** template *** 297,309 **** struct LeafFunctor { typedef int Type_t; inline static ! Type_t apply(const T* & const ci, const IncrementLeaf &) { T* &i = const_cast(ci); ++i; return 0; } }; #endif --- 382,406 ---- struct LeafFunctor { typedef int Type_t; + typedef T Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef IncrementLeaf Tag_t; + inline static ! Type_t apply(const Subject_t* & const ci, const Tag_t &) { T* &i = const_cast(ci); ++i; return 0; } + + inline static + Type_t apply(const Subject_t* & const ci, + const LoopInvariant_t &, + const Tag_t &lf) + { + return apply(ci, lf); + } }; #endif *************** template *** 312,322 **** struct LeafFunctor, IncrementLeaf> { typedef int Type_t; inline static ! Type_t apply(const Scalar &, const IncrementLeaf &) { return 0; } }; --- 409,431 ---- struct LeafFunctor, IncrementLeaf> { typedef int Type_t; + typedef Scalar Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef IncrementLeaf Tag_t; + inline static ! Type_t apply(const Subject_t &, const Tag_t &) { return 0; } + + inline static + Type_t apply(const Subject_t &s, + const LoopInvariant_t &, + const Tag_t &lf) + { + return apply(s, lf); + } }; *************** template *** 338,350 **** struct LeafFunctor { typedef int Type_t; inline static ! Type_t apply(const T &cl, const DecrementLeaf &) { T &l = const_cast(cl); --l; return 0; } }; #if defined(__MWERKS__) --- 447,471 ---- struct LeafFunctor { typedef int Type_t; + typedef T Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef DecrementLeaf Tag_t; + inline static ! Type_t apply(const Subject_t &cl, const Tag_t &) { T &l = const_cast(cl); --l; return 0; } + + inline static + Type_t apply(const Subject_t &cl, + const LoopInvariant_t &, + const Tag_t &lf) + { + return apply(cl, lf); + } }; #if defined(__MWERKS__) *************** template *** 353,377 **** struct LeafFunctor { typedef int Type_t; inline static ! Type_t apply(const T* & const ci, const IncrementLeaf &) { T* &i = const_cast(ci); --i; return 0; } }; #endif template struct LeafFunctor, DecrementLeaf> { typedef int Type_t; inline static ! Type_t apply(const Scalar &, const DecrementLeaf &) { return 0; } }; //----------------------------------------------------------------------------- --- 474,524 ---- struct LeafFunctor { typedef int Type_t; + typedef T Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef DecrementLeaf Tag_t; + inline static ! Type_t apply(const Subject_t* & const ci, ! const Tag_t &) { T* &i = const_cast(ci); --i; return 0; } + + inline static + Type_t apply(const Subject_t* &i, + const LoopInvariant_t &, + const Tag_t &lf) + { + return apply(i, lf); + } }; + #endif template struct LeafFunctor, DecrementLeaf> { typedef int Type_t; + typedef Scalar Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef DecrementLeaf Tag_t; + inline static ! Type_t apply(const Subject_t &, const Tag_t &) { return 0; } + + inline static + Type_t apply(const Subject_t &s, + const LoopInvariant_t &, + const Tag_t &lf) + { + return apply(s, lf); + } }; //----------------------------------------------------------------------------- *************** template *** 392,402 **** struct LeafFunctor { typedef typename std::iterator_traits::value_type Type_t; inline static ! Type_t apply(const ForwardIterator &i, const DereferenceLeaf &) { return *i; } }; #if defined(__MWERKS__) --- 539,561 ---- struct LeafFunctor { typedef typename std::iterator_traits::value_type Type_t; + typedef ForwardIterator Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef DereferenceLeaf Tag_t; + inline static ! Type_t apply(const Subject_t &i, const Tag_t &) { return *i; } + + inline static + Type_t apply(const Subject_t &i, + const LoopInvariant_t &, + const Tag_t &lf) + { + return apply(i, lf); + } }; #if defined(__MWERKS__) *************** template *** 405,429 **** struct LeafFunctor { typedef T Type_t; inline static ! Type_t apply(const T *i, const DereferenceLeaf &) { return *i; } }; #endif template struct LeafFunctor, DereferenceLeaf> { typedef T Type_t; inline static ! const Type_t &apply(const Scalar &s, const DereferenceLeaf &) { return s.value(); } - }; #endif // PETE_PETE_FUNCTORS_H --- 564,612 ---- struct LeafFunctor { typedef T Type_t; + typedef T Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef DereferenceLeaf Tag_t; + inline static ! Type_t apply(const Subject_t *i, const Tag_t &) { return *i; } + + inline static + Type_t apply(const Subject_t *i, + const LoopInvariant_t &, + const Tag_t &lf) + { + return apply(i, lf); + } }; + #endif template struct LeafFunctor, DereferenceLeaf> { typedef T Type_t; + typedef Scalar Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + typedef DereferenceLeaf Tag_t; + inline static ! const Type_t &apply(const Subject_t &s, const Tag_t &) { return s.value(); } + inline static + const Type_t &apply(const Subject_t &s, + const LoopInvariant_t &li, + const Tag_t &) + { + return s.value(li); + } + }; #endif // PETE_PETE_FUNCTORS_H Index: src/PETE/PoomaPETE.h =================================================================== RCS file: /home/pooma/Repository/r2/src/PETE/PoomaPETE.h,v retrieving revision 1.3 diff -c -p -r1.3 PoomaPETE.h *** src/PETE/PoomaPETE.h 2001/10/15 17:34:31 1.3 --- src/PETE/PoomaPETE.h 2001/11/05 19:28:26 *************** template::Type_t Type_t; + typedef typename Expr::LoopInvariant_t LoopInvariant_t; + inline static const Type_t &apply(const Expr &expr, const FTag &f, const CTag &) { return LeafFunctor::apply(expr, f); } + + inline static + const Type_t &apply(const Expr &expr, const LoopInvariant_t &li, + const FTag &f, const CTag &) + { + return LeafFunctor::apply(expr, li, f); + } }; template *************** forEachRef(const Expr &e, const FTag &f, *** 81,99 **** return ForEachRef::apply(e, f, c); } template struct ForEachRef, FTag, CTag> { typedef typename ForEachRef::Type_t TypeA_t; typedef typename Combine1::Type_t Type_t; inline static ! const Type_t &apply(const UnaryNode &expr, const FTag &f, ! const CTag &c) { return Combine1:: combine(ForEachRef::apply(expr.child(), f, c), c); } }; template --- 90,129 ---- return ForEachRef::apply(e, f, c); } + template + inline const typename ForEachRef::Type_t & + forEachRef(const Expr &e, const typename Expr::LoopInvariant_t &li, + const FTag &f, const CTag &c) + { + return ForEachRef::apply(e, li, f, c); + } + template struct ForEachRef, FTag, CTag> { typedef typename ForEachRef::Type_t TypeA_t; typedef typename Combine1::Type_t Type_t; + typedef UnaryNode Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + inline static ! const Type_t &apply(const Subject_t &expr, ! const FTag &f, const CTag &c) { return Combine1:: combine(ForEachRef::apply(expr.child(), f, c), c); } + + inline static + const Type_t &apply(const Subject_t &expr, + const LoopInvariant_t &li, + const FTag &f, const CTag &c) + { + return Combine1:: + combine(ForEachRef::apply(expr.child(), li.child(), f, c), + c); + } }; template *************** struct ForEachRef, *** 102,116 **** typedef typename ForEachRef::Type_t TypeA_t; typedef typename ForEachRef::Type_t TypeB_t; typedef typename Combine2::Type_t Type_t; inline static ! const Type_t &apply(const BinaryNode &expr, const FTag &f, ! const CTag &c) { return Combine2:: combine(ForEachRef::apply(expr.left(), f, c), ForEachRef::apply(expr.right(), f, c), c); } }; template --- 132,159 ---- typedef typename ForEachRef::Type_t TypeA_t; typedef typename ForEachRef::Type_t TypeB_t; typedef typename Combine2::Type_t Type_t; + typedef BinaryNode Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + inline static ! const Type_t &apply(const Subject_t &expr, ! const FTag &f, const CTag &c) { return Combine2:: combine(ForEachRef::apply(expr.left(), f, c), ForEachRef::apply(expr.right(), f, c), c); } + + const Type_t &apply(const Subject_t &expr, + const LoopInvariant_t &li, + const FTag &f, const CTag &c) + { + return Combine2:: + combine(ForEachRef::apply(expr.left(), li.left(), f, c), + ForEachRef::apply(expr.right(), li.right(), f, c), + c); + } }; template *************** struct ForEachRef::Type_t TypeC_t; typedef typename Combine3::Type_t Type_t; inline static ! const Type_t &apply(const TrinaryNode &expr, const FTag &f, ! const CTag &c) { return Combine3:: combine(ForEachRef::apply(expr.left(), f, c), --- 164,175 ---- typedef typename ForEachRef::Type_t TypeC_t; typedef typename Combine3::Type_t Type_t; + typedef TrinaryNode Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + inline static ! const Type_t &apply(const Subject_t &expr, ! const FTag &f, const CTag &c) { return Combine3:: combine(ForEachRef::apply(expr.left(), f, c), *************** struct ForEachRef::apply(expr.right(), f, c), c); } }; template struct ForEachRef, FTag, CTag> { typedef typename ForEachRef::Type_t Type_t; inline static ! const Type_t &apply(const Expression &expr, const FTag &f, ! const CTag &c) { return ForEachRef::apply(expr.expression(), f, c); } }; template struct ForEachRef, FTag, CTag> { typedef typename ForEachRef::Type_t Type_t; inline static ! const Type_t &apply(const Reference &ref, const FTag &f, ! const CTag &c) { return ForEachRef::apply(ref.reference(), f, c); } }; --- 177,239 ---- ForEachRef::apply(expr.right(), f, c), c); } + + inline static + const Type_t &apply(const Subject_t &expr, + const LoopInvariant_t &li, + const FTag &f, const CTag &c) + { + return Combine3:: + combine(ForEachRef::apply(expr.left(), li.left(), f, c), + ForEachRef::apply(expr.middle(), li.middle(), f, c), + ForEachRef::apply(expr.right(), li.right(), f, c), + c); + } }; template struct ForEachRef, FTag, CTag> { typedef typename ForEachRef::Type_t Type_t; + typedef Expression Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + inline static ! const Type_t &apply(const Subject_t &expr, ! const FTag &f, const CTag &c) { return ForEachRef::apply(expr.expression(), f, c); } + + inline static + const Type_t &apply(const Subject_t &expr, + const LoopInvariant_t &li, + const FTag &f, const CTag &c) + { + return ForEachRef::apply(expr.expression(), li, f, c); + } }; template struct ForEachRef, FTag, CTag> { typedef typename ForEachRef::Type_t Type_t; + typedef Reference Subject_t; + typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; + inline static ! const Type_t &apply(const Subject_t &ref, ! const FTag &f, const CTag &c) { return ForEachRef::apply(ref.reference(), f, c); + } + + inline static + const Type_t &apply(const Subject_t &ref, + const LoopInvariant_t &li, + const FTag &f, const CTag &c) + { + return ForEachRef::apply(ref.reference(), li, f, c); } }; Index: src/PETE/Scalar.h =================================================================== RCS file: /home/pooma/Repository/r2/src/PETE/Scalar.h,v retrieving revision 1.7 diff -c -p -r1.7 Scalar.h *** src/PETE/Scalar.h 2000/05/24 17:32:56 1.7 --- src/PETE/Scalar.h 2001/11/05 19:28:26 *************** class Scalar *** 50,55 **** --- 50,74 ---- { public: + // Values that do not change during the evaluation of a single + // data parallel statement. + + class LoopInvariant_t { + public: + + LoopInvariant_t(const T &t) : scalar_m(t) {} + + inline T& scalar() { return scalar_m; } + inline const T scalar() const { return scalar_m; } + + private: + + //--------------------------------------------------------------------------- + // The scalar value is stored here. + + T scalar_m; + }; + //--------------------------------------------------------------------------- // Default constructor takes no action. *************** public: *** 60,70 **** // Constructor from a single value. inline ! Scalar(const T &t) : scalar_m(t) { } template inline ! explicit Scalar(const T1 &t) : scalar_m(t) { } //--------------------------------------------------------------------------- // Constructor with arbitary second/third arguments, which is/are ignored. --- 79,89 ---- // Constructor from a single value. inline ! Scalar(const T &t) : invariant_m(t) { } template inline ! explicit Scalar(const T1 &t) : invariant_m(t) { } //--------------------------------------------------------------------------- // Constructor with arbitary second/third arguments, which is/are ignored. *************** public: *** 74,105 **** template inline Scalar(const Scalar &s, const Arg &) ! : scalar_m(s.scalar_m) { } template inline Scalar(const Scalar &s, const Arg1 &, const Arg2 &) ! : scalar_m(s.scalar_m) { } //--------------------------------------------------------------------------- // Copy constructor inline ! Scalar(const Scalar &s) : scalar_m(s.scalar_m) { } //--------------------------------------------------------------------------- // Return value. inline ! const T &value() const { return scalar_m; } //--------------------------------------------------------------------------- // Assignment operators. inline Scalar &operator=(const Scalar &rhs) { ! scalar_m = rhs.scalar_m; return *this; } --- 93,127 ---- template inline Scalar(const Scalar &s, const Arg &) ! : invariant_m(s.value()) { } template inline Scalar(const Scalar &s, const Arg1 &, const Arg2 &) ! : invariant_m(s.value()) { } //--------------------------------------------------------------------------- // Copy constructor inline ! Scalar(const Scalar &s) : invariant_m(s.value()) { } //--------------------------------------------------------------------------- // Return value. inline ! const T value() const { return invariant_m.scalar(); } + inline + const T value(const LoopInvariant_t &li) const { return li.scalar(); } + //--------------------------------------------------------------------------- // Assignment operators. inline Scalar &operator=(const Scalar &rhs) { ! invariant_m.scalar() = rhs.value(); return *this; } *************** public: *** 107,123 **** inline Scalar &operator=(const T &rhs) { ! scalar_m = rhs; return *this; } ! private: ! //--------------------------------------------------------------------------- ! // The scalar value is stored here. ! T scalar_m; }; --- 129,150 ---- inline Scalar &operator=(const T &rhs) { ! invariant_m.scalar() = rhs; return *this; } ! ! // Values that do not change during the evaluation of a single ! // data parallel statement. ! ! LoopInvariant_t loopInvariant() const { return invariant_m; } ! private: ! // Values that do not change during the evaluation of a single ! // data parallel statement. ! LoopInvariant_t invariant_m; }; Index: src/PETE/TreeNodes.h =================================================================== RCS file: /home/pooma/Repository/r2/src/PETE/TreeNodes.h,v retrieving revision 1.14 diff -c -p -r1.14 TreeNodes.h *** src/PETE/TreeNodes.h 2000/12/04 21:19:37 1.14 --- src/PETE/TreeNodes.h 2001/11/05 19:28:26 *************** *** 50,55 **** --- 50,71 ---- template struct Reference { + // Values that do not change during the evaluation of a single + // data parallel statement. + + class LoopInvariant_t { + public: + + LoopInvariant_t(const T &t) : reference_m(t) {} + + inline T& reference() { return reference_m; } + inline const T& reference() const { return reference_m; } + + private: + + const T &reference_m; + }; + //--------------------------------------------------------------------------- // Export the type of thing we're referencing. *************** struct Reference *** 60,66 **** inline Reference(const T &reference) ! : reference_m(reference) { } //--------------------------------------------------------------------------- --- 76,82 ---- inline Reference(const T &reference) ! : invariant_m(reference) { } //--------------------------------------------------------------------------- *************** struct Reference *** 68,74 **** inline Reference(const Reference &model) ! : reference_m(model.reference()) { } //--------------------------------------------------------------------------- --- 84,90 ---- inline Reference(const Reference &model) ! : invariant_m(model.reference()) { } //--------------------------------------------------------------------------- *************** struct Reference *** 77,92 **** inline const T &reference() const { ! return reference_m; } //--------------------------------------------------------------------------- // Conversion operators. ! operator const T& () const { return reference_m; } ! operator T& () const { return const_cast(reference_m); } ! ! const T &reference_m; }; //----------------------------------------------------------------------------- --- 93,120 ---- inline const T &reference() const { ! return invariant_m.reference(); } + inline + const T &reference(const LoopInvariant_t &li) const + { + return li.reference(); + } + //--------------------------------------------------------------------------- // Conversion operators. ! operator const T& () const { return invariant_m.reference(); } ! operator T& () const { return const_cast(invariant_m.reference()); } ! ! LoopInvariant_t loopInvariant() const { return invariant_m; } ! ! private: ! // Values that do not change during the evaluation of a single ! // data parallel statement. ! ! LoopInvariant_t invariant_m; }; //----------------------------------------------------------------------------- *************** class UnaryNode *** 136,141 **** --- 164,183 ---- { public: + class LoopInvariant_t { + public: + typedef typename Child::LoopInvariant_t ChildLoopInvariant_t; + + LoopInvariant_t(const ChildLoopInvariant_t& li) + : li_m(li) {} + + inline + const ChildLoopInvariant_t& child() const { return li_m; } + + private: + ChildLoopInvariant_t li_m; + }; + inline typename DeReference::Return_t child() const { return DeReference::apply(child_m); } *************** public: *** 176,182 **** : child_m(t.child(), a) { } //--------------------------------------------------------------------------- ! // Constructor using a BinaryNode with a different Child and // two arbitrary arguments. // Note: for this to work, a Child must be constructable // from an OtherChild and an Arg1 & Arg2. --- 218,224 ---- : child_m(t.child(), a) { } //--------------------------------------------------------------------------- ! // Constructor using a UnaryNode with a different Child and // two arbitrary arguments. // Note: for this to work, a Child must be constructable // from an OtherChild and an Arg1 & Arg2. *************** public: *** 188,193 **** --- 230,240 ---- : child_m(t.child(), a1, a2) { } + inline + LoopInvariant_t loopInvariant() const { + return LoopInvariant_t(child_m.loopInvariant()); + } + private: Child child_m; *************** class BinaryNode *** 214,219 **** --- 261,286 ---- { public: + class LoopInvariant_t { + public: + typedef typename Left::LoopInvariant_t LeftLoopInvariant_t; + typedef typename Right::LoopInvariant_t RightLoopInvariant_t; + + LoopInvariant_t(const LeftLoopInvariant_t& l, + const RightLoopInvariant_t& r) + : l_m(l), r_m(r) {} + + inline + const LeftLoopInvariant_t& left() const { return l_m; } + + inline + const RightLoopInvariant_t& right() const { return r_m; } + + private: + LeftLoopInvariant_t l_m; + RightLoopInvariant_t r_m; + }; + inline typename DeReference::Return_t left() const { return DeReference::apply(left_m); } *************** public: *** 275,280 **** --- 342,352 ---- : left_m(t.left(), a1, a2), right_m(t.right(), a1, a2) { } + inline + LoopInvariant_t loopInvariant() const { + return LoopInvariant_t(left_m.loopInvariant(), right_m.loopInvariant()); + } + private: //--------------------------------------------------------------------------- *************** class TrinaryNode *** 308,313 **** --- 380,411 ---- { public: + class LoopInvariant_t { + public: + typedef typename Left::LoopInvariant_t LeftLoopInvariant_t; + typedef typename Middle::LoopInvariant_t MiddleLoopInvariant_t; + typedef typename Right::LoopInvariant_t RightLoopInvariant_t; + + LoopInvariant_t(const LeftLoopInvariant_t& l, + const MiddleLoopInvariant_t& m, + const RightLoopInvariant_t& r) + : l_m(l), m_m(m), r_m(r) {} + + inline + const LeftLoopInvariant_t& left() const { return l_m; } + + inline + const MiddleLoopInvariant_t& middle() const { return m_m; } + + inline + const RightLoopInvariant_t& right() const { return r_m; } + + private: + LeftLoopInvariant_t l_m; + MiddleLoopInvariant_t m_m; + RightLoopInvariant_t r_m; + }; + inline typename DeReference::Return_t left() const { return DeReference::apply(left_m); } *************** public: *** 374,379 **** --- 472,484 ---- : left_m(t.left(), a1, a2), middle_m(t.middle(), a1, a2) , right_m(t.right(), a1, a2) { } + + inline + LoopInvariant_t loopInvariant() const { + return LoopInvariant_t(left_m.loopInvariant(), + middle_m.loopInvariant(), + right_m.loopInvariant()); + } private: -------------- next part -------------- Index: Stencil.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Engine/Stencil.h,v retrieving revision 1.44 diff -c -p -r1.44 Stencil.h *** Stencil.h 2001/09/14 22:37:56 1.44 --- Stencil.h 2001/10/31 16:36:03 *************** public: *** 273,278 **** --- 273,352 ---- enum { multiPatch = ExprEngine_t::multiPatch }; enum { zeroBased = true }; + class LoopInvariant_t { + public: + typedef typename Expression::LoopInvariant_t ExpressionLoopInvariant_t; + + LoopInvariant_t(const ExpressionLoopInvariant_t& eli, + const int* offset) + : eli_m(eli) { + for (int i = 0; i < D; ++i) + offset_m[i] = offset[i]; + } + + const ExpressionLoopInvariant_t& exprLoopInvariant() const + { return eli_m; } + + const int* offset() const { return offset_m; } + + private: + ExpressionLoopInvariant_t eli_m; + int offset_m[D]; + }; + + class ExpressionProxy + { + public: + typedef Element_t Element_t; + typedef typename Expression::LoopInvariant_t ExpressionLoopInvariant_t; + typedef typename Expression::Element_t Ret_t; + + ExpressionProxy(const Expression &expression, const ExpressionLoopInvariant_t &eli) + : expression_m(expression), eli_m(eli) + { + } + + inline Ret_t + operator()(int i) const + { + return expression_m.read(eli_m, i); + } + + inline Ret_t + operator()(int i, int j) const + { + return expression_m.read(eli_m, i, j); + } + + inline Ret_t + operator()(int i, int j, int k) const + { + return expression_m.read(eli_m, i, j, k); + } + + inline Ret_t + read(int i) const + { + return expression_m.read(eli_m, i); + } + + inline Ret_t + read(int i, int j) const + { + return expression_m.read(eli_m, i, j); + } + + inline Ret_t + read(int i, int j, int k) const + { + return expression_m.read(eli_m, i, j, k); + } + + const Expression &expression_m; + const ExpressionLoopInvariant_t &eli_m; + }; + + //============================================================ // Construct from a Function object (effectively a stencil) // and an expression (effectively the input array), and *************** public: *** 378,383 **** --- 452,502 ---- loc[2].first() + offset_m[2]); } + inline Element_t read(const LoopInvariant_t& li, int i) const + { + // Input index `i + offset_m[0]' corresponds to output index `i'. + ExpressionProxy expressionProxy(expression_m, li.exprLoopInvariant()); + return function()(expressionProxy, + i + li.offset()[0]); + } + inline Element_t read(const LoopInvariant_t& li, int i, int j) const + { + ExpressionProxy expressionProxy(expression_m, li.exprLoopInvariant()); + return function()(expressionProxy, + i + li.offset()[0], + j + li.offset()[1]); + } + inline Element_t read(const LoopInvariant_t& li, int i, int j, int k) const + { + ExpressionProxy expressionProxy(expression_m, li.exprLoopInvariant()); + return function()(expressionProxy, + i + li.offset()[0], + j + li.offset()[1], + k + li.offset()[2]); + } + + inline Element_t read(const LoopInvariant_t& li, const Loc<1> &loc) const + { + ExpressionProxy expressionProxy(expression_m, li.exprLoopInvariant()); + return function()(expressionProxy, + loc[0].first() + li.offset()[0]); + } + inline Element_t read(const LoopInvariant_t& li, const Loc<2> &loc) const + { + ExpressionProxy expressionProxy(expression_m, li.exprLoopInvariant()); + return function()(expressionProxy, + loc[0].first() + li.offset()[0], + loc[1].first() + li.offset()[1]); + } + inline Element_t read(const LoopInvariant_t& li, const Loc<3> &loc) const + { + ExpressionProxy expressionProxy(expression_m, li.exprLoopInvariant()); + return function()(expressionProxy, + loc[0].first() + li.offset()[0], + loc[1].first() + li.offset()[1], + loc[2].first() + li.offset()[2]); + } + //============================================================ // operator() are provided since users typically write stencils // as x(i, j) + x(i, j - 1), so for stencils of stencils to work *************** public: *** 474,479 **** --- 593,602 ---- inline const Function &function() const { return function_m; } inline const Expression &expression() const { return expression_m; } + inline const LoopInvariant_t loopInvariant() const + { return LoopInvariant_t(expression_m.loopInvariant(), + offset_m); } + private: Function function_m; *************** struct LeafFunctor > > { typedef int Type_t; ! ! static ! Type_t apply(const Engine > &engine, ! const ExpressionApply > &tag) { typedef StencilIntersector NewIntersector_t; NewIntersector_t newIntersector(engine.intersectDomain(), --- 978,990 ---- ExpressionApply > > { typedef int Type_t; ! typedef Engine > Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef ExpressionApply > Tag_t; ! ! inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &tag) { typedef StencilIntersector NewIntersector_t; NewIntersector_t newIntersector(engine.intersectDomain(), *************** struct LeafFunctor(newIntersector)); return 0; } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + typedef StencilIntersector NewIntersector_t; + NewIntersector_t newIntersector(engine.intersectDomain(), + tag.tag().intersector_m); + + // FIXME: Where is this defined? Revise it. + expressionApply(engine.expression(), li, + IntersectorTag(newIntersector)); + return 0; + } }; //--------------------------------------------------------------------------- *************** struct EngineFunctor struct LeafFunctor >, EngineView > { ! typedef LeafFunctor > LeafFunctor_t; typedef typename LeafFunctor_t::Type_t NewViewed_t; typedef Engine > Type_t; ! static ! Type_t apply(const Engine > &engine, ! const EngineView &tag) { return Type_t(engine.function(), LeafFunctor_t::apply(engine.expression(), tag)); } }; //----------------------------------------------------------------------------- --- 1046,1074 ---- template struct LeafFunctor >, EngineView > { ! typedef Engine > Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef EngineView Tag_t; ! typedef LeafFunctor LeafFunctor_t; typedef typename LeafFunctor_t::Type_t NewViewed_t; typedef Engine > Type_t; ! inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &tag) { return Type_t(engine.function(), LeafFunctor_t::apply(engine.expression(), tag)); } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return Type_t(engine.function(), li, + LeafFunctor_t::apply(engine.expression(), tag)); + } }; //----------------------------------------------------------------------------- *************** struct LeafFunctor struct LeafFunctor >, ExpressionApply > { ! typedef LeafFunctor > LeafFunctor_t; typedef int Type_t; ! static ! Type_t apply(const Engine > &engine, ! const ExpressionApply &tag) { return LeafFunctor_t::apply(engine.expression(), tag); } }; --- 1081,1105 ---- template struct LeafFunctor >, ExpressionApply > { ! typedef Engine > Subject_t; ! typedef typename Subject_t::LoopInvariant_t LoopInvariant_t; ! typedef ExpressionApply Tag_t; ! typedef LeafFunctor LeafFunctor_t; typedef int Type_t; ! inline static ! Type_t apply(const Subject_t &engine, ! const Tag_t &tag) { return LeafFunctor_t::apply(engine.expression(), tag); + } + + inline static + Type_t apply(const Subject_t &engine, + const LoopInvariant_t &li, + const Tag_t &tag) + { + return LeafFunctor_t::apply(engine.expression(), li, tag); } }; From oldham at codesourcery.com Tue Nov 6 00:51:27 2001 From: oldham at codesourcery.com (Jeffrey Oldham) Date: Mon, 5 Nov 2001 16:51:27 -0800 Subject: Patch: Fix Typographical Error Message-ID: <20011105165127.A26928@codesourcery.com> 2001-11-05 Jeffrey D. Oldham * Pooma.h: Fix typographical error in a comment. Not tested. Approved by NO ONE! Applied to mainline. Thanks, Jeffrey D. Oldham oldham at codesourcery.com -------------- next part -------------- Index: Pooma.h =================================================================== RCS file: /home/pooma/Repository/r2/src/Pooma/Pooma.h,v retrieving revision 1.30 diff -c -p -r1.30 Pooma.h *** Pooma.h 2000/06/08 22:16:34 1.30 --- Pooma.h 2001/11/05 23:42:48 *************** namespace Pooma { *** 286,292 **** // arguments will be removed. If the 3rd argument is true, also initialize // the run-time system. If the 4th argument is true, use arch-specific routine // to get command line arguments. If the 5th argument is true, call ! // arch-specific initalize(). // Return success. bool initialize(int &argc, char ** &argv, --- 286,292 ---- // arguments will be removed. If the 3rd argument is true, also initialize // the run-time system. If the 4th argument is true, use arch-specific routine // to get command line arguments. If the 5th argument is true, call ! // arch-specific initialize(). // Return success. bool initialize(int &argc, char ** &argv, From tdumont at maply.univ-lyon1.fr Thu Nov 15 08:29:47 2001 From: tdumont at maply.univ-lyon1.fr (Thierry Dumont) Date: Thu, 15 Nov 2001 09:29:47 +0100 (CET) Subject: problem.. Message-ID: Sir, I have a problem compiling smarts-1.2.0. Before sending this mail, I have tried all the e-mail adresses of the pooma & smarts projects that can be found on your web: none is working! So, I' m not sure that I send this e-mail to the good adress, but I need to solve my problem! Machine & software: ================== Linux RedHat 7.1 on intel. gcc version 2.96 20000731 smarts version is 1.2.0. Description of the problem: ========================== a) with : configure --with-CXX=g++ I get: g++ -DLINUX -O2 -D_REENTRANT -D_THREAD_SAFE -I/users/mobylette_1/tdumont/smarts-1.2.0/include -I/users/mobylette_1/tdumont/smarts-1.2.0/include/IterateSchedulers -I/users/mobylette_1/tdumont/smarts-1.2.0/machine-specific/i386-linux -c /users/mobylette_1/tdumont/smarts-1.2.0/src/AffinityScheduler.C In file included from /users/mobylette_1/tdumont/smarts-1.2.0/machine-specific/i386-linux/pthread.h:25, from /usr/include/g++-3/stl_alloc.h:71, from /usr/include/g++-3/alloc.h:21, from /usr/include/g++-3/vector.h:31, from /users/mobylette_1/tdumont/smarts-1.2.0/machine-specific/i386-linux/Helpers.h:33, from /users/mobylette_1/tdumont/smarts-1.2.0/include/Smarts.h:76, from /users/mobylette_1/tdumont/smarts-1.2.0/src/AffinityScheduler.C:25: /users/mobylette_1/tdumont/smarts-1.2.0/include/Pthread.h:50: conflicting types for `typedef void *pthread_mutex_t' /usr/include/bits/pthreadtypes.h:83: previous declaration as `typedef struct pthread_mutex_t pthread_mutex_t' /users/mobylette_1/tdumont/smarts-1.2.0/include/Pthread.h:51: conflicting types for `typedef char pthread_mutexattr_t' /usr/include/bits/pthreadtypes.h:90: previous declaration as `typedef .... usr/include/bits/pthreadtypes.h:60: previous declaration as `typedef struct pthread_cond_t pthread_cond_t' /users/mobylette_1/tdumont/smarts-1.2.0/include/Pthread.h:61: conflicting types for `typedef void *pthread_t' /usr/include/bits/pthreadtypes.h:140: previous declaration as `typedef long unsigned int pthread_t' b)with: configure --with-thread=pthreads --with-CXX=g++ make I get: g++ -DKERNEL_PTHREADS -DLINUX -O2 -D_REENTRANT -D_THREAD_SAFE -I/users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include -I/users/mobylette_1/tdumont/smarts-1.2.0/include -I/users/mobylette_1/tdumont/smarts-1.2.0/include/IterateSchedulers -I/users/mobylette_1/tdumont/smarts-1.2.0/machine-specific/i386-linux -c /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C In file included from /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Smarts.h:30, from /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C:43: /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Context.h:158: syntax error before `;' /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Context.h:159: syntax error before `;' /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Context.h:161: syntax error before `;' /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Context.h:162: syntax error before `;' In file included from /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Context.h:220, /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h: In function `void Smarts::Context::addIterate (Smarts::Runnable *)': /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h:41: `class Smarts::Context' has no member named `affinityIterateQueue' /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h:46: `class Smarts::Context' has no member named `iterateQueue' /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h:49: `class Smarts::Context' has no member named `iterateQueue' /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h: In function `void Smarts::Context::addIterateToCpu (Smarts::Runnable *, int)': /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h:56: `class Smarts::Context' has no member named `affinityIterateQueue' /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h:59: `class Smarts::Context' has no member named `iterateQueue' In file included from /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C:43: /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Smarts.h: At top level: /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Smarts.h:32: redefinition of `Smarts' /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Mutex.h:34: `Smarts' previously defined here In file included from /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C:46: /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/AcquireByUpcall.h:37: namespace alias `Smarts' not allowed here, assuming `Smarts' /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C:50: namespace alias `Smarts' not allowed here, assuming `Smarts' /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C: In function `int Smarts::parastart (void *)': /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C:92: return-statement with no value, in function declared with a non-void return type /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C: In function `void Smarts::Context::mustRunOn ()': /users/mobylette_1/tdumont/smarts-1.2.0/machine-specific/i386-linux/Helpers.h:79: too many arguments to function `void Smarts::Bind ()' /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C:98: at this point in file /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C: In function `void Smarts::Context::mustRunOff ()': .... Version 1.1.1 of smarts is ok, but doesn't seems to work with pooma-2.3.0. Can you help me? Very sincerely yours, t. dumont. -- Thierry Dumont. MAPLY (Maths Appliques de Lyon-UMR 5585 CNRS). Univ. Lyon I,43 Bd du 11 Novembre 1918, 69622 - Villeurbanne Cedex - France. Thierry.Dumont at maply.univ-lyon1.fr web: http://maply.univ-lyon1.fr/~tdumont From oldham at codesourcery.com Mon Nov 19 16:57:53 2001 From: oldham at codesourcery.com (Jeffrey Oldham) Date: Mon, 19 Nov 2001 08:57:53 -0800 Subject: [pooma-dev] problem.. In-Reply-To: ; from tdumont@numerix.univ-lyon1.fr on Thu, Nov 15, 2001 at 09:29:47AM +0100 References: Message-ID: <20011119085753.B11871@codesourcery.com> The Pooma WWW site has moved to pooma.codesourcery.com. http://www.acl.lanl.gov/pooma/ is no longer updated. We also had trouble compiling Smarts. Suvas, is there a version of Smarts similar to 1.2.0 that compiles and is known correct? The version we have is available at http://www.codesourcery.com/pooma/pooma_download. Thanks, Jeffrey D. Oldham oldham at codesourcery.com On Thu, Nov 15, 2001 at 09:29:47AM +0100, Thierry Dumont wrote: > > Sir, > > I have a problem compiling smarts-1.2.0. > > Before sending this mail, I have tried all the e-mail adresses of the > pooma & smarts projects that can be found on your web: none is working! > > So, I' m not sure that I send this e-mail to the good address, but I need > to solve my problem! > > Machine & software: > ================== > Linux RedHat 7.1 on intel. gcc version 2.96 20000731 > smarts version is 1.2.0. > > Description of the problem: > ========================== > > a) with : configure --with-CXX=g++ > I get: > > > g++ -DLINUX -O2 -D_REENTRANT -D_THREAD_SAFE > -I/users/mobylette_1/tdumont/smarts-1.2.0/include > -I/users/mobylette_1/tdumont/smarts-1.2.0/include/IterateSchedulers > -I/users/mobylette_1/tdumont/smarts-1.2.0/machine-specific/i386-linux -c > /users/mobylette_1/tdumont/smarts-1.2.0/src/AffinityScheduler.C > In file included from > /users/mobylette_1/tdumont/smarts-1.2.0/machine-specific/i386-linux/pthread.h:25, > from /usr/include/g++-3/stl_alloc.h:71, > from /usr/include/g++-3/alloc.h:21, > from /usr/include/g++-3/vector.h:31, > from > /users/mobylette_1/tdumont/smarts-1.2.0/machine-specific/i386-linux/Helpers.h:33, > from > /users/mobylette_1/tdumont/smarts-1.2.0/include/Smarts.h:76, > from > /users/mobylette_1/tdumont/smarts-1.2.0/src/AffinityScheduler.C:25: > /users/mobylette_1/tdumont/smarts-1.2.0/include/Pthread.h:50: conflicting > types for `typedef void > *pthread_mutex_t' > /usr/include/bits/pthreadtypes.h:83: previous declaration as `typedef > struct pthread_mutex_t pthread_mutex_t' > /users/mobylette_1/tdumont/smarts-1.2.0/include/Pthread.h:51: conflicting > types for `typedef char > pthread_mutexattr_t' > /usr/include/bits/pthreadtypes.h:90: previous declaration as `typedef > .... > usr/include/bits/pthreadtypes.h:60: previous declaration as `typedef > struct pthread_cond_t pthread_cond_t' > /users/mobylette_1/tdumont/smarts-1.2.0/include/Pthread.h:61: conflicting > types for `typedef void > *pthread_t' > /usr/include/bits/pthreadtypes.h:140: previous declaration as `typedef > long unsigned int pthread_t' > > > b)with: > configure --with-thread=pthreads --with-CXX=g++ > make > > I get: > g++ -DKERNEL_PTHREADS -DLINUX -O2 -D_REENTRANT -D_THREAD_SAFE > -I/users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include > -I/users/mobylette_1/tdumont/smarts-1.2.0/include > -I/users/mobylette_1/tdumont/smarts-1.2.0/include/IterateSchedulers > -I/users/mobylette_1/tdumont/smarts-1.2.0/machine-specific/i386-linux -c > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C > In file included from > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Smarts.h:30, > from > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C:43: > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Context.h:158: > syntax error before `;' > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Context.h:159: > syntax error before `;' > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Context.h:161: > syntax error before `;' > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Context.h:162: > syntax error before `;' > In file included from > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Context.h:220, > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h: > In function `void > Smarts::Context::addIterate (Smarts::Runnable *)': > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h:41: > `class Smarts::Context' > has no member named `affinityIterateQueue' > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h:46: > `class Smarts::Context' > has no member named `iterateQueue' > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h:49: > `class Smarts::Context' > has no member named `iterateQueue' > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h: > In function `void > Smarts::Context::addIterateToCpu (Smarts::Runnable *, int)': > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h:56: > `class Smarts::Context' > has no member named `affinityIterateQueue' > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/IterateContext.h:59: > `class Smarts::Context' > has no member named `iterateQueue' > In file included from > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C:43: > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Smarts.h: At top > level: > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Smarts.h:32: > redefinition of `Smarts' > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/Mutex.h:34: > `Smarts' previously defined here > In file included from > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C:46: > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/include/AcquireByUpcall.h:37: > namespace alias `Smarts' > not allowed here, assuming `Smarts' > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C:50: > namespace alias `Smarts' not allowed > here, assuming `Smarts' > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C: In > function `int Smarts::parastart > (void *)': > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C:92: > return-statement with no value, in > function declared with a non-void return type > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C: In > function `void > Smarts::Context::mustRunOn ()': > /users/mobylette_1/tdumont/smarts-1.2.0/machine-specific/i386-linux/Helpers.h:79: > too many arguments to > function `void Smarts::Bind ()' > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C:98: at this > point in file > /users/mobylette_1/tdumont/smarts-1.2.0/pthreads/src/Context.C: In > function `void > Smarts::Context::mustRunOff ()': > .... > > > Version 1.1.1 of smarts is ok, but doesn't seems to work with pooma-2.3.0. > > Can you help me? > > Very sincerely yours, > > t. dumont. > > -- > Thierry Dumont. MAPLY (Maths Appliques de Lyon-UMR 5585 CNRS). > Univ. Lyon I,43 Bd du 11 Novembre 1918, 69622 - Villeurbanne Cedex - France. > Thierry.Dumont at maply.univ-lyon1.fr web: http://maply.univ-lyon1.fr/~tdumont From tdumont at maply.univ-lyon1.fr Mon Nov 19 16:23:31 2001 From: tdumont at maply.univ-lyon1.fr (Thierry Dumont) Date: Mon, 19 Nov 2001 17:23:31 +0100 (CET) Subject: [pooma-dev] problem.. In-Reply-To: <20011119085753.B11871@codesourcery.com> Message-ID: On Mon, 19 Nov 2001, Jeffrey Oldham wrote: > The Pooma WWW site has moved to pooma.codesourcery.com. > http://www.acl.lanl.gov/pooma/ is no longer updated. > > We also had trouble compiling Smarts. Suvas, is there a > version of Smarts similar to 1.2.0 that compiles and is known correct? > The version we have is available at > http://www.codesourcery.com/pooma/pooma_download. > > Thanks, > Jeffrey D. Oldham > oldham at codesourcery.com > Ok, thank you. Actually, the compilation problem was a compiler problem! As I have tried to compile on a new machine (Linux RedHat 7.2 <- ), the compiler is: gcc version 2.96 20000731. Going back to gcc version 2.95.3 make everything work! This 2.96 version is NOT official! Very sincerely yours, t.d. -- Thierry Dumont. MAPLY (Maths Appliques de Lyon-UMR 5585 CNRS). Univ. Lyon I,43 Bd du 11 Novembre 1918, 69622 - Villeurbanne Cedex - France. Thierry.Dumont at maply.univ-lyon1.fr web: http://maply.univ-lyon1.fr/~tdumont