Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tree for key to node lookups instead of std::map. #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions Compute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2359,14 +2359,6 @@ void printUndlist(DoubleWalkState *state, int level, TreePiece *tp){

#endif // INTERLIST_VER > 0

void RemoteTreeBuilder::registerNode(GenericTreeNode *node){
tp->nodeLookupTable[node->getKey()] = node;
}

void LocalTreeBuilder::registerNode(GenericTreeNode *node){
tp->nodeLookupTable[node->getKey()] = node;
}

bool RemoteTreeBuilder::work(GenericTreeNode *node, int level){
CkAssert(node != NULL);
CkAssert(node->isValid() && !node->isCached());
Expand Down Expand Up @@ -2397,7 +2389,6 @@ bool RemoteTreeBuilder::work(GenericTreeNode *node, int level){
streamingProxy[node->remoteIndex].requestRemoteMoments(node->getKey(), tp->thisIndex, &opts);
}
}
registerNode(node);
return false;
}

Expand All @@ -2413,7 +2404,6 @@ bool RemoteTreeBuilder::work(GenericTreeNode *node, int level){
// from the particle positions.
node->boundingBox.reset();

registerNode(node);
return true;

default:
Expand Down Expand Up @@ -2486,7 +2476,6 @@ bool LocalTreeBuilder::work(GenericTreeNode *node, int level){
tp->bucketList.push_back(node);
tp->numBuckets++;

registerNode(node);
// deliver moments, since doneChildren() will
// never be called with a bucket
tp->deliverMomentsToClients(node);
Expand All @@ -2495,7 +2484,6 @@ bool LocalTreeBuilder::work(GenericTreeNode *node, int level){
else if(node->getType() == Empty){
node->remoteIndex = tp->thisIndex;

registerNode(node);
// deliver MomentsToClients, since remote pieces don't know its
// an empty node.
tp->deliverMomentsToClients(node);
Expand All @@ -2510,7 +2498,6 @@ bool LocalTreeBuilder::work(GenericTreeNode *node, int level){
node->boundingBox.reset();
node->remoteIndex = tp->thisIndex;

registerNode(node);
// don't deliver MomentsToClients, since we
// haven't yet computed the moments for this
// node: this will happen only after the moments
Expand Down
7 changes: 0 additions & 7 deletions Compute.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,6 @@ class RemoteTreeBuilder : public TreeNodeWorker {

bool work(GenericTreeNode *node, int level);
void doneChildren(GenericTreeNode *node, int level);

private:
void registerNode(GenericTreeNode *node);

};

/// @brief Class to build the local part of the tree. Builds Internal nodes.
Expand All @@ -312,9 +308,6 @@ class LocalTreeBuilder : public TreeNodeWorker {

bool work(GenericTreeNode *node, int level);
void doneChildren(GenericTreeNode *node, int level);

private:
void registerNode(GenericTreeNode *node);
};

/** @brief TreeNodeWorker implementation that just prints out the
Expand Down
11 changes: 0 additions & 11 deletions DataManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,6 @@ void DataManager::combineLocalTrees(CkReductionMsg *msg) {
}
nodeTable.clear();

#ifdef CUDA
cumNumReplicatedNodes = 0;
#endif

CkVec<Tree::GenericTreeNode*> gtn;
for(int i = 0; i < registeredTreePieces.length(); i++){
gtn.push_back(registeredTreePieces[i].root);
Expand Down Expand Up @@ -317,9 +313,6 @@ const char *typeString(NodeType type);
* to the copies in each treepiece of an identical node.
*/
Tree::GenericTreeNode *DataManager::buildProcessorTree(int n, Tree::GenericTreeNode **gtn) {
#ifdef CUDA
cumNumReplicatedNodes += (n-1);
#endif
int nUnresolved;
int pickedIndex;
GenericTreeNode *pickedNode = pickNodeFromMergeList(n,gtn,nUnresolved,pickedIndex);
Expand Down Expand Up @@ -786,22 +779,18 @@ void DataManager::serializeLocal(GenericTreeNode *node){
CkQ<GenericTreeNode *> queue;

int numTreePieces = registeredTreePieces.length();
int numNodes = 0;
int numParticles = 0;
int numCachedNodes = 0;
int numCachedParticles = 0;

for(int i = 0; i < numTreePieces; i++){
TreePiece *tp = registeredTreePieces[i].treePiece;
numNodes += tp->getNumNodes();
numParticles += tp->getDMNumParticles();
}
numNodes -= cumNumReplicatedNodes;

CkVec<CudaMultipoleMoments> localMoments;
CkVec<CompactPartData> localParticles;

localMoments.reserve(numNodes);
localParticles.resize(numParticles);

localMoments.length() = 0;
Expand Down
4 changes: 0 additions & 4 deletions DataManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,6 @@ class DataManager : public CBase_DataManager {
// holds chare array indices of registered treepieces
CkVec<TreePieceDescriptor> registeredTreePieces;
#ifdef CUDA
//CkVec<int> registeredTreePieceIndices;
/// @brief counter for the number of tree nodes that are
/// replicated by TreePieces that share the same address space.
int cumNumReplicatedNodes;
int treePiecesDone;
int savedChunk;
int treePiecesDonePrefetch;
Expand Down
27 changes: 9 additions & 18 deletions ParallelGravity.h
Original file line number Diff line number Diff line change
Expand Up @@ -1037,11 +1037,16 @@ class TreePiece : public CBase_TreePiece {
#if INTERLIST_VER > 0
GenericTreeNode *getStartAncestor(int current, int previous, GenericTreeNode *dflt);
#endif
/// \brief convert a key to a node using the nodeLookupTable
/// \brief convert a key to a node using the tree
/// \param k NodeKey constructed from the path to the Node
/// \returns pointer to the Node, if found. Otherwise NULL.
inline GenericTreeNode *keyToNode(const Tree::NodeKey k){
NodeLookupType::iterator iter = nodeLookupTable.find(k);
if (iter != nodeLookupTable.end()) return iter->second;
else return NULL;
GenericTreeNode *thisNode = root;
while(thisNode != NULL && thisNode->getKey() != k) {
int iChild = thisNode->whichChild(k);
thisNode = thisNode->getChildren(iChild);
}
return thisNode;
}

GenericTreeNode *getBucket(int i){
Expand Down Expand Up @@ -1227,9 +1232,6 @@ class TreePiece : public CBase_TreePiece {
int64_t nStartWrite; // Particle number at which this piece starts
// to write file.

/// Map between Keys and TreeNodes, used to get a node from a key
NodeLookupType nodeLookupTable;

/// Number of nodes still missing before starting the real computation
//u_int64_t prefetchWaiting;
/// Array of keys that will be the root of the prefetching chunks
Expand Down Expand Up @@ -1353,28 +1355,18 @@ class TreePiece : public CBase_TreePiece {
void quiescence();
/*END DEBUGGING */

NodeLookupType &getNodeLookupTable() {
return nodeLookupTable;
}

int getNumNodes() {
return nodeLookupTable.size();
}

/// delete treenodes if allocated
void deleteTree() {
if(pTreeNodes != NULL) {
delete pTreeNodes;
pTreeNodes = NULL;
root = NULL;
nodeLookupTable.clear();
}
else {
if (root != NULL) {
root->fullyDelete();
delete root;
root = NULL;
nodeLookupTable.clear();
}
}
}
Expand Down Expand Up @@ -1412,7 +1404,6 @@ class TreePiece : public CBase_TreePiece {
* to trigger nextBucket() which will loop over all the buckets.
*/
void doAllBuckets();
void reconstructNodeLookup(GenericTreeNode *node);
//void rebuildSFCTree(GenericTreeNode *node,GenericTreeNode *parent,int *);

public:
Expand Down
14 changes: 0 additions & 14 deletions TreePiece.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2772,7 +2772,6 @@ void TreePiece::startORBTreeBuild(CkReductionMsg* m){
if (thisIndex == 0) root->firstParticle ++;
if (thisIndex == (int)numTreePieces-1) root->lastParticle --;
root->particleCount = myNumParticles;
nodeLookupTable[(Tree::NodeKey)1] = root;

//root->key = firstPossibleKey;
root->boundingBox = boundingBox;
Expand Down Expand Up @@ -2879,7 +2878,6 @@ void TreePiece::buildORBTree(GenericTreeNode * node, int level){
#if INTERLIST_VER > 0
child->startBucket=numBuckets;
#endif
nodeLookupTable[child->getKey()] = child;
if (child->getType() == NonLocal) {
// find a remote index for the node
int first, last;
Expand Down Expand Up @@ -3036,7 +3034,6 @@ void TreePiece::startOctTreeBuild(CkReductionMsg* m) {
if (myPlace == 0) root->firstParticle ++;
if (myPlace == dm->responsibleIndex.size()-1) root->lastParticle --;
root->particleCount = myNumParticles;
nodeLookupTable[(Tree::NodeKey)1] = root;

root->boundingBox = boundingBox;
numBuckets = 0;
Expand Down Expand Up @@ -5796,17 +5793,6 @@ void TreePiece::pup(PUP::er& p) {
}
}

void TreePiece::reconstructNodeLookup(GenericTreeNode *node) {
nodeLookupTable[node->getKey()] = node;
node->particlePointer = &myParticles[node->firstParticle];
if (node->getType() == Bucket) bucketList.push_back(node);
GenericTreeNode *child;
for (unsigned int i=0; i<node->numChildren(); ++i) {
child = node->getChildren(i);
if (child != NULL) reconstructNodeLookup(child);
}
}

/** Check that all the particles in the tree are really in their boxes.
Because the keys are made of only the first 21 out of 23 bits of the
floating point representation, there can be particles that are outside
Expand Down
Loading