[PATCH] Fix ReduceOverContexts

Richard Guenther rguenth at tat.physik.uni-tuebingen.de
Tue Dec 2 17:17:20 UTC 2003


Hi!

The following patch fixes ReduceOverContext wrt "invalid" participants of
the reduction (I dont think I ever came along these, though...).

Seems obviously correct, but it isnt used extensively (only user of the
validity argument seems to be Reduction<RemoteMultiPatchEvaluatorTag> and
the case of invalidity is not covered in the testsuite).

The problem is that if the owning context has an invalid value, we're
calling the reduction operator on an uninitialized value. Ugh.

Ok?

Richard.


===== ReduceOverContexts.h 1.2 vs edited =====
--- 1.2/r2/src/Tulip/ReduceOverContexts.h	Thu Oct 23 14:41:05 2003
+++ edited/ReduceOverContexts.h	Tue Dec  2 18:07:24 2003
@@ -34,7 +34,8 @@
 /** @file
  * @ingroup Tulip
  * @brief
- * Undocumented.
+ * ReduceOverContexts encapsulates functionality like MPI_Reduce
+ * and MPI_Allreduce by means of the ReduceOverContexts::broadcast() method.
  */

 #ifndef POOMA_CHEETAH_REDUCEOVERCONTEXTS_H
@@ -196,11 +197,8 @@
 #if POOMA_CHEETAH

   ReduceOverContexts(const T &val, int toContext = 0, bool valid = true)
-    : toContext_m(toContext)
+    : valid_m(false), toContext_m(toContext)
     {
-      if (valid)
-        value_m = val;
-
       int tagBase = tagBase_m;
       tagBase_m += Pooma::contexts();

@@ -267,9 +265,10 @@
   {
     if (v.valid())
       {
-	if (me->toReceive_m == Pooma::contexts())
+	if (!valid_m)
 	  {
 	    me->value_m = v.value();
+	    me->valid_m = true;
 	  }
 	else
 	  {
@@ -280,9 +279,13 @@
     me->toReceive_m--;
   }

- // The actual value we're reducing.
+  // The actual value we're reducing.

   T value_m;
+
+  // If its valid.
+
+  bool valid_m;

   // The number of messages we're receiving.




More information about the pooma-dev mailing list