[PATCH] Kill Unwrap<>

Richard Guenther rguenth at tat.physik.uni-tuebingen.de
Sat Jan 17 19:21:26 UTC 2004


Hi!

This patch kills previously introduced Unwrap<> and instead provides a
fallback in OpMask<>.  This way we don't forget places to update (as I did
with PartialReduction in case of OpenMP).

Tested on serial ia64 linux with no regressions.

Ok?

Richard.


2004Jan17  Richard Guenther <richard.guenther at uni-tuebingen.de>

	* src/Engine/RemoteEngine.h: kill use of Unwrap<>.
	src/Evaluator/Reduction.h: likewise.
	src/Tulip/ReduceOverContexts.h: likewise.
	src/Evaluator/OpMask.h: likewise, provide fallback in
	OpMask instead.

diff -Nru a/r2/src/Engine/RemoteEngine.h b/r2/src/Engine/RemoteEngine.h
--- a/r2/src/Engine/RemoteEngine.h	Sat Jan 17 20:16:00 2004
+++ b/r2/src/Engine/RemoteEngine.h	Sat Jan 17 20:16:00 2004
@@ -2193,12 +2193,12 @@
       {
 	ret = vals[0];
 	for (j = 1; j < n; j++)
-	  Unwrap<Op>::unwrap(op)(ret, vals[j]);
+	  op(ret, vals[j]);
       }

     delete [] vals;

-    ReduceOverContexts<T, typename Unwrap<Op>::Op_t> finalReduction(ret, 0, n > 0);
+    ReduceOverContexts<T, Op> finalReduction(ret, 0, n > 0);
     if (Pooma::context() == 0)
       ret = finalReduction;

diff -Nru a/r2/src/Evaluator/OpMask.h b/r2/src/Evaluator/OpMask.h
--- a/r2/src/Evaluator/OpMask.h	Sat Jan 17 20:16:00 2004
+++ b/r2/src/Evaluator/OpMask.h	Sat Jan 17 20:16:00 2004
@@ -150,16 +150,25 @@
   OpMask(const Op &op) : op_m(op) { }
   ~OpMask() { }

+  /// WhereProxy Op, embed a conditional operation.
   template<class T1, class T2>
-  inline T1&
-  operator()(T1 &a, const T2 &b) const
+  inline void
+  operator()(T1 &a, const MaskAssign<T2> &b) const
   {
     if (b.defined())
     {
       op_m(a, b.value());
     }
-    return a;
   }
+
+  /// Fall back to native operation.
+  template<class T1, class T2>
+  inline void
+  operator()(T1 &a, const T2 &b) const
+  {
+    op_m(a, b);
+  }
+
   Op op_m;
 };

@@ -167,18 +176,6 @@
 struct BinaryReturn<T1, T2, OpMask<Op> >
 {
   typedef T1 &Type_t;
-};
-
-template <class Op>
-struct Unwrap {
-  typedef Op Op_t;
-  static inline const Op_t& unwrap(const Op &op) { return op; }
-};
-
-template <class Op>
-struct Unwrap<OpMask<Op> > {
-  typedef typename Unwrap<Op>::Op_t Op_t;
-  static inline const Op_t& unwrap(const OpMask<Op> &op) { return Unwrap<Op>::unwrap(op.op_m); }
 };

 template <class Op, class T>
diff -Nru a/r2/src/Evaluator/Reduction.h b/r2/src/Evaluator/Reduction.h
--- a/r2/src/Evaluator/Reduction.h	Sat Jan 17 20:16:00 2004
+++ b/r2/src/Evaluator/Reduction.h	Sat Jan 17 20:16:00 2004
@@ -259,7 +259,7 @@

     ret = vals[0];
     for (j = 1; j < n; j++)
-      Unwrap<Op>::unwrap(op)(ret, vals[j]);
+      op(ret, vals[j]);
     delete [] vals;
   }
 };
diff -Nru a/r2/src/Tulip/ReduceOverContexts.h b/r2/src/Tulip/ReduceOverContexts.h
--- a/r2/src/Tulip/ReduceOverContexts.h	Sat Jan 17 20:16:00 2004
+++ b/r2/src/Tulip/ReduceOverContexts.h	Sat Jan 17 20:16:00 2004
@@ -274,7 +274,7 @@
 	    if (!v.valid())
 	      v = *v2;
 	    else
-	      Unwrap<ReductionOp>::Op_t()(v.value(), v2->value());
+	      ReductionOp()(v.value(), v2->value());
           }
           Serialize_t::cleanup(v2);
         }
@@ -325,7 +325,7 @@
 	  }
 	else
 	  {
-	    Unwrap<ReductionOp>::Op_t()(me->value_m, v.value());
+	    ReductionOp()(me->value_m, v.value());
 	  }
       }




More information about the pooma-dev mailing list