From 5bc4f2a08088fd1982010e041252213da87cd6c7 Mon Sep 17 00:00:00 2001 From: StefanoPetrilli Date: Mon, 30 May 2022 14:27:26 -0500 Subject: [PATCH] PROCESS MATCHED VERTICES parallelization improvement --- ...mEdgesLinearSearchMesgBndlSmallMateCMP.cpp | 288 +++++++++--------- samples/advanced/pdegen/runs/amg_pde3d.inp | 2 +- 2 files changed, 152 insertions(+), 138 deletions(-) diff --git a/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp b/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp index 0140c0c6..43584b77 100644 --- a/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp +++ b/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp @@ -217,7 +217,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( double Ghost2LocalInitialization = MPI_Wtime(); #endif -#pragma omp parallel private(insertMe, k, k1, adj1, adj2, adj11, adj12, heaviestEdgeWt, w, ghostOwner, u, privateU, privateMyCard, isEmpty) firstprivate(StartIndex, EndIndex) default(shared) num_threads(4) +#pragma omp parallel private(insertMe, k, u, w, v, k1, adj1, adj2, adj11, adj12, heaviestEdgeWt, ghostOwner, privateU, privateMyCard, isEmpty) firstprivate(StartIndex, EndIndex) default(shared) num_threads(4) { // TODO comments about the reduction @@ -627,11 +627,12 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( /////////////////////////////////////////////////////////////////////////////////// privateU.~staticQueue(); new(&privateU) staticQueue(1000); //TODO how can I put a meaningfull size? - /* - while ( !U.empty() ) { - u = U.pop_front(); //Get an element from the queue - */ isEmpty = false; + +#ifdef COUNT_LOCAL_VERTEX + MilanLongInt localVertices = 0; +#endif + while( true ) { @@ -647,8 +648,10 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( #endif if ( (u >= StartIndex) && (u <= EndIndex) ) { //Process Only the Local Vertices -#pragma omp critical - { +#ifdef COUNT_LOCAL_VERTEX + localVertices ++; +#endif + //Get the Adjacency list for u adj1 = verLocPtr[u - StartIndex]; //Pointer adj2 = verLocPtr[u - StartIndex + 1]; @@ -656,118 +659,51 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( v = verLocInd[k]; if ((v >= StartIndex) && (v <= EndIndex)) { //If Local Vertex: - - if (isAlreadyMatched(v, StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap)) continue; +#pragma omp critical + { #ifdef PRINT_DEBUG_INFO_ - cout<<"\n("<= 0) { - if ((w < StartIndex) || (w > EndIndex)) { //A ghost - //Build the Message Packet: - //Message[0] = v; //LOCAL - //Message[1] = w; //GHOST - //Message[2] = REQUEST; //TYPE - //Send a Request (Asynchronous) + //End: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v) #ifdef PRINT_DEBUG_INFO_ - cout<<"\n("< 0) { - Counter[Ghost2LocalMap[w]] = Counter[Ghost2LocalMap[w]] - 1; //Decrement - if (Counter[Ghost2LocalMap[w]] == 0) { - S--; //Decrement S -#ifdef PRINT_DEBUG_INFO_ - cout<<"\n("< 0 - //End: PARALLEL_PROCESS_CROSS_EDGE_B(v,w) - } //End of if CandidateMate[w] = v - } //End of if a Ghost Vertex - else { //w is a local vertex - if (candidateMate[w - StartIndex] == v) { - Mate[v - StartIndex] = w; //v is a local vertex - Mate[w - StartIndex] = v; //w is a local vertex - //Q.push_back(u); - privateU.push_back(v); - privateU.push_back(w); - privateMyCard++; -#ifdef PRINT_DEBUG_INFO_ - cout<<"\n("<=0) - else { - adj11 = verLocPtr[v - StartIndex]; - adj12 = verLocPtr[v - StartIndex + 1]; - for (k1 = adj11; k1 < adj12; k1++) { - w = verLocInd[k1]; + //If found a dominating edge: + if (w >= 0) { if ((w < StartIndex) || (w > EndIndex)) { //A ghost //Build the Message Packet: - //Message[0] = v; //LOCAL - //Message[1] = w; //GHOST - //Message[2] = FAILURE; //TYPE + //Message[0] = v; //LOCAL + //Message[1] = w; //GHOST + //Message[2] = REQUEST; //TYPE //Send a Request (Asynchronous) #ifdef PRINT_DEBUG_INFO_ - cout<<"\n("< 0) { + Counter[Ghost2LocalMap[w]] = Counter[Ghost2LocalMap[w]] - 1; //Decrement + if (Counter[Ghost2LocalMap[w]] == 0) { + S--; //Decrement S +#ifdef PRINT_DEBUG_INFO_ + cout<<"\n("< 0 + //End: PARALLEL_PROCESS_CROSS_EDGE_B(v,w) + } //End of if CandidateMate[w] = v + } //End of if a Ghost Vertex + else { //w is a local vertex + if (candidateMate[w - StartIndex] == v) { + Mate[v - StartIndex] = w; //v is a local vertex + Mate[w - StartIndex] = v; //w is a local vertex + //Q.push_back(u); + privateU.push_back(v); + privateU.push_back(w); + privateMyCard++; +#ifdef PRINT_DEBUG_INFO_ + cout<<"\n("<=0) + else { + adj11 = verLocPtr[v - StartIndex]; + adj12 = verLocPtr[v - StartIndex + 1]; + for (k1 = adj11; k1 < adj12; k1++) { + w = verLocInd[k1]; + if ((w < StartIndex) || (w > EndIndex)) { //A ghost + //Build the Message Packet: + //Message[0] = v; //LOCAL + //Message[1] = w; //GHOST + //Message[2] = FAILURE; //TYPE + //Send a Request (Asynchronous) +#ifdef PRINT_DEBUG_INFO_ + cout<<"\n("<= StartIndex) && (v <= EndIndex) ) //If Local Vertex: else { //Neighbor is a ghost vertex - if (candidateMate[NLVer + Ghost2LocalMap[v]] == u) - candidateMate[NLVer + Ghost2LocalMap[v]] = -1; - if (v != Mate[u - StartIndex]) { //u is local - //Build the Message Packet: - //Message[0] = u; //LOCAL - //Message[1] = v; //GHOST - //Message[2] = SUCCESS; //TYPE - //Send a Request (Asynchronous) -#ifdef PRINT_DEBUG_INFO_ - cout<<"\n("<= StartIndex) && (u <= EndIndex) ) //Process Only If a Local Vertex #pragma omp critical(U) @@ -827,8 +834,15 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( } //End of while ( /*!Q.empty()*/ !U.empty() ) +#ifdef COUNT_LOCAL_VERTEX + printf("Count local vertexes: %ld for thread %d of processor %d\n", + localVertices, + omp_get_thread_num(), + myRank); +#endif } // end of parallel region + ///////////////////////// END OF PROCESS MATCHED VERTICES ///////////////////////// #ifdef DEBUG_HANG_ if (myRank == 0) cout<<"\n("<