From 49a59a652bf9492fd1f44d4ecebb1a7af47bbac2 Mon Sep 17 00:00:00 2001 From: Sepideh Maleki Date: Mon, 22 Feb 2021 16:07:54 -0600 Subject: [PATCH] imbalance --- lonestar/analytics/cpu/bipart/Refine.cpp | 48 +----------------------- lonestar/analytics/cpu/bipart/bipart.cpp | 30 ++++++++------- lonestar/analytics/cpu/bipart/bipart.h | 2 +- 3 files changed, 19 insertions(+), 61 deletions(-) diff --git a/lonestar/analytics/cpu/bipart/Refine.cpp b/lonestar/analytics/cpu/bipart/Refine.cpp index 9c36f91ec0..5286c7cbc7 100644 --- a/lonestar/analytics/cpu/bipart/Refine.cpp +++ b/lonestar/analytics/cpu/bipart/Refine.cpp @@ -28,50 +28,6 @@ namespace { -// This is only used on the terminal graph (find graph) -// Should workd for hmetis - -/*int calculate_cutsize(GGraph& g) { - - GNodeBag bag; - galois::do_all(galois::iterate(g.getNets()), - [&](GNode n) { - auto c = g.edges(n).begin(); - GNode cn = g.getEdgeDst(*c); - int part = g.getData(cn).getPart(); - for (auto x : g.edges(n)) { - auto cc = g.getEdgeDst(x); - int partc = g.getData(cc).getPart(); - if (partc != part) { - bag.push(n); - return; - } - } - }, - galois::loopname("cutsize")); - return std::distance(bag.begin(), bag.end()); -}*/ - -/*int calculate_cutsize(GGraph& g, std::map part) { - - GNodeBag bag; - galois::do_all(galois::iterate(g.getNets()), - [&](GNode n) { - auto c = g.edges(n).begin(); - GNode cn = g.getEdgeDst(*c); - unsigned ppart = part[cn]; - for (auto x : g.edges(n, galois::MethodFlag::UNPROTECTED)) { - auto cc = g.getEdgeDst(x); - unsigned partc = part[cc]; - if (partc != ppart) { - bag.push(n); - return; - } - } - }, - galois::steal(), galois::loopname("cutsize")); - return std::distance(bag.begin(), bag.end()); -}*/ void projectPart(MetisGraph* Graph) { GGraph* fineGraph = Graph->getFinerGraph()->getGraph(); GGraph* coarseGraph = Graph->getGraph(); @@ -578,12 +534,12 @@ bool isPT(int n) { return (ceil(log2(n)) == floor(log2(n))); } -void refine(MetisGraph* coarseGraph, unsigned K) { +void refine(MetisGraph* coarseGraph, unsigned K, double imbalance) { float ratio = 0.0f; float tol = 0.0f; bool flag = isPT(K); if (flag) { - ratio = 55.0 / 45.0; // change if needed + ratio = (50.0f + (double) imbalance)/(50.0f - (double) imbalance); tol = std::max(ratio, 1 - ratio) - 1; } else { ratio = ((float)((K + 1) / 2)) / ((float)(K / 2)); // change if needed diff --git a/lonestar/analytics/cpu/bipart/bipart.cpp b/lonestar/analytics/cpu/bipart/bipart.cpp index fc475a707b..27761209ea 100644 --- a/lonestar/analytics/cpu/bipart/bipart.cpp +++ b/lonestar/analytics/cpu/bipart/bipart.cpp @@ -54,7 +54,7 @@ static cll::opt schedulingMode( clEnumVal(MDEG, "MDEG"), clEnumVal(DEG, "DEG"), clEnumVal(MWD, "MWD"), clEnumVal(HIS, "HIS"), clEnumVal(RAND, "random")), - cll::init(PLD)); + cll::init(RAND)); static cll::opt mtxInput("mtxinput", @@ -84,8 +84,8 @@ static cll::opt numPartitions(cll::Positional, cll::init(2)); static cll::opt imbalance( "balance", - cll::desc("Fraction deviated from mean partition size (default 0.01)"), - cll::init(0.01)); + cll::desc("Percentage deviated from mean partition size (default 5)"), + cll::init(5.0)); //! Flag that forces user to be aware that they should be passing in a //! hMetis graph. @@ -119,7 +119,7 @@ void Partition(MetisGraph* metisGraph, unsigned coarsenTo, unsigned K) { galois::StatTimer T3("Refine"); T3.start(); - refine(mcg, K); + refine(mcg, K, imbalance); T3.stop(); Ctime += (T.get()/1000.0f); Ptime += (T2.get()/1000.0f); @@ -148,15 +148,17 @@ int computingCut(GGraph& g) { } int computingBalance(GGraph& g) { - int zero = 0, one = 0; + int max = 0; + std::vector parts(numPartitions, 0); for (size_t c = g.hedges; c < g.size(); c++) { - int part = g.getData(c).getPart(); - if (part == 0) - zero++; - else - one++; + unsigned pp = g.getData(c).getPart(); + parts[pp]++; } - return std::abs(zero - one); + for (unsigned i = 0; i max) + max = parts[i]; + } + return max; } // printGraphBeg(*graph) @@ -330,7 +332,7 @@ int main(int argc, char** argv) { std::vector> nodesvec(k); // std::array, 100> hedgesvec; - for (int level = 1; level < num; level++) { + for (int level = 0; level < num; level++) { for (int i = 0; i < k; i++) nodesvec[i].clear(); @@ -493,8 +495,8 @@ int main(int argc, char** argv) { std::cout<<"Edge Cut,"<