[PATCH] Make PatchSizeSyncer::calcGlobalGrid() generic
Richard Guenther
rguenth at tat.physik.uni-tuebingen.de
Mon Dec 8 12:41:22 UTC 2003
Hi!
This patch makes use of CollectFromContexts inside
PatchSizeSyncer::calcGlobalGrid(), instead of handcrafting a Cheetah based
implementation. This reduces explicit Cheetah dependence to fewer places
(to aid adding a native MPI implementation).
Tested with a native MPI implementation.
Ok?
Richard.
2003Dec08 Richard Guenther <richard.guenther at uni-tuebingen.de>
* src/Tulip/PatchSizeSyncer.cmpl.cpp: use CollectFromContexts for
gather operation.
===== PatchSizeSyncer.cmpl.cpp 1.1 vs edited =====
--- 1.1/r2/src/Tulip/PatchSizeSyncer.cmpl.cpp Mon May 13 17:47:45 2002
+++ edited/PatchSizeSyncer.cmpl.cpp Fri Dec 5 16:46:01 2003
@@ -34,19 +34,16 @@
// Includes:
//-----------------------------------------------------------------------------
+#include "Tulip/Messaging.h"
#include "Tulip/PatchSizeSyncer.h"
#include "Tulip/RemoteProxy.h"
+#include "Tulip/CollectFromContexts.h"
+#include <utility>
#include <algorithm>
namespace Pooma {
-int PatchSizeSyncer::tag_s = 0;
-
-#if POOMA_CHEETAH
-Cheetah::MatchingHandler *PatchSizeSyncer::handler_s = 0;
-#endif
-
//-----------------------------------------------------------------------------
// PatchSize constructor & destructor...
//-----------------------------------------------------------------------------
@@ -68,19 +65,6 @@
}
//-----------------------------------------------------------------------------
-// PatchSizeSyncer::receiveGrid
-//
-// This function is passed on to the matching-handler and is invoked when
-// a message is received.
-//-----------------------------------------------------------------------------
-
-void PatchSizeSyncer::receiveGrid(std::pair<int,Grid_t> &incoming)
-{
- gridList_m.push_back(
- std::make_pair(incoming.first,new Grid_t(incoming.second)));
-}
-
-//-----------------------------------------------------------------------------
// PatchSizeSyncer::calcGlobalGrid
//
// Does a reduction of the grids, sending all the local grids to
@@ -108,40 +92,12 @@
{
#if POOMA_CHEETAH
- // Each context will send their local Grid to context 0.
- // We'll offset the base tag by the context number - 1 to
- // generate the tags for this.
-
- int tagbase = tag_s;
- tag_s += numContexts_m - 1;
-
Grid<1> result;
- if (myContext_m != 0)
- {
- handler_s->send(0, tagbase + myContext_m - 1,
- std::make_pair(localKey_m,localGrid_m));
- }
- else
+ CollectFromContexts<std::pair<int, Grid_t> > collection
+ (std::make_pair(localKey_m,localGrid_m));
+ if (myContext_m == 0)
{
- // Push the context 0 grid onto the list:
-
- gridList_m.push_back(std::make_pair(localKey_m,new Grid_t(localGrid_m)));
-
- // Request messages from the other contexts, which
- // will result in receiveGrid being invoked and
- // the remainder of gridList_m being filled.
-
- for (int i = 1; i < numContexts_m; ++i)
- {
- handler_s->request(i, tagbase + i - 1,
- &PatchSizeSyncer::receiveGrid,
- this);
- }
-
- while (gridList_m.size() < numContexts_m)
- Pooma::poll();
-
// The grid list is full. We sort it and then renormalize the
// domains to make them globally consistent. The
// renormalization is done by looking through the list and
@@ -149,6 +105,10 @@
// have been added on the previous grids. We simultaneously
// calculate the total number of points, needed to form the
// global result.
+
+ for (int j = 0; j < numContexts_m; ++j)
+ gridList_m.push_back(Elem_t(collection[j].first,
+ new Grid_t(collection[j].second)));
std::sort(gridList_m.begin(),gridList_m.end(),ElemCompare());
More information about the pooma-dev
mailing list