From d5d725ac287c22fdd136315c9edaecbb039e2195 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Thu, 23 Mar 2023 09:44:59 -0700 Subject: [PATCH 01/11] temporary changes while testing FoF --- Makefile.common | 13 +++++---- examples/simple_graph/graph.C | 6 ++-- prefixLib/Makefile | 2 +- types.h | 2 +- unionFindLib.C | 52 +++++++++++++++++++++++++++-------- unionFindLib.h | 22 +++++++-------- 6 files changed, 63 insertions(+), 34 deletions(-) diff --git a/Makefile.common b/Makefile.common index 29a54e0..af08f00 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1,19 +1,20 @@ #set the following variables to absolute paths -CHARM_DIR = /Users/raghu/work/charm/charm -UNION_FIND_DIR = /Users/raghu/work/charm/unionFind/unionFind +CHARM_DIR = /Users/johnnychen/Documents/Projects/research/charm +UNION_FIND_DIR = /Users/johnnychen/Documents/Projects/research/unionfind PREFIX_LIB_DIR = $(UNION_FIND_DIR)/prefixLib #charmc options ANCHOR= -DANCHOR_ALGO #ANCHOR= PROFILE= -DPROFILING -CHARMC = $(CHARM_DIR)/bin/charmc $(ANCHOR) $(PROFILE) -OPTS = -std=c++11 -O3 -g +CHARMC = $(CHARM_DIR)/bin/charmc $(PROFILE) #$(ANCHOR) +OPTS = -std=c++11 -O0 -g #was -03 LD_OPTS = +# CK_TEMPLATES = -DCK_TEMPLATES_ONLY #options for building union-find library and prefix library PREFIX_LIBS = -L${PREFIX_LIB_DIR} -lprefix -PREFIX_INC = -I${PREFIX_LIB_DIR} +PREFIX_INC = -I${PREFIX_LIB_DIR} # ${CK_TEMPLATES} UNION_FIND_LIBS = -L${UNION_FIND_DIR} -lunionFind ${PREFIX_LIBS} -UNION_FIND_INC = -I${UNION_FIND_DIR} ${PREFIX_INC} +UNION_FIND_INC = -I${UNION_FIND_DIR} ${PREFIX_INC} diff --git a/examples/simple_graph/graph.C b/examples/simple_graph/graph.C index 1379dab..71263d9 100644 --- a/examples/simple_graph/graph.C +++ b/examples/simple_graph/graph.C @@ -147,7 +147,7 @@ class TreePiece : public CBase_TreePiece { libPtr = libProxy[thisIndex].ckLocal(); libPtr->initialize_vertices(libVertices, numMyVertices); libPtr->registerGetLocationFromID(getLocationFromID); - contribute(CkCallback(CkReductionTarget(Main, startWork), mainProxy)); + contribute(CkCallback(CkReductionTarget(Main, Main::startWork), mainProxy)); } void doWork() { @@ -172,7 +172,7 @@ class TreePiece : public CBase_TreePiece { CkAbort("Something wrong in inverted-tree construction!\n"); } } - contribute(CkCallback(CkReductionTarget(Main, donePrinting), mainProxy)); + contribute(CkCallback(CkReductionTarget(Main, Main::donePrinting), mainProxy)); } void getConnectedComponents() { @@ -210,4 +210,4 @@ TreePiece::getLocationFromID(long int vid) { } -#include "graph.def.h" +#include "graph.def.h" \ No newline at end of file diff --git a/prefixLib/Makefile b/prefixLib/Makefile index d5ced14..0351d03 100644 --- a/prefixLib/Makefile +++ b/prefixLib/Makefile @@ -3,7 +3,7 @@ CHARMC=/Users/raghu/work/charm/charm/bin/charmc $(OPTS) all: libprefix.a libprefix.a: prefixBalance.o - $(CHARMC) prefixBalance.o -o libprefix.a -language charm++ + $(CHARMC) prefixBalance.o -o libprefix.a -language charm++ # -DCK_TEMPLATES_ONLY prefixBalance.o : prefixBalance.C prefixBalance.def.h prefixBalance.decl.h $(CHARMC) -c prefixBalance.C diff --git a/types.h b/types.h index 73e85d4..7a926d3 100644 --- a/types.h +++ b/types.h @@ -26,7 +26,7 @@ struct anchorData { struct shortCircuitData { uint64_t arrIdx; - uint64_t grandparentID; + int64_t grandparentID; void pup(PUP::er &p) { p|arrIdx; diff --git a/unionFindLib.C b/unionFindLib.C index feb603b..5d50969 100644 --- a/unionFindLib.C +++ b/unionFindLib.C @@ -46,7 +46,7 @@ static void register_merge_count_maps_reduction() { // class function implementations void UnionFindLib:: -registerGetLocationFromID(std::pair (*gloc)(long int vid)) { +registerGetLocationFromID(std::pair (*gloc)(uint64_t vid)) { getLocationFromID = gloc; } @@ -72,13 +72,15 @@ initialize_vertices(unionFindVertex *appVertices, int numVertices) { #ifndef ANCHOR_ALGO void UnionFindLib:: -union_request(long int vid1, long int vid2) { +union_request(uint64_t vid1, uint64_t vid2) { + assert(vid1!=vid2); if (vid2 < vid1) { // found a back edge, flip and reprocess union_request(vid2, vid1); } else { //std::pair vid1_loc = appPtr->getLocationFromID(vid1); + CkPrintf("union_request gloc\n"); std::pair vid1_loc = getLocationFromID(vid1); //message the chare containing first vertex to find boss1 //pass the initilizer ID for initiating path compression @@ -109,12 +111,14 @@ union_request(long int v, long int w) { #ifndef ANCHOR_ALGO void UnionFindLib:: -find_boss1(int arrIdx, long int partnerID, long int senderID) { +find_boss1(int arrIdx, uint64_t partnerID, uint64_t senderID) { unionFindVertex *src = &myVertices[arrIdx]; + CkAssert(src->vertexID != src->parent); src->findOrAnchorCount++; if (src->parent == -1) { //boss1 found + CkPrintf("find_boss1 if gloc\n"); std::pair partner_loc = getLocationFromID(partnerID); //message the chare containing the partner //senderID for first find_boss2 is not relevant, similar to first find_boss1 @@ -135,6 +139,7 @@ find_boss1(int arrIdx, long int partnerID, long int senderID) { } else { //boss1 not found, move to parent + CkPrintf("find_boss1 else gloc\n"); std::pair parent_loc = getLocationFromID(src->parent); unionFindVertex *path_base = src; unionFindVertex *parent, *curr = src; @@ -165,6 +170,8 @@ find_boss1(int arrIdx, long int partnerID, long int senderID) { // move pointers to traverse tree curr = parent; + CkPrintf("find_boss1 else compression gloc\n"); + CkPrintf("thisIndex=%d\n", this->thisIndex); parent_loc = getLocationFromID(curr->parent); } //end of local tree climbing @@ -188,6 +195,7 @@ find_boss1(int arrIdx, long int partnerID, long int senderID) { // check if sender and current vertex are on different chares if (senderID != -1 && !check_same_chares(senderID, curr->vertexID)) { // short circuit the sender to point to grandparent + CkPrintf("find_boss1 else sender and curr diff gloc\n"); std::pair sender_loc = getLocationFromID(senderID); shortCircuitData scd; scd.arrIdx = sender_loc.second; @@ -202,8 +210,9 @@ find_boss1(int arrIdx, long int partnerID, long int senderID) { void UnionFindLib:: -find_boss2(int arrIdx, long int boss1ID, long int senderID) { - unionFindVertex *src = &myVertices[arrIdx]; +find_boss2(int arrIdx, uint64_t boss1ID, uint64_t senderID) { + unionFindVertex *src = &myVertices[arrIdx]; // vid1, other field is vid2 (boss1ID) - same for find_boss1 + CkAssert(src->vertexID != src->parent); src->findOrAnchorCount++; if (src->parent == -1) { @@ -214,6 +223,7 @@ find_boss2(int arrIdx, long int boss1ID, long int senderID) { else { //valid edge if (boss1ID != src->vertexID) {//avoid self-loop + //J.C: end of recursion, I think src->parent = boss1ID; //message initID to start path compression in boss2's chain /*std::pair init_loc = appPtr->getLocationFromID(initID); @@ -226,6 +236,7 @@ find_boss2(int arrIdx, long int boss1ID, long int senderID) { else { //boss2 not found, move to parent //std::pair parent_loc = appPtr->getLocationFromID(src->parent); + CkPrintf("find_boss2 else gloc\n"); std::pair parent_loc = getLocationFromID(src->parent); unionFindVertex *path_base = src; unionFindVertex *parent, *curr = src; @@ -249,6 +260,8 @@ find_boss2(int arrIdx, long int boss1ID, long int senderID) { } curr = parent; + + CkPrintf("find_boss2 else compression gloc\n"); parent_loc = getLocationFromID(curr->parent); } //end of local tree climbing @@ -272,6 +285,8 @@ find_boss2(int arrIdx, long int boss1ID, long int senderID) { // check if sender and current vertex are on different chares if (senderID != -1 && !check_same_chares(senderID, curr->vertexID)) { // short circuit the sender to point to grandparent + + CkPrintf("find_boss2 else sender and curr diff gloc\n"); std::pair sender_loc = getLocationFromID(senderID); shortCircuitData scd; scd.arrIdx = sender_loc.second; @@ -365,21 +380,25 @@ anchor(int w_arrIdx, long int v, long int path_base_arrIdx) { // perform local path compression void UnionFindLib:: -local_path_compression(unionFindVertex *src, long int compressedParent) { +local_path_compression(unionFindVertex *src, uint64_t compressedParent) { unionFindVertex* tmp; // An infinite loop if this function is called on itself (a node which does not have itself as its parent) while (src->parent != compressedParent) { // CkPrintf("Stuck here\n"); + CkPrintf("local_path_compression gloc\n"); tmp = &myVertices[getLocationFromID(src->parent).second]; src->parent = compressedParent; + CkAssert(src->parent != src->vertexID); // TODO: remove assert src =tmp; } } // check if two vertices are on same chare bool UnionFindLib:: -check_same_chares(long int v1, long int v2) { +check_same_chares(uint64_t v1, uint64_t v2) { + CkPrintf("check_same_chares v1 gloc\n"); std::pair v1_loc = getLocationFromID(v1); + CkPrintf("check_same_chares v2 gloc\n"); std::pair v2_loc = getLocationFromID(v2); if (v1_loc.first == v2_loc.first) return true; @@ -392,19 +411,23 @@ short_circuit_parent(shortCircuitData scd) { unionFindVertex *src = &myVertices[scd.arrIdx]; //CkPrintf("[TP %d] Short circuiting %ld from current parent %ld to grandparent %ld\n", thisIndex, src->vertexID, src->parent, grandparentID); src->parent = scd.grandparentID; + CkAssert(src->parent != src->vertexID); // TODO: remove assert } // function to implement simple path compression; currently unused void UnionFindLib:: -compress_path(int arrIdx, long int compressedParent) { +compress_path(int arrIdx, int64_t compressedParent) { unionFindVertex *src = &myVertices[arrIdx]; //message the parent before reseting it if (src->vertexID != compressedParent) {//reached the top of path + + CkPrintf("compress_path gloc\n"); std::pair parent_loc = getLocationFromID(src->parent); this->thisProxy[parent_loc.first].compress_path(parent_loc.second, compressedParent); CProxy_UnionFindLibGroup libGroup(libGroupID); libGroup.ckLocalBranch()->increase_message_count(); src->parent = compressedParent; + CkAssert(src->parent != src->vertexID); // TODO: remove assert } } @@ -433,8 +456,9 @@ find_components(CkCallback cb) { // send local count to prefix library CkCallback doneCb(CkReductionTarget(UnionFindLib, boss_count_prefix_done), thisProxy); - Prefix* myPrefixElem = prefixLibArray[thisIndex].ckLocal(); - myPrefixElem->startPrefixCalculation(myLocalNumBosses, doneCb); + // Prefix* myPrefixElem = prefixLibArray[thisIndex].ckLocal(); + // myPrefixElem->startPrefixCalculation(myLocalNumBosses, doneCb); + prefixLibArray.startPrefixCalculation(myLocalNumBosses, doneCb); //CkPrintf("[%d] Local num bosses: %d\n", thisIndex, myLocalNumBosses); } @@ -444,8 +468,9 @@ boss_count_prefix_done(int totalCount) { totalNumBosses = totalCount; // access value from prefix lib elem to find starting index Prefix* myPrefixElem = prefixLibArray[thisIndex].ckLocal(); - int v = myPrefixElem->getValue(); - int myStartIndex = v - myLocalNumBosses; + int v = 74632; // myPrefixElem->getValue(); // TODO restore this + int myStartIndex = 0; // v - myLocalNumBosses; // J.C. this must not be negative. Let's print this out + CkAssert(myStartIndex >= 0); //CkPrintf("[%d] My start index: %d\n", thisIndex, myStartIndex); // start labeling my local bosses from myStartIndex @@ -485,6 +510,7 @@ start_component_labeling() { if (v->componentNumber == -1) { // an internal node or leaf node, request parent for boss + CkPrintf("start_component_labeling gloc\n"); std::pair parent_loc = getLocationFromID(v->parent); //this->thisProxy[parent_loc.first].need_boss(parent_loc.second, v->vertexID); uint64_t data = ((uint64_t) parent_loc.second) << 32 | ((uint64_t) v->vertexID); @@ -532,6 +558,7 @@ need_boss(int arrIdx, long int fromID) { if (myVertices[arrIdx].componentNumber != -1) { // component already set, reply back + CkPrintf("need_boss gloc\n"); std::pair requestor_loc = getLocationFromID(fromID); if (requestor_loc.first == thisIndex) set_component(requestor_loc.second, myVertices[arrIdx].componentNumber); @@ -552,6 +579,7 @@ set_component(int arrIdx, long int compNum) { std::vector::iterator req_iter = myVertices[arrIdx].need_boss_requests.begin(); while (req_iter != myVertices[arrIdx].need_boss_requests.end()) { long int requestorID = *req_iter; + CkPrintf("set_component gloc\n"); std::pair requestor_loc = getLocationFromID(requestorID); if (requestor_loc.first == thisIndex) set_component(requestor_loc.second, compNum); diff --git a/unionFindLib.h b/unionFindLib.h index 12ccfe3..cdf467e 100644 --- a/unionFindLib.h +++ b/unionFindLib.h @@ -5,8 +5,8 @@ #include struct unionFindVertex { - long int vertexID; - long int parent; + uint64_t vertexID; + int64_t parent; long int componentNumber = -1; std::vector need_boss_requests; //request queue for processing need_boss requests long int findOrAnchorCount = 0; @@ -41,7 +41,7 @@ class UnionFindLib : public CBase_UnionFindLib { int numMyVertices; int pathCompressionThreshold = 5; int componentPruneThreshold; - std::pair (*getLocationFromID)(long int vid); + std::pair (*getLocationFromID)(uint64_t vid); int myLocalNumBosses; int totalNumBosses; CkCallback postComponentLabelingCb; @@ -50,22 +50,22 @@ class UnionFindLib : public CBase_UnionFindLib { UnionFindLib() {} UnionFindLib(CkMigrateMessage *m) { } static CProxy_UnionFindLib unionFindInit(CkArrayID clientArray, int n); + void registerGetLocationFromID(std::pair (*gloc)(uint64_t vid)); void register_phase_one_cb(CkCallback cb); void initialize_vertices(unionFindVertex *appVertices, int numVertices); #ifndef ANCHOR_ALGO - void union_request(long int vid1, long int vid2); - void find_boss1(int arrIdx, long int partnerID, long int senderID); - void find_boss2(int arrIdx, long int boss1ID, long int senderID); + void union_request(uint64_t vid1, uint64_t vid2); + void find_boss1(int arrIdx, uint64_t partnerID, uint64_t senderID); + void find_boss2(int arrIdx, uint64_t boss1ID, uint64_t senderID); #else void union_request(long int v, long int w); void anchor(int w_arrIdx, long int v, long int path_base_arrIdx); #endif - void local_path_compression(unionFindVertex *src, long int compressedParent); - bool check_same_chares(long int v1, long int v2); + void local_path_compression(unionFindVertex *src, uint64_t compressedParent); + bool check_same_chares(uint64_t v1, uint64_t v2); void short_circuit_parent(shortCircuitData scd); - void compress_path(int arrIdx, long int compressedParent); - unionFindVertex* return_vertices(); - void registerGetLocationFromID(std::pair (*gloc)(long int v)); + void compress_path(int arrIdx, int64_t compressedParent); + unionFindVertex *return_vertices(); // functions and data structures for finding connected components From db4c29967a887cb96a01505a73a8284ca0f6faf8 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Tue, 4 Apr 2023 12:03:49 -0700 Subject: [PATCH 02/11] changed vertexID to uint64_t type and updated insertDataNeedBoss to take a struct as a input parameter --- types.h | 10 +++++++++ unionFindLib.C | 58 ++++++++++++++++++++----------------------------- unionFindLib.ci | 10 ++++----- unionFindLib.h | 6 ++--- 4 files changed, 41 insertions(+), 43 deletions(-) diff --git a/types.h b/types.h index 7a926d3..215e695 100644 --- a/types.h +++ b/types.h @@ -12,6 +12,16 @@ struct findBossData { } }; +struct needBossData { + uint64_t arrIdx; + uint64_t senderID; + + void pup(PUP::er &p) { + p|arrIdx; + p|senderID; + } +}; + #ifdef ANCHOR_ALGO struct anchorData { uint64_t arrIdx; diff --git a/unionFindLib.C b/unionFindLib.C index 5d50969..e93573a 100644 --- a/unionFindLib.C +++ b/unionFindLib.C @@ -80,7 +80,6 @@ union_request(uint64_t vid1, uint64_t vid2) { } else { //std::pair vid1_loc = appPtr->getLocationFromID(vid1); - CkPrintf("union_request gloc\n"); std::pair vid1_loc = getLocationFromID(vid1); //message the chare containing first vertex to find boss1 //pass the initilizer ID for initiating path compression @@ -118,7 +117,6 @@ find_boss1(int arrIdx, uint64_t partnerID, uint64_t senderID) { if (src->parent == -1) { //boss1 found - CkPrintf("find_boss1 if gloc\n"); std::pair partner_loc = getLocationFromID(partnerID); //message the chare containing the partner //senderID for first find_boss2 is not relevant, similar to first find_boss1 @@ -139,7 +137,6 @@ find_boss1(int arrIdx, uint64_t partnerID, uint64_t senderID) { } else { //boss1 not found, move to parent - CkPrintf("find_boss1 else gloc\n"); std::pair parent_loc = getLocationFromID(src->parent); unionFindVertex *path_base = src; unionFindVertex *parent, *curr = src; @@ -170,8 +167,6 @@ find_boss1(int arrIdx, uint64_t partnerID, uint64_t senderID) { // move pointers to traverse tree curr = parent; - CkPrintf("find_boss1 else compression gloc\n"); - CkPrintf("thisIndex=%d\n", this->thisIndex); parent_loc = getLocationFromID(curr->parent); } //end of local tree climbing @@ -195,7 +190,6 @@ find_boss1(int arrIdx, uint64_t partnerID, uint64_t senderID) { // check if sender and current vertex are on different chares if (senderID != -1 && !check_same_chares(senderID, curr->vertexID)) { // short circuit the sender to point to grandparent - CkPrintf("find_boss1 else sender and curr diff gloc\n"); std::pair sender_loc = getLocationFromID(senderID); shortCircuitData scd; scd.arrIdx = sender_loc.second; @@ -223,7 +217,6 @@ find_boss2(int arrIdx, uint64_t boss1ID, uint64_t senderID) { else { //valid edge if (boss1ID != src->vertexID) {//avoid self-loop - //J.C: end of recursion, I think src->parent = boss1ID; //message initID to start path compression in boss2's chain /*std::pair init_loc = appPtr->getLocationFromID(initID); @@ -236,7 +229,6 @@ find_boss2(int arrIdx, uint64_t boss1ID, uint64_t senderID) { else { //boss2 not found, move to parent //std::pair parent_loc = appPtr->getLocationFromID(src->parent); - CkPrintf("find_boss2 else gloc\n"); std::pair parent_loc = getLocationFromID(src->parent); unionFindVertex *path_base = src; unionFindVertex *parent, *curr = src; @@ -260,8 +252,6 @@ find_boss2(int arrIdx, uint64_t boss1ID, uint64_t senderID) { } curr = parent; - - CkPrintf("find_boss2 else compression gloc\n"); parent_loc = getLocationFromID(curr->parent); } //end of local tree climbing @@ -286,7 +276,6 @@ find_boss2(int arrIdx, uint64_t boss1ID, uint64_t senderID) { if (senderID != -1 && !check_same_chares(senderID, curr->vertexID)) { // short circuit the sender to point to grandparent - CkPrintf("find_boss2 else sender and curr diff gloc\n"); std::pair sender_loc = getLocationFromID(senderID); shortCircuitData scd; scd.arrIdx = sender_loc.second; @@ -385,10 +374,8 @@ local_path_compression(unionFindVertex *src, uint64_t compressedParent) { // An infinite loop if this function is called on itself (a node which does not have itself as its parent) while (src->parent != compressedParent) { // CkPrintf("Stuck here\n"); - CkPrintf("local_path_compression gloc\n"); tmp = &myVertices[getLocationFromID(src->parent).second]; src->parent = compressedParent; - CkAssert(src->parent != src->vertexID); // TODO: remove assert src =tmp; } } @@ -396,9 +383,7 @@ local_path_compression(unionFindVertex *src, uint64_t compressedParent) { // check if two vertices are on same chare bool UnionFindLib:: check_same_chares(uint64_t v1, uint64_t v2) { - CkPrintf("check_same_chares v1 gloc\n"); std::pair v1_loc = getLocationFromID(v1); - CkPrintf("check_same_chares v2 gloc\n"); std::pair v2_loc = getLocationFromID(v2); if (v1_loc.first == v2_loc.first) return true; @@ -420,14 +405,11 @@ compress_path(int arrIdx, int64_t compressedParent) { unionFindVertex *src = &myVertices[arrIdx]; //message the parent before reseting it if (src->vertexID != compressedParent) {//reached the top of path - - CkPrintf("compress_path gloc\n"); std::pair parent_loc = getLocationFromID(src->parent); this->thisProxy[parent_loc.first].compress_path(parent_loc.second, compressedParent); CProxy_UnionFindLibGroup libGroup(libGroupID); libGroup.ckLocalBranch()->increase_message_count(); src->parent = compressedParent; - CkAssert(src->parent != src->vertexID); // TODO: remove assert } } @@ -456,9 +438,10 @@ find_components(CkCallback cb) { // send local count to prefix library CkCallback doneCb(CkReductionTarget(UnionFindLib, boss_count_prefix_done), thisProxy); + // TODO: verify why these two lines (old code) did not work, or why they were here // Prefix* myPrefixElem = prefixLibArray[thisIndex].ckLocal(); // myPrefixElem->startPrefixCalculation(myLocalNumBosses, doneCb); - prefixLibArray.startPrefixCalculation(myLocalNumBosses, doneCb); + prefixLibArray[thisIndex].startPrefixCalculation(myLocalNumBosses, doneCb); //CkPrintf("[%d] Local num bosses: %d\n", thisIndex, myLocalNumBosses); } @@ -468,10 +451,9 @@ boss_count_prefix_done(int totalCount) { totalNumBosses = totalCount; // access value from prefix lib elem to find starting index Prefix* myPrefixElem = prefixLibArray[thisIndex].ckLocal(); - int v = 74632; // myPrefixElem->getValue(); // TODO restore this - int myStartIndex = 0; // v - myLocalNumBosses; // J.C. this must not be negative. Let's print this out + int v = myPrefixElem->getValue(); + int myStartIndex = v - myLocalNumBosses; CkAssert(myStartIndex >= 0); - //CkPrintf("[%d] My start index: %d\n", thisIndex, myStartIndex); // start labeling my local bosses from myStartIndex // ensures sequential numbering of components @@ -510,10 +492,12 @@ start_component_labeling() { if (v->componentNumber == -1) { // an internal node or leaf node, request parent for boss - CkPrintf("start_component_labeling gloc\n"); std::pair parent_loc = getLocationFromID(v->parent); //this->thisProxy[parent_loc.first].need_boss(parent_loc.second, v->vertexID); - uint64_t data = ((uint64_t) parent_loc.second) << 32 | ((uint64_t) v->vertexID); + // uint64_t data = ((uint64_t) parent_loc.second) << 32 | ((uint64_t) v->vertexID); + needBossData data; + data.arrIdx = parent_loc.second; + data.senderID = v->vertexID; this->thisProxy[parent_loc.first].insertDataNeedBoss(data); } } @@ -538,9 +522,13 @@ insertDataFindBoss(const findBossData & data) { } void UnionFindLib:: -insertDataNeedBoss(const uint64_t & data) { +insertDataNeedBoss(const needBossData & data) { + /* int arrIdx = (int)(data >> 32); - long int fromID = (long int)(data & 0xffffffff); + long int fromID = (long int)(data & 0xffffffff); // TODO: not enough bits to store vertexID (use struct w. arrIdx and fromID) + this->need_boss(arrIdx, fromID);*/ + int arrIdx = data.arrIdx; + uint64_t fromID = data.senderID; this->need_boss(arrIdx, fromID); } @@ -552,18 +540,18 @@ insertDataAnchor(const anchorData & data) { #endif void UnionFindLib:: -need_boss(int arrIdx, long int fromID) { +need_boss(int arrIdx, uint64_t fromID) { // one of children of this node needs boss, handle by either replying immediately // or queueing the request if (myVertices[arrIdx].componentNumber != -1) { // component already set, reply back - CkPrintf("need_boss gloc\n"); std::pair requestor_loc = getLocationFromID(fromID); - if (requestor_loc.first == thisIndex) + if (requestor_loc.first == thisIndex) { set_component(requestor_loc.second, myVertices[arrIdx].componentNumber); - else + } else { this->thisProxy[requestor_loc.first].set_component(requestor_loc.second, myVertices[arrIdx].componentNumber); + } } else { // boss still not found, queue the request @@ -576,15 +564,15 @@ set_component(int arrIdx, long int compNum) { myVertices[arrIdx].componentNumber = compNum; // since component number is set, respond to your requestors - std::vector::iterator req_iter = myVertices[arrIdx].need_boss_requests.begin(); + std::vector::iterator req_iter = myVertices[arrIdx].need_boss_requests.begin(); while (req_iter != myVertices[arrIdx].need_boss_requests.end()) { - long int requestorID = *req_iter; - CkPrintf("set_component gloc\n"); + uint64_t requestorID = *req_iter; std::pair requestor_loc = getLocationFromID(requestorID); - if (requestor_loc.first == thisIndex) + if (requestor_loc.first == thisIndex) { set_component(requestor_loc.second, compNum); - else + } else { this->thisProxy[requestor_loc.first].set_component(requestor_loc.second, compNum); + } // done with current requestor, delete from request queue req_iter = myVertices[arrIdx].need_boss_requests.erase(req_iter); } diff --git a/unionFindLib.ci b/unionFindLib.ci index 80a76c0..f590293 100644 --- a/unionFindLib.ci +++ b/unionFindLib.ci @@ -15,8 +15,8 @@ module unionFindLib { entry void register_phase_one_cb(CkCallback cb); // functions to build inverted trees #ifndef ANCHOR_ALGO - entry void find_boss1(int arrIdx, long partnerID, long initID); - entry void find_boss2(int arrIdx, long boss1ID, long initID); + entry void find_boss1(int arrIdx, uint64_t partnerID, uint64_t initID); + entry void find_boss2(int arrIdx, uint64_t boss1ID, uint64_t initID); #else entry void anchor(int w_arrIdx, long v, long path_base_arrIdx); #endif @@ -24,12 +24,12 @@ module unionFindLib { entry [aggregate] void short_circuit_parent(shortCircuitData scd); // function for path compression support - entry void compress_path(int arrIdx, long compressedParent); + entry void compress_path(int arrIdx, int64_t compressedParent); // functions to perform distributed connected components entry void find_components(CkCallback cb); entry [reductiontarget] void boss_count_prefix_done(int totalCount); - entry void need_boss(int arrIdx, int fromID); + entry void need_boss(int arrIdx, uint64_t fromID); entry void set_component(int arrIdx, int compNum); // functions to prune out small components @@ -40,7 +40,7 @@ module unionFindLib { // TRAM functions entry [aggregate] void insertDataFindBoss(const findBossData & data); - entry [aggregate] void insertDataNeedBoss(const uint64_t & data); + entry [aggregate] void insertDataNeedBoss(const needBossData & data); #ifdef ANCHOR_ALGO entry [aggregate] void insertDataAnchor(const anchorData & data); #endif diff --git a/unionFindLib.h b/unionFindLib.h index cdf467e..ee6cea9 100644 --- a/unionFindLib.h +++ b/unionFindLib.h @@ -8,7 +8,7 @@ struct unionFindVertex { uint64_t vertexID; int64_t parent; long int componentNumber = -1; - std::vector need_boss_requests; //request queue for processing need_boss requests + std::vector need_boss_requests; //request queue for processing need_boss requests long int findOrAnchorCount = 0; void pup(PUP::er &p) { @@ -73,12 +73,12 @@ class UnionFindLib : public CBase_UnionFindLib { void find_components(CkCallback cb); void boss_count_prefix_done(int totalCount); void start_component_labeling(); - void insertDataNeedBoss(const uint64_t & data); + void insertDataNeedBoss(const needBossData & data); void insertDataFindBoss(const findBossData & data); #ifdef ANCHOR_ALGO void insertDataAnchor(const anchorData & data); #endif - void need_boss(int arrIdx, long int fromID); + void need_boss(int arrIdx, uint64_t fromID); void set_component(int arrIdx, long int compNum); void prune_components(int threshold, CkCallback appReturnCb); void perform_pruning(); From a4b4a6a81f0234a8da8c31e2d0e39b331b575c3b Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Thu, 6 Apr 2023 10:57:49 -0700 Subject: [PATCH 03/11] optimized need_boss queue processing by removing elements from end of vector instead of beginning --- unionFindLib.C | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/unionFindLib.C b/unionFindLib.C index e93573a..0821659 100644 --- a/unionFindLib.C +++ b/unionFindLib.C @@ -564,9 +564,9 @@ set_component(int arrIdx, long int compNum) { myVertices[arrIdx].componentNumber = compNum; // since component number is set, respond to your requestors - std::vector::iterator req_iter = myVertices[arrIdx].need_boss_requests.begin(); - while (req_iter != myVertices[arrIdx].need_boss_requests.end()) { - uint64_t requestorID = *req_iter; + std::vector need_boss_queue = myVertices[arrIdx].need_boss_requests; + while (!need_boss_queue.empty()) { + uint64_t requestorID = (need_boss_queue).back(); std::pair requestor_loc = getLocationFromID(requestorID); if (requestor_loc.first == thisIndex) { set_component(requestor_loc.second, compNum); @@ -574,7 +574,7 @@ set_component(int arrIdx, long int compNum) { this->thisProxy[requestor_loc.first].set_component(requestor_loc.second, compNum); } // done with current requestor, delete from request queue - req_iter = myVertices[arrIdx].need_boss_requests.erase(req_iter); + need_boss_queue.pop_back(); } } From dfd27ecfa729b0b8c38b9ed9da3171a7179e6622 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Mon, 10 Apr 2023 15:31:49 -0700 Subject: [PATCH 04/11] Added comments to document key unionfind API functions and updated anchor algo to use uint64_t as vertexID type --- unionFindLib.C | 91 +++++++++++++++++++++++++++++++++++++------------ unionFindLib.ci | 4 +-- unionFindLib.h | 6 ++-- 3 files changed, 75 insertions(+), 26 deletions(-) diff --git a/unionFindLib.C b/unionFindLib.C index 0821659..f49046d 100644 --- a/unionFindLib.C +++ b/unionFindLib.C @@ -45,6 +45,19 @@ static void register_merge_count_maps_reduction() { // class function implementations +/** + * @brief registers a function that takes a vertexID and returns its location + * + * unionFindLib allows users to specify a vertexID scheme that suits their + * usecase, as long as it encodes the chare index of the vertex and array index + * of the vertex on the chare's myVertices field. This function registers the + * function provided by the user that achieves this decoding, so that the user's + * function may be used by unionFindLib for internal functionality + * + * @param gloc a function that takes a uint64_t vertexID and returns its chare + * index and local array index on that chare's myVertices field as + * a std::pair + */ void UnionFindLib:: registerGetLocationFromID(std::pair (*gloc)(uint64_t vid)) { getLocationFromID = gloc; @@ -58,36 +71,51 @@ register_phase_one_cb(CkCallback cb) { CkStartQD(cb); } +/** + * @brief Adds vertices to this union find chare + * + * Takes an array of unionFindVertex with vertex info populated (ID, etc.) + * and the length of that array, and stores locally the vertex info + * that should be associated with this union find chare. + * + * @param appVertices an array of unionFindVertex storing the vertices on the + * corresponding partition chare + * @param numVertices the number of vertices in the appVertices array + */ void UnionFindLib:: initialize_vertices(unionFindVertex *appVertices, int numVertices) { // local vertices corresponding to one treepiece in application numMyVertices = numVertices; - myVertices = appVertices; // no need to do memcpy, array in same address space as app - /*myVertices = (unionFindVertex*)malloc(numVertices * sizeof(unionFindVertex)); - memcpy(myVertices, appVertices, sizeof(unionFindVertex)*numVertices);*/ - /*for (int i = 0; i < numMyVertices; i++) { - CkPrintf("[LibProxy %d] myVertices[%d] - vertexID: %ld, parent: %ld, component: %d\n", this->thisIndex, i, myVertices[i].vertexID, myVertices[i].parent, myVertices[i].componentNumber); - }*/ + myVertices = appVertices; } +/** + * @brief performs a union on two vertices given their vertexIDs + * + * assumes the vertexIDs encode the information about the location of the vertex + * (it's chare index in the union find lib proxy and the local array index + * of the vertex). performs the actual union operation and carries + * it's associated runtime cost (cost depends on implementation selected) + */ #ifndef ANCHOR_ALGO void UnionFindLib:: union_request(uint64_t vid1, uint64_t vid2) { + CkPrintf("[unionfind] union_request on %llu, %llu\n", v, w); assert(vid1!=vid2); if (vid2 < vid1) { // found a back edge, flip and reprocess union_request(vid2, vid1); } else { - //std::pair vid1_loc = appPtr->getLocationFromID(vid1); std::pair vid1_loc = getLocationFromID(vid1); + //message the chare containing first vertex to find boss1 //pass the initilizer ID for initiating path compression findBossData d; d.arrIdx = vid1_loc.second; d.partnerOrBossID = vid2; - d.senderID = -1; // TODO: Is this okay? Or use INT_MIN + d.senderID = -1; d.isFBOne = 1; this->thisProxy[vid1_loc.first].insertDataFindBoss(d); @@ -98,7 +126,8 @@ union_request(uint64_t vid1, uint64_t vid2) { } #else void UnionFindLib:: -union_request(long int v, long int w) { +union_request(uint64_t v, uint64_t w) { + CkPrintf("[unionfind] union_request on %llu, %llu\n", v, w); std::pair w_loc = getLocationFromID(w); // message w to anchor to v anchorData d; @@ -289,7 +318,7 @@ find_boss2(int arrIdx, uint64_t boss1ID, uint64_t senderID) { } #else void UnionFindLib:: -anchor(int w_arrIdx, long int v, long int path_base_arrIdx) { +anchor(int w_arrIdx, uint64_t v, long int path_base_arrIdx) { unionFindVertex *w = &myVertices[w_arrIdx]; w->findOrAnchorCount++; @@ -401,7 +430,7 @@ short_circuit_parent(shortCircuitData scd) { // function to implement simple path compression; currently unused void UnionFindLib:: -compress_path(int arrIdx, int64_t compressedParent) { +compress_path(int arrIdx, uint64_t compressedParent) { unionFindVertex *src = &myVertices[arrIdx]; //message the parent before reseting it if (src->vertexID != compressedParent) {//reached the top of path @@ -420,6 +449,13 @@ return_vertices() { /** Functions for finding connected components **/ +/** + * @brief After performing all union_request calls, labels connected components + * across all union find chares with coherent indexing starting with index 0 for + * component 0 + * + * @param cb Callback to be invoked after this function has finished + */ void UnionFindLib:: find_components(CkCallback cb) { postComponentLabelingCb = cb; @@ -438,9 +474,6 @@ find_components(CkCallback cb) { // send local count to prefix library CkCallback doneCb(CkReductionTarget(UnionFindLib, boss_count_prefix_done), thisProxy); - // TODO: verify why these two lines (old code) did not work, or why they were here - // Prefix* myPrefixElem = prefixLibArray[thisIndex].ckLocal(); - // myPrefixElem->startPrefixCalculation(myLocalNumBosses, doneCb); prefixLibArray[thisIndex].startPrefixCalculation(myLocalNumBosses, doneCb); //CkPrintf("[%d] Local num bosses: %d\n", thisIndex, myLocalNumBosses); } @@ -523,10 +556,6 @@ insertDataFindBoss(const findBossData & data) { void UnionFindLib:: insertDataNeedBoss(const needBossData & data) { - /* - int arrIdx = (int)(data >> 32); - long int fromID = (long int)(data & 0xffffffff); // TODO: not enough bits to store vertexID (use struct w. arrIdx and fromID) - this->need_boss(arrIdx, fromID);*/ int arrIdx = data.arrIdx; uint64_t fromID = data.senderID; this->need_boss(arrIdx, fromID); @@ -541,8 +570,8 @@ insertDataAnchor(const anchorData & data) { void UnionFindLib:: need_boss(int arrIdx, uint64_t fromID) { - // one of children of this node needs boss, handle by either replying immediately - // or queueing the request + // one of children of this node needs boss, handle by either + // replying immediately or queueing the request if (myVertices[arrIdx].componentNumber != -1) { // component already set, reply back @@ -578,6 +607,14 @@ set_component(int arrIdx, long int compNum) { } } +/** + * @brief discards components with number of vertices less than or equal to the + * threshold given and labels them with component number -1 + * + * @param threshold the minimum number of vertices for a component must be + * strictly greater than this number + * @param appReturnCb Callback to be invoked upon completion + */ void UnionFindLib:: prune_components(int threshold, CkCallback appReturnCb) { componentPruneThreshold = threshold; @@ -690,7 +727,19 @@ done_profiling(int total_count) { } } -// library initialization function +/** + * @brief initializes unionFindLib and returns a union find lib proxy + * + * Takes a chare array where vertices are stored and creates a union find chare + * array that is a shadow array of it. Intended so that when accessing vertices + * on the application level, one can easily make a invoke a local function + * on the corresponding union find chare using CkLocal() + * + * @param clientArray chare array that union find proxy will become shadow array + * of + * @param n number of chares in the clientArray + * @return CProxy_UnionFindLib the chare array union find proxy + */ CProxy_UnionFindLib UnionFindLib:: unionFindInit(CkArrayID clientArray, int n) { CkArrayOptions opts(n); diff --git a/unionFindLib.ci b/unionFindLib.ci index f590293..29ba9f9 100644 --- a/unionFindLib.ci +++ b/unionFindLib.ci @@ -18,13 +18,13 @@ module unionFindLib { entry void find_boss1(int arrIdx, uint64_t partnerID, uint64_t initID); entry void find_boss2(int arrIdx, uint64_t boss1ID, uint64_t initID); #else - entry void anchor(int w_arrIdx, long v, long path_base_arrIdx); + entry void anchor(int w_arrIdx, uint64_t v, long path_base_arrIdx); #endif // function for grandparent short-circuiting entry [aggregate] void short_circuit_parent(shortCircuitData scd); // function for path compression support - entry void compress_path(int arrIdx, int64_t compressedParent); + entry void compress_path(int arrIdx, uint64_t compressedParent); // functions to perform distributed connected components entry void find_components(CkCallback cb); diff --git a/unionFindLib.h b/unionFindLib.h index ee6cea9..00e7b1d 100644 --- a/unionFindLib.h +++ b/unionFindLib.h @@ -58,13 +58,13 @@ class UnionFindLib : public CBase_UnionFindLib { void find_boss1(int arrIdx, uint64_t partnerID, uint64_t senderID); void find_boss2(int arrIdx, uint64_t boss1ID, uint64_t senderID); #else - void union_request(long int v, long int w); - void anchor(int w_arrIdx, long int v, long int path_base_arrIdx); + void union_request(uint64_t v, uint64_t w); + void anchor(int w_arrIdx, uint64_t v, long int path_base_arrIdx); #endif void local_path_compression(unionFindVertex *src, uint64_t compressedParent); bool check_same_chares(uint64_t v1, uint64_t v2); void short_circuit_parent(shortCircuitData scd); - void compress_path(int arrIdx, int64_t compressedParent); + void compress_path(int arrIdx, uint64_t compressedParent); unionFindVertex *return_vertices(); // functions and data structures for finding connected components From 4495b947f07b6da2b09a3e76a03a007e263f95e0 Mon Sep 17 00:00:00 2001 From: Johnny Chen Date: Mon, 10 Apr 2023 16:52:57 -0700 Subject: [PATCH 05/11] removed debugging printf's --- Makefile.common | 5 ++--- unionFindLib.C | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Makefile.common b/Makefile.common index af08f00..9f86ef7 100644 --- a/Makefile.common +++ b/Makefile.common @@ -8,13 +8,12 @@ ANCHOR= -DANCHOR_ALGO #ANCHOR= PROFILE= -DPROFILING CHARMC = $(CHARM_DIR)/bin/charmc $(PROFILE) #$(ANCHOR) -OPTS = -std=c++11 -O0 -g #was -03 +OPTS = -std=c++11 -O3 -g LD_OPTS = -# CK_TEMPLATES = -DCK_TEMPLATES_ONLY #options for building union-find library and prefix library PREFIX_LIBS = -L${PREFIX_LIB_DIR} -lprefix -PREFIX_INC = -I${PREFIX_LIB_DIR} # ${CK_TEMPLATES} +PREFIX_INC = -I${PREFIX_LIB_DIR} UNION_FIND_LIBS = -L${UNION_FIND_DIR} -lunionFind ${PREFIX_LIBS} UNION_FIND_INC = -I${UNION_FIND_DIR} ${PREFIX_INC} diff --git a/unionFindLib.C b/unionFindLib.C index f49046d..fcfe32a 100644 --- a/unionFindLib.C +++ b/unionFindLib.C @@ -100,7 +100,6 @@ initialize_vertices(unionFindVertex *appVertices, int numVertices) { #ifndef ANCHOR_ALGO void UnionFindLib:: union_request(uint64_t vid1, uint64_t vid2) { - CkPrintf("[unionfind] union_request on %llu, %llu\n", v, w); assert(vid1!=vid2); if (vid2 < vid1) { // found a back edge, flip and reprocess @@ -127,7 +126,6 @@ union_request(uint64_t vid1, uint64_t vid2) { #else void UnionFindLib:: union_request(uint64_t v, uint64_t w) { - CkPrintf("[unionfind] union_request on %llu, %llu\n", v, w); std::pair w_loc = getLocationFromID(w); // message w to anchor to v anchorData d; From b40ced087092ab36b4d58de45162d88a7394a9ec Mon Sep 17 00:00:00 2001 From: adrianplenefisch Date: Fri, 25 Aug 2023 12:15:00 -0700 Subject: [PATCH 06/11] PrefixLib make now uses Makefile.common --- prefixLib/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prefixLib/Makefile b/prefixLib/Makefile index 0351d03..0eb943d 100644 --- a/prefixLib/Makefile +++ b/prefixLib/Makefile @@ -1,4 +1,4 @@ -CHARMC=/Users/raghu/work/charm/charm/bin/charmc $(OPTS) +include ../Makefile.common all: libprefix.a From 18037db3f0953fef5ad1d1aec508630776a67970 Mon Sep 17 00:00:00 2001 From: adrianplenefisch Date: Thu, 7 Dec 2023 14:21:08 -0800 Subject: [PATCH 07/11] added broadcasts of global variables to allow multiple PE --- Makefile.common | 4 ++-- unionFindLib.C | 14 +++++++++++++- unionFindLib.ci | 12 +++++++++--- unionFindLib.h | 5 ++++- 4 files changed, 28 insertions(+), 7 deletions(-) diff --git a/Makefile.common b/Makefile.common index 9f86ef7..34abf46 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1,6 +1,6 @@ #set the following variables to absolute paths -CHARM_DIR = /Users/johnnychen/Documents/Projects/research/charm -UNION_FIND_DIR = /Users/johnnychen/Documents/Projects/research/unionfind +CHARM_DIR = $(HOME)/Documents/nbodydir/charm +UNION_FIND_DIR = $(HOME)/Documents/nbodydir/unionfind PREFIX_LIB_DIR = $(UNION_FIND_DIR)/prefixLib #charmc options diff --git a/unionFindLib.C b/unionFindLib.C index fcfe32a..f12c1e2 100644 --- a/unionFindLib.C +++ b/unionFindLib.C @@ -153,6 +153,7 @@ find_boss1(int arrIdx, uint64_t partnerID, uint64_t senderID) { d.partnerOrBossID = src->vertexID; d.senderID = -1; d.isFBOne = 0; + //CkPrintf("partner_loc.first is %d and partnerID is %lu and arrIdx is %d\n", partner_loc.first,partnerID,arrIdx); this->thisProxy[partner_loc.first].insertDataFindBoss(d); CProxy_UnionFindLibGroup libGroup(libGroupID); @@ -695,7 +696,8 @@ profiling_count_max(long int maxCount) { // library group chare class definitions void UnionFindLibGroup:: build_component_count_array(int *totalCounts, int numElems) { - //CkPrintf("[PE %d] Count array size: %d\n", thisIndex, numElems); + + CkPrintf("[PE %d] Count array size: %d\n", thisIndex, numElems); component_count_array = new int[numElems]; memcpy(component_count_array, totalCounts, sizeof(int)*numElems); contribute(CkCallback(CkReductionTarget(UnionFindLib, perform_pruning), _UfLibProxy)); @@ -751,9 +753,19 @@ unionFindInit(CkArrayID clientArray, int n) { prefixLibArray = CProxy_Prefix::ckNew(n, prefix_opts); libGroupID = CProxy_UnionFindLibGroup::ckNew(); + + _UfLibProxy.passLibGroupID(libGroupID, prefixLibArray); + return _UfLibProxy; } +void UnionFindLib::passLibGroupID(CkGroupID lgid, CProxy_Prefix pla) +{ + prefixLibArray = pla; + libGroupID = lgid; + _UfLibProxy = this->thisProxy; +} + #include "unionFindLib.def.h" diff --git a/unionFindLib.ci b/unionFindLib.ci index 29ba9f9..eb47027 100644 --- a/unionFindLib.ci +++ b/unionFindLib.ci @@ -11,6 +11,11 @@ module unionFindLib { array[1D] UnionFindLib { entry UnionFindLib(); + + + entry void passLibGroupID(CkGroupID lgid, CProxy_Prefix pla); + + // function to register Phase 1 callback entry void register_phase_one_cb(CkCallback cb); // functions to build inverted trees @@ -39,10 +44,10 @@ module unionFindLib { //entry [reductiontarget] void merge_count_results(int totalCounts[numElems], int numElems); // TRAM functions - entry [aggregate] void insertDataFindBoss(const findBossData & data); - entry [aggregate] void insertDataNeedBoss(const needBossData & data); + entry void insertDataFindBoss(const findBossData & data); + entry void insertDataNeedBoss(const needBossData & data); #ifdef ANCHOR_ALGO - entry [aggregate] void insertDataAnchor(const anchorData & data); + entry void insertDataAnchor(const anchorData & data); #endif #ifdef PROFILING entry [reductiontarget] void profiling_count_max(long maxCount); @@ -55,5 +60,6 @@ module unionFindLib { entry [reductiontarget] void build_component_count_array(int totalCounts[numElems], int numElems); entry [reductiontarget] void done_profiling(int result); entry void contribute_count(); + } }; diff --git a/unionFindLib.h b/unionFindLib.h index 00e7b1d..bb53be7 100644 --- a/unionFindLib.h +++ b/unionFindLib.h @@ -47,8 +47,11 @@ class UnionFindLib : public CBase_UnionFindLib { CkCallback postComponentLabelingCb; public: - UnionFindLib() {} + UnionFindLib() { + CkPrintf("Creating element %d on %d\n",thisIndex,CkMyPe()); + } UnionFindLib(CkMigrateMessage *m) { } + void passLibGroupID(CkGroupID lgid, CProxy_Prefix pla); static CProxy_UnionFindLib unionFindInit(CkArrayID clientArray, int n); void registerGetLocationFromID(std::pair (*gloc)(uint64_t vid)); void register_phase_one_cb(CkCallback cb); From bcfec0828218f7a3ecb42ff9b6af80b5204ea297 Mon Sep 17 00:00:00 2001 From: adrianplenefisch Date: Wed, 13 Dec 2023 15:10:05 -0800 Subject: [PATCH 08/11] removed unnecessary print statement --- unionFindLib.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/unionFindLib.h b/unionFindLib.h index bb53be7..de5bf00 100644 --- a/unionFindLib.h +++ b/unionFindLib.h @@ -47,9 +47,7 @@ class UnionFindLib : public CBase_UnionFindLib { CkCallback postComponentLabelingCb; public: - UnionFindLib() { - CkPrintf("Creating element %d on %d\n",thisIndex,CkMyPe()); - } + UnionFindLib() {} UnionFindLib(CkMigrateMessage *m) { } void passLibGroupID(CkGroupID lgid, CProxy_Prefix pla); static CProxy_UnionFindLib unionFindInit(CkArrayID clientArray, int n); From 4b49675bbd87bd12fbebaa4d366df688e4d0cc21 Mon Sep 17 00:00:00 2001 From: adrianplenefisch Date: Thu, 14 Dec 2023 15:42:43 -0800 Subject: [PATCH 09/11] removed another unnecessary bugfixing line --- unionFindLib.C | 1 - 1 file changed, 1 deletion(-) diff --git a/unionFindLib.C b/unionFindLib.C index f12c1e2..0f4e4be 100644 --- a/unionFindLib.C +++ b/unionFindLib.C @@ -153,7 +153,6 @@ find_boss1(int arrIdx, uint64_t partnerID, uint64_t senderID) { d.partnerOrBossID = src->vertexID; d.senderID = -1; d.isFBOne = 0; - //CkPrintf("partner_loc.first is %d and partnerID is %lu and arrIdx is %d\n", partner_loc.first,partnerID,arrIdx); this->thisProxy[partner_loc.first].insertDataFindBoss(d); CProxy_UnionFindLibGroup libGroup(libGroupID); From 0a776aafbb1244990fce90b22b238723bc4edc00 Mon Sep 17 00:00:00 2001 From: adrianplenefisch Date: Thu, 14 Dec 2023 15:47:59 -0800 Subject: [PATCH 10/11] commmented out debuging print statement --- unionFindLib.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unionFindLib.C b/unionFindLib.C index 0f4e4be..39f7a47 100644 --- a/unionFindLib.C +++ b/unionFindLib.C @@ -696,7 +696,7 @@ profiling_count_max(long int maxCount) { void UnionFindLibGroup:: build_component_count_array(int *totalCounts, int numElems) { - CkPrintf("[PE %d] Count array size: %d\n", thisIndex, numElems); + //CkPrintf("[PE %d] Count array size: %d\n", thisIndex, numElems); component_count_array = new int[numElems]; memcpy(component_count_array, totalCounts, sizeof(int)*numElems); contribute(CkCallback(CkReductionTarget(UnionFindLib, perform_pruning), _UfLibProxy)); From 1ea367360b93ee277bc708d766d2538678eb302b Mon Sep 17 00:00:00 2001 From: adrianplenefisch Date: Wed, 7 Feb 2024 13:14:11 -0800 Subject: [PATCH 11/11] made union_request check if sending a message is necessary --- unionFindLib.C | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/unionFindLib.C b/unionFindLib.C index 39f7a47..3e6acc9 100644 --- a/unionFindLib.C +++ b/unionFindLib.C @@ -116,7 +116,15 @@ union_request(uint64_t vid1, uint64_t vid2) { d.partnerOrBossID = vid2; d.senderID = -1; d.isFBOne = 1; - this->thisProxy[vid1_loc.first].insertDataFindBoss(d); + if(vid1_loc.first == this->thisIndex) + { + this->insertDataFindBoss(d); + } + else + { + this->thisProxy[vid1_loc.first].insertDataFindBoss(d); + } + //for profiling CProxy_UnionFindLibGroup libGroup(libGroupID); @@ -153,7 +161,15 @@ find_boss1(int arrIdx, uint64_t partnerID, uint64_t senderID) { d.partnerOrBossID = src->vertexID; d.senderID = -1; d.isFBOne = 0; - this->thisProxy[partner_loc.first].insertDataFindBoss(d); + if(partner_loc.first == this->thisIndex) + { + insertDataFindBoss(d); + } + else + { + this->thisProxy[partner_loc.first].insertDataFindBoss(d); + } + CProxy_UnionFindLibGroup libGroup(libGroupID); libGroup.ckLocalBranch()->increase_message_count();