started pup code
authorPritish Jetley <pjetley2@illinois.edu>
Sun, 16 Oct 2011 23:14:27 +0000 (18:14 -0500)
committerPritish Jetley <pjetley2@illinois.edu>
Sun, 16 Oct 2011 23:14:27 +0000 (18:14 -0500)
DataManager.cpp
Main.cpp
State.cpp
State.h
TreePiece.cpp
TreePiece.h
Worker.cpp
Worker.h
defines.h
gravity.h

index d03d123..dc00176 100644 (file)
@@ -917,6 +917,9 @@ void DataManager::startTraversal(){
 void DataManager::requestParticles(Node<ForceData> *leaf, CutoffWorker<ForceData> *worker, State *state, Traversal<ForceData> *traversal){
   Key key = leaf->getKey();
   Request &request = particleRequestTable[key];
+#ifdef TRACE_REMOTE_DATA_REQUESTS
+  traceUserEvent(REMOTE_PARTICLE_REQUEST);
+#endif
   if(!request.sent){
     partReqs.incrRequests();
 
@@ -971,6 +974,9 @@ void DataManager::requestParticles(RequestMsg *msg){
 void DataManager::requestNode(Node<ForceData> *leaf, CutoffWorker<ForceData> *worker, State *state, Traversal<ForceData> *traversal){
   Key key = leaf->getKey();
   Request &request = nodeRequestTable[key];
+#ifdef TRACE_REMOTE_DATA_REQUESTS
+  traceUserEvent(REMOTE_NODE_REQUEST);
+#endif
   if(!request.sent){
     nodeReqs.incrRequests();
 
index 32c8d01..49c85cc 100644 (file)
--- a/Main.cpp
+++ b/Main.cpp
@@ -24,10 +24,17 @@ Main::Main(CkArgMsg *msg){
   dataManagerProxy = CProxy_DataManager::ckNew();
 
   CkArrayOptions opts(globalParams.numTreePieces);
+  /*
   CProxy_RRMap myMap = CProxy_RRMap::ckNew();
   opts.setMap(myMap);
+  */
   treePieceProxy = CProxy_TreePiece::ckNew(opts);
 
+#ifdef TRACE_REMOTE_DATA_REQUESTS
+  traceRegisterUserEvent("Node",REMOTE_NODE_REQUEST);
+  traceRegisterUserEvent("Particles",REMOTE_PARTICLE_REQUEST);
+#endif
+
   mainProxy = thisProxy;
 
   thisProxy.commence();
index db24d3a..89ca0c2 100644 (file)
--- a/State.cpp
+++ b/State.cpp
@@ -3,36 +3,18 @@
 #include "TreePiece.h"
 
 void State::nodeEncountered(Key bucketKey, Node<ForceData> *node){
-#ifdef TREE_PIECE_LOG
-  logFile << "bucket " << bucketKey 
-    << " node " << node->getKey() 
-    << " type " << NodeTypeString[node->getType()] 
-    << " radius " << node->data.moments.radius
-    << " cm " << node->data.moments.cm.x 
-    << "," << node->data.moments.cm.y 
-    << "," << node->data.moments.cm.z
-    << endl;
-#endif
-
 #ifdef VERBOSE_TRAVERSAL
   CkPrintf("(%d,%d) %s bucket %lu encountered node %lu type %s radius %f\n", ownerTreePiece->getIndex(), ownerTreePiece->getIteration(), description.c_str(), bucketKey, node->getKey(), NodeTypeString[node->getType()].c_str(), node->data.moments.radius);
 #endif
 }
 
 void State::nodeOpened(Key bucketKey, Node<ForceData> *node){
-#ifdef TREE_PIECE_LOG
-#endif
-
 #ifdef VERBOSE_TRAVERSAL
   CkPrintf("(%d,%d) %s bucket %lu opened node %lu type %s \n", ownerTreePiece->getIndex(), ownerTreePiece->getIteration(), description.c_str(), bucketKey, node->getKey(), NodeTypeString[node->getType()].c_str());
 #endif
 }
 
 void State::nodeDiscarded(Key bucketKey, Node<ForceData> *node){
-#ifdef TREE_PIECE_LOG
-  logFile << "bucket " << bucketKey << " discarded node" << node->getKey() << endl;
-#endif
-
 #ifdef VERBOSE_TRAVERSAL
   CkPrintf("(%d,%d) %s bucket %lu discarding node %lu\n", ownerTreePiece->getIndex(), ownerTreePiece->getIteration(), description.c_str(), bucketKey, node->getKey());
 #endif
@@ -41,42 +23,16 @@ void State::nodeDiscarded(Key bucketKey, Node<ForceData> *node){
 }
 
 void State::nodeComputed(Node<ForceData> *bucket, Key nodeKey){
-#ifdef TREE_PIECE_LOG
-  logFile << "bucket " << bucket->getKey() << " node " << nodeKey << " COMPUTE " << endl;
-#endif
 #ifdef VERBOSE_TRAVERSAL
   string nanStr = "";
-  /*
-  int numParticles = bucket->getNumParticles();
-  Particle *particles = bucket->getParticles();
-  for(int i = 0; i < numParticles; i++){
-    if(isnan(particles[i].acceleration.length())){
-      nanStr = "NAN DETECTED!\n";
-      break;
-    }
-  }
-  */
   CkPrintf("(%d,%d) %s bucket %lu (%s) computing node %lu\n", ownerTreePiece->getIndex(), ownerTreePiece->getIteration(), description.c_str(), bucket->getKey(), nanStr.c_str(), nodeKey);
 #endif
   insert(bucket->getKey(),nodeKey);
 }
 
 void State::bucketComputed(Node<ForceData> *bucket, Key k){
-#ifdef TREE_PIECE_LOG
-  logFile << "bucket " << bucket->getKey() << " PARTICLES " << k << endl;
-#endif
 #ifdef VERBOSE_TRAVERSAL
   string nanStr = "";
-  /*
-  int numParticles = bucket->getNumParticles();
-  Particle *particles = bucket->getParticles();
-  for(int i = 0; i < numParticles; i++){
-    if(isnan(particles[i].acceleration.length())){
-      nanStr = "NAN DETECTED!";
-      break;
-    }
-  }
-  */
   CkPrintf("(%d,%d) %s bucket %lu (%s) computing bucket %lu\n", ownerTreePiece->getIndex(), ownerTreePiece->getIteration(), description.c_str(), bucket->getKey(), nanStr.c_str(), k);
 #endif
   insert(bucket->getKey(),k);
diff --git a/State.h b/State.h
index 2da6b27..10bf8ad 100644 (file)
--- a/State.h
+++ b/State.h
@@ -11,8 +11,6 @@ using namespace std;
 
 extern string NodeTypeString[];
 
-//typedef void (*StateCompletionFn)(void *context);
-
 class TreePiece;
 struct State {
   int pending;
@@ -22,22 +20,18 @@ struct State {
 
 #ifdef DEBUG_TRAVERSALS
   map<Key,set<Key> > bucketKeys;
+  string description;
 #endif
 
 #ifdef STATISTICS
   CmiUInt8 numInteractions[3];
 #endif
 
-#ifdef TREE_PIECE_LOG
-  ofstream logFile;
-#endif
-
 #ifdef CHECK_NUM_INTERACTIONS
   map<Key,CmiUInt8> bucketNodeInteractions;
   map<Key,CmiUInt8> bucketPartInteractions;
 #endif
 
-  string description;
 
   void incrPending() { pending++; }
   bool decrPending() {
@@ -66,27 +60,10 @@ struct State {
 #endif
   }
   
-  State(int i, string id, TreePiece *tp) : 
-    pending(-1), 
-    current(-1), 
-    ownerTreePiece(tp),
-    currentBucketPtr(NULL) 
-  {
-#ifdef TREE_PIECE_LOG
-    ostringstream oss;
-    oss << "tp." << i << "." << id << ".log";
-    logFile.open(oss.str().c_str());
-#endif
-    description = id;
-
-#ifdef STATISTICS
-    numInteractions[0] = 0;
-    numInteractions[1] = 0;
-    numInteractions[2] = 0;
-#endif
-  }
-
-  void reset(int p, Node<ForceData> **bucketPtr){
+  void reset(TreePiece *owner, int p, Node<ForceData> **bucketPtr){
+  //void reset(TreePiece *owner, string &id, int p, Node<ForceData> **bucketPtr){
+    ownerTreePiece = owner;
+    //description = id;
     pending = p;
     current = 0;
     currentBucketPtr = bucketPtr;
@@ -99,9 +76,6 @@ struct State {
   void bucketComputed(Node<ForceData> *bucket, Key k);
 
   void finishedIteration(){
-#ifdef TREE_PIECE_LOG
-    logFile.close();
-#endif
 #ifdef STATISTICS
     numInteractions[0] = 0;
     numInteractions[1] = 0;
@@ -151,13 +125,4 @@ struct State {
   }
 };
 
-/*
-struct TraversalState {
-  int curBucket;
-
-  TraversalState() : curBucket(0), State(cb,context,pending) {}
-};
-*/
-
-
 #endif
index 6a527e0..a537028 100644 (file)
@@ -14,17 +14,18 @@ TreePiece::TreePiece() :
   numDecompMsgsRecvd(0),
   smallestKey(~Key(0)),
   largestKey(Key(0)),
-  localTraversalState(thisIndex,"local",this),
-  remoteTraversalState(thisIndex,"remote",this),
+  localTraversalState(),
+  remoteTraversalState(),
   localStateID(0), 
   remoteStateID(1),
-  localTraversalWorker(this),
-  remoteTraversalWorker(this),
+  localTraversalWorker(),
+  remoteTraversalWorker(),
   totalNumTraversals(2),
   iteration(0),
   numTraversalsDone(0)
 {
   myDM = dataManagerProxy.ckLocalBranch();
+  usesAtSync = true;
 }
 
 void TreePiece::receiveParticles(ParticleMsg *msg){
@@ -69,15 +70,15 @@ void TreePiece::startTraversal(){
     return;
   }
 
-  remoteTraversalState.reset(myNumBuckets,myBuckets);
-  remoteTraversalWorker.reset(&remoteTraversalState,*myBuckets);
+  remoteTraversalState.reset(this,myNumBuckets,myBuckets);
+  remoteTraversalWorker.reset(this,&remoteTraversalState,*myBuckets);
   RescheduleMsg *msg = new (NUM_PRIORITY_BITS) RescheduleMsg;
   *(int *)CkPriorityPtr(msg) = REMOTE_GRAVITY_PRIORITY;
   CkSetQueueing(msg, CK_QUEUEING_IFIFO);
   thisProxy[thisIndex].doRemoteGravity(msg);
 
-  localTraversalState.reset(myNumBuckets,myBuckets);
-  localTraversalWorker.reset(&localTraversalState,*myBuckets);
+  localTraversalState.reset(this,myNumBuckets,myBuckets);
+  localTraversalWorker.reset(this,&localTraversalState,*myBuckets);
 
   msg = new (NUM_PRIORITY_BITS) RescheduleMsg;
   *(int *)CkPriorityPtr(msg) = LOCAL_GRAVITY_PRIORITY;
@@ -100,7 +101,7 @@ void TreePiece::doLocalGravity(RescheduleMsg *msg){
     localGravityDone();
     delete msg;
   }
-  else{
+  else if(localTraversalState.current < myNumBuckets) {
     thisProxy[thisIndex].doLocalGravity(msg);
   }
 }
@@ -120,7 +121,7 @@ void TreePiece::doRemoteGravity(RescheduleMsg *msg){
     remoteGravityDone();
     delete msg;
   }
-  else{
+  else if (remoteTraversalState.current < myNumBuckets) {
     thisProxy[thisIndex].doRemoteGravity(msg);
   }
 }
@@ -264,5 +265,11 @@ int TreePiece::getIteration() {
   return iteration;
 }
 
+void TreePiece::pup(PUP::er &p){
+  p | iteration;
+  if(p.isUnpacking()){
+  }
+}
+
 #include "Traversal_defs.h"
 
index b2f6764..9841a6d 100644 (file)
@@ -74,6 +74,8 @@ class TreePiece : public CBase_TreePiece {
 
   void quiescence();
   int getIteration();
+
+  void pup(PUP::er &p);
 };
 
 #endif
index ece2a2c..94bea53 100644 (file)
@@ -127,7 +127,7 @@ int TraversalWorker::work(Node<ForceData> *node){
   }
 
   // basic opening criterion
-  bool open = openCriterionBucket(node,currentBucket,offset);
+  bool open = openCriterionBucket(node,currentBucket);
   state->incrOpenCriterion();
   if(open){
     state->nodeOpened(currentBucket->getKey(),node);
index 05de11c..12b4d5e 100644 (file)
--- a/Worker.h
+++ b/Worker.h
@@ -78,28 +78,18 @@ class TraversalWorker : public CutoffWorker<ForceData> {
   TreePiece *ownerTreePiece;
   State *state;
   
-  // XXX for later
-  Vector3D<Real> offset;
-
   Node<ForceData> *currentBucket;
 
-  TraversalWorker(TreePiece *tp) : 
-    ownerTreePiece(tp),
-    offset(), 
-    currentBucket(NULL)
-  {
-  }
-
   TraversalWorker() : 
     ownerTreePiece(NULL),
-    offset(), 
     currentBucket(NULL)
   {
   }
 
   public:
 
-  void reset(State *s, Node<ForceData> *bucket){
+  void reset(TreePiece *owner, State *s, Node<ForceData> *bucket){
+    ownerTreePiece = owner;
     state = s;
     currentBucket = bucket;
   }
@@ -127,7 +117,6 @@ class TraversalWorker : public CutoffWorker<ForceData> {
 class LocalTraversalWorker : public TraversalWorker {
   static const bool keep[];
   public:
-  LocalTraversalWorker(TreePiece *tp) : TraversalWorker(tp) {}
   LocalTraversalWorker() : TraversalWorker() {}
   bool getKeep(NodeType type);
 };
@@ -135,7 +124,6 @@ class LocalTraversalWorker : public TraversalWorker {
 class RemoteTraversalWorker : public TraversalWorker {
   static const bool keep[];
   public:
-  RemoteTraversalWorker(TreePiece *tp) : TraversalWorker(tp) {}
   RemoteTraversalWorker() : TraversalWorker() {}
   void done();
   bool getKeep(NodeType type);
index 0a75cd5..7db4aa6 100644 (file)
--- a/defines.h
+++ b/defines.h
@@ -45,4 +45,7 @@ const double opening_geometry_factor = 2 / sqrt(3.0);
 #define REMOTE_GRAVITY_PRIORITY (-2)
 #define LOCAL_GRAVITY_PRIORITY (-1)
 
+#define REMOTE_NODE_REQUEST 9998
+#define REMOTE_PARTICLE_REQUEST 9999
+
 #endif
index 5912b99..beada22 100644 (file)
--- a/gravity.h
+++ b/gravity.h
@@ -11,9 +11,7 @@ extern Parameters globalParams;
 
 inline bool
 openCriterionBucket(Node<ForceData> *node,
-                   Node<ForceData> *bucketNode,
-                   Vector3D<Real> &offset 
-                   ) {
+                   Node<ForceData> *bucketNode) {
 
   Vector3D<Real> dr = node->data.moments.cm - bucketNode->data.moments.cm;
   Real drsq = dr.lengthSquared();