[pooma-dev] Re: [PATCH] Fix ReduceOverContexts
Richard Guenther
rguenth at tat.physik.uni-tuebingen.de
Tue Dec 2 19:22:37 UTC 2003
On Tue, 2 Dec 2003, Jeffrey D. Oldham wrote:
> Richard Guenther wrote:
> > 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?
>
> Yes. Please correct the spelling noted below.
> > T value_m;
> > +
> > + // If its valid.
>
> Will you please change the spelling to:
>
> If it's valid.
Ok, for the record, I committed the patch below which has an additional
typo fixed (s/value_m/me->value_m/) revealed during a compile check.
Richard.
2003Dec02 Richard Guenther <richard.guenther at uni-tuebingen.de>
* src/Tulip/ReduceOverContexts.h: handle case that reduction context
has invalid value.
Index: ReduceOverContexts.h
===================================================================
RCS file: /home/pooma/Repository/r2/src/Tulip/ReduceOverContexts.h,v
retrieving revision 1.9
diff -u -u -r1.9 ReduceOverContexts.h
--- ReduceOverContexts.h 21 Oct 2003 18:47:59 -0000 1.9
+++ ReduceOverContexts.h 2 Dec 2003 19:14:00 -0000
@@ -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 (!me->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 it's valid.
+
+ bool valid_m;
// The number of messages we're receiving.
More information about the pooma-dev
mailing list