From 54d608d2dd06e637efb280868bdc862b7ffccb6f Mon Sep 17 00:00:00 2001 From: Cirdans-Home Date: Thu, 1 Feb 2024 14:50:49 +0100 Subject: [PATCH] Isolated under ifdef buggy matching --- amgprec/impl/aggregator/MatchBoxPC.cpp | 3 +- amgprec/impl/aggregator/MatchBoxPC.h | 16 ++++ ...mEdgesLinearSearchMesgBndlSmallMateCMP.cpp | 11 +-- amgprec/impl/aggregator/clean.cpp | 3 +- .../impl/aggregator/computeCandidateMate.cpp | 7 +- amgprec/impl/aggregator/extractUChunk.cpp | 5 +- amgprec/impl/aggregator/findOwnerOfGhost.cpp | 3 +- amgprec/impl/aggregator/initialize.cpp | 5 +- amgprec/impl/aggregator/isAlreadyMatched.cpp | 7 +- .../parallelComputeCandidateMateB.cpp | 3 +- amgprec/impl/aggregator/processCrossEdge.cpp | 5 +- .../impl/aggregator/processExposedVertex.cpp | 27 ++++--- .../aggregator/processMatchedVertices.cpp | 79 ++++++++++--------- .../processMatchedVerticesAndSendMessages.cpp | 76 +++++++++--------- amgprec/impl/aggregator/processMessages.cpp | 14 ++-- amgprec/impl/aggregator/queueTransfer.cpp | 3 +- .../impl/aggregator/sendBundledMessages.cpp | 9 ++- 17 files changed, 155 insertions(+), 121 deletions(-) diff --git a/amgprec/impl/aggregator/MatchBoxPC.cpp b/amgprec/impl/aggregator/MatchBoxPC.cpp index 90b448dc..37a879be 100644 --- a/amgprec/impl/aggregator/MatchBoxPC.cpp +++ b/amgprec/impl/aggregator/MatchBoxPC.cpp @@ -72,8 +72,9 @@ void dMatchBoxPC(MilanLongInt NLVer, MilanLongInt NLEdge, double tmr = MPI_Wtime(); #endif -#define OMP +// Rimosso per tornare al vecchio matching #define OMP #ifdef OMP + fprintf(stderr,"Warning: using buggy OpenMP matching!\n"); dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(NLVer, NLEdge, verLocPtr, verLocInd, edgeLocWeight, verDistance, Mate, diff --git a/amgprec/impl/aggregator/MatchBoxPC.h b/amgprec/impl/aggregator/MatchBoxPC.h index a1fddb59..35cab21d 100644 --- a/amgprec/impl/aggregator/MatchBoxPC.h +++ b/amgprec/impl/aggregator/MatchBoxPC.h @@ -59,7 +59,11 @@ #include #include #include +#ifdef OMP +// OpenMP is included and used if and only if the OpenMP version of the matching +// is required #include "omp.h" +#endif #include "primitiveDataTypeDefinitions.h" #include "dataStrStaticQueue.h" @@ -174,6 +178,10 @@ extern "C" #define MilanRealMin MINUS_INFINITY #endif +#ifdef OMP +/* These functions are only used in the experimental OMP implementation, if that +is disabled there is no reason to actually compile or reference them. */ + // Function of find the owner of a ghost vertex using binary search: MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance, MilanInt myRank, MilanInt numProcs); @@ -420,6 +428,14 @@ extern "C" MilanLongInt *msgIndSent, MilanLongInt *msgActualSent, MilanReal *msgPercent, MilanReal *ph0_time, MilanReal *ph1_time, MilanReal *ph2_time, MilanLongInt *ph1_card, MilanLongInt *ph2_card); +#endif + + +#ifndef OMP + //Function of find the owner of a ghost vertex using binary search: + inline MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance, + MilanInt myRank, MilanInt numProcs); +#endif void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateC( MilanLongInt NLVer, MilanLongInt NLEdge, diff --git a/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp b/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp index 49b366a6..b086edad 100644 --- a/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp +++ b/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp @@ -1,5 +1,5 @@ #include "MatchBoxPC.h" - +#ifdef OMP // *********************************************************************** // // MatchboxP: A C++ library for approximate weighted matching @@ -222,7 +222,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( cout << myRank << " Finished initialization" << endl; fflush(stdout); #endif - + startTime = MPI_Wtime(); ///////////////////////////////////////////////////////////////////////////////////////// @@ -391,7 +391,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( cout << myRank << " Finished sendBundles" << endl; fflush(stdout); #endif - + *ph1_card = myCard; // Cardinality at the end of Phase-1 startTime = MPI_Wtime(); ///////////////////////////////////////////////////////////////////////////////////////// @@ -422,7 +422,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( /////////////////////////////////////////////////////////////////////////////////// /////////////////////////// PROCESS MATCHED VERTICES ////////////////////////////// /////////////////////////////////////////////////////////////////////////////////// - + processMatchedVerticesAndSendMessages(NLVer, UChunkBeingProcessed, U, @@ -456,7 +456,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( comm, &msgActual, Message); - + ///////////////////////// END OF PROCESS MATCHED VERTICES ///////////////////////// //// BREAK IF NO MESSAGES EXPECTED ///////// @@ -552,3 +552,4 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( #endif #endif +#endif diff --git a/amgprec/impl/aggregator/clean.cpp b/amgprec/impl/aggregator/clean.cpp index f316aee7..018469e4 100644 --- a/amgprec/impl/aggregator/clean.cpp +++ b/amgprec/impl/aggregator/clean.cpp @@ -1,5 +1,5 @@ #include "MatchBoxPC.h" - +#ifdef OMP // TODO comment void clean(MilanLongInt NLVer, @@ -89,3 +89,4 @@ void clean(MilanLongInt NLVer, } } } +#endif diff --git a/amgprec/impl/aggregator/computeCandidateMate.cpp b/amgprec/impl/aggregator/computeCandidateMate.cpp index 7d4e7ce8..39ce8db1 100644 --- a/amgprec/impl/aggregator/computeCandidateMate.cpp +++ b/amgprec/impl/aggregator/computeCandidateMate.cpp @@ -1,5 +1,5 @@ #include "MatchBoxPC.h" - +#ifdef OMP /** * Execute the research fr the Candidate Mate without controlling if the vertices are already matched. * Returns the vertices with the highest weight @@ -60,7 +60,7 @@ MilanLongInt computeCandidateMate(MilanLongInt adj1, for (k = adj1; k < adj2; k++) { if (isAlreadyMatched(verLocInd[k], StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap)) continue; - + if ((edgeLocWeight[k] > heaviestEdgeWt) || ((edgeLocWeight[k] == heaviestEdgeWt) && (w < verLocInd[k]))) { heaviestEdgeWt = edgeLocWeight[k]; @@ -68,6 +68,7 @@ MilanLongInt computeCandidateMate(MilanLongInt adj1, } } // End of for loop // End: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v) - + return w; } +#endif diff --git a/amgprec/impl/aggregator/extractUChunk.cpp b/amgprec/impl/aggregator/extractUChunk.cpp index 923a0b51..0986dfb6 100644 --- a/amgprec/impl/aggregator/extractUChunk.cpp +++ b/amgprec/impl/aggregator/extractUChunk.cpp @@ -1,5 +1,5 @@ #include "MatchBoxPC.h" - +#ifdef OMP void extractUChunk( vector &UChunkBeingProcessed, vector &U, @@ -28,4 +28,5 @@ void extractUChunk( } } // End of critical U // End of critical U -} \ No newline at end of file +} +#endif diff --git a/amgprec/impl/aggregator/findOwnerOfGhost.cpp b/amgprec/impl/aggregator/findOwnerOfGhost.cpp index b9d60614..81c18822 100644 --- a/amgprec/impl/aggregator/findOwnerOfGhost.cpp +++ b/amgprec/impl/aggregator/findOwnerOfGhost.cpp @@ -1,5 +1,5 @@ #include "MatchBoxPC.h" - +#ifdef OMP /// Find the owner of a ghost node: MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance, MilanInt myRank, MilanInt numProcs) @@ -27,3 +27,4 @@ MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance, return Current; } // End of findOwnerOfGhost() +#endif diff --git a/amgprec/impl/aggregator/initialize.cpp b/amgprec/impl/aggregator/initialize.cpp index 17a4169e..3f0f1a10 100644 --- a/amgprec/impl/aggregator/initialize.cpp +++ b/amgprec/impl/aggregator/initialize.cpp @@ -1,5 +1,5 @@ #include "MatchBoxPC.h" - +#ifdef OMP void initialize(MilanLongInt NLVer, MilanLongInt NLEdge, MilanLongInt StartIndex, MilanLongInt EndIndex, MilanLongInt *numGhostEdges, @@ -291,7 +291,7 @@ void initialize(MilanLongInt NLVer, MilanLongInt NLEdge, //new (&U) staticQueue(NLVer + (*numGhostVertices)); U.reserve(NLVer + (*numGhostVertices)); - // Initialize the private vectors + // Initialize the private vectors privateQLocalVtx.reserve(*numGhostVertices); privateQGhostVtx.reserve(*numGhostVertices); privateQMsgType.reserve(*numGhostVertices); @@ -302,3 +302,4 @@ void initialize(MilanLongInt NLVer, MilanLongInt NLEdge, } // End of single region } // End of parallel region } +#endif diff --git a/amgprec/impl/aggregator/isAlreadyMatched.cpp b/amgprec/impl/aggregator/isAlreadyMatched.cpp index a7d65c15..de5f2f18 100644 --- a/amgprec/impl/aggregator/isAlreadyMatched.cpp +++ b/amgprec/impl/aggregator/isAlreadyMatched.cpp @@ -1,5 +1,5 @@ #include "MatchBoxPC.h" - +#ifdef OMP /** * //TODO documentation * @param k @@ -32,7 +32,7 @@ bool isAlreadyMatched(MilanLongInt node, */ MilanLongInt val; if ((node < StartIndex) || (node > EndIndex)) // if ghost vertex - { + { #pragma omp atomic read val = GMate[Ghost2LocalMap[node]]; return val >= 0; // Already matched @@ -43,4 +43,5 @@ bool isAlreadyMatched(MilanLongInt node, val = Mate[node - StartIndex]; return val >= 0; // Already matched -} \ No newline at end of file +} +#endif diff --git a/amgprec/impl/aggregator/parallelComputeCandidateMateB.cpp b/amgprec/impl/aggregator/parallelComputeCandidateMateB.cpp index ffb8d2a3..f5429bf4 100644 --- a/amgprec/impl/aggregator/parallelComputeCandidateMateB.cpp +++ b/amgprec/impl/aggregator/parallelComputeCandidateMateB.cpp @@ -1,5 +1,5 @@ #include "MatchBoxPC.h" - +#ifdef OMP void PARALLEL_COMPUTE_CANDIDATE_MATE_B(MilanLongInt NLVer, MilanLongInt *verLocPtr, MilanLongInt *verLocInd, @@ -25,3 +25,4 @@ void PARALLEL_COMPUTE_CANDIDATE_MATE_B(MilanLongInt NLVer, } } } +#endif diff --git a/amgprec/impl/aggregator/processCrossEdge.cpp b/amgprec/impl/aggregator/processCrossEdge.cpp index e844f127..d7c72d42 100644 --- a/amgprec/impl/aggregator/processCrossEdge.cpp +++ b/amgprec/impl/aggregator/processCrossEdge.cpp @@ -1,5 +1,5 @@ #include "MatchBoxPC.h" - +#ifdef OMP void PROCESS_CROSS_EDGE(MilanLongInt *edge, MilanLongInt *S) { @@ -21,4 +21,5 @@ void PROCESS_CROSS_EDGE(MilanLongInt *edge, #endif // End: PARALLEL_PROCESS_CROSS_EDGE_B -} \ No newline at end of file +} +#endif diff --git a/amgprec/impl/aggregator/processExposedVertex.cpp b/amgprec/impl/aggregator/processExposedVertex.cpp index 2b38ec7a..c7ac4703 100644 --- a/amgprec/impl/aggregator/processExposedVertex.cpp +++ b/amgprec/impl/aggregator/processExposedVertex.cpp @@ -1,5 +1,5 @@ #include "MatchBoxPC.h" - +#ifdef OMP void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer, MilanLongInt *candidateMate, MilanLongInt *verLocInd, @@ -29,7 +29,7 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer, vector &privateQGhostVtx, vector &privateQMsgType, vector &privateQOwner) -{ +{ MilanLongInt v = -1, k = -1, w = -1, adj11 = 0, adj12 = 0, k1 = 0; MilanInt ghostOwner = 0, option, igw; @@ -79,7 +79,7 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer, Ghost2LocalMap); candidateMate[v] = w; } - + if (w >= 0) { (*myCard)++; if ((w < StartIndex) || (w > EndIndex)) { // w is a ghost vertex @@ -88,29 +88,29 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer, option = 1; Mate[v] = w; GMate[Ghost2LocalMap[w]] = v + StartIndex; // w is a Ghost - + } // End of if CandidateMate[w] = v } // End of if a Ghost Vertex else { // w is a local vertex - + if (candidateMate[w - StartIndex] == (v + StartIndex)) { option = 3; Mate[v] = w; // v is local Mate[w - StartIndex] = v + StartIndex; // w is local - + #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")MATCH: (" << v + StartIndex << "," << w << ") "; fflush(stdout); #endif - + } // End of if ( candidateMate[w-StartIndex] == (v+StartIndex) ) } // End of Else - + } // End of second if - + } // End critical processExposed - + } // End of if(w >=0) else { // This piece of code is executed a really small amount of times @@ -131,17 +131,17 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer, // assert(ghostOwner != -1); // assert(ghostOwner != myRank); PCounter[ghostOwner]++; - + privateQLocalVtx.push_back(v + StartIndex); privateQGhostVtx.push_back(w); privateQMsgType.push_back(FAILURE); privateQOwner.push_back(ghostOwner); - + } // End of if(GHOST) } // End of for loop } // End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) - + switch (option) { case -1: @@ -193,3 +193,4 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer, } // End of parallel region } +#endif diff --git a/amgprec/impl/aggregator/processMatchedVertices.cpp b/amgprec/impl/aggregator/processMatchedVertices.cpp index d9363c39..d88199a6 100644 --- a/amgprec/impl/aggregator/processMatchedVertices.cpp +++ b/amgprec/impl/aggregator/processMatchedVertices.cpp @@ -1,5 +1,5 @@ #include "MatchBoxPC.h" - +#ifdef OMP void processMatchedVertices( MilanLongInt NLVer, vector &UChunkBeingProcessed, @@ -58,29 +58,29 @@ void processMatchedVertices( { while (!U.empty()) { - + extractUChunk(UChunkBeingProcessed, U, privateU); - + for (MilanLongInt u : UChunkBeingProcessed) { #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")u: " << u; fflush(stdout); #endif if ((u >= StartIndex) && (u <= EndIndex)) { // Process Only the Local Vertices - + #ifdef COUNT_LOCAL_VERTEX localVertices++; #endif - + // Get the Adjacency list for u adj1 = verLocPtr[u - StartIndex]; // Pointer adj2 = verLocPtr[u - StartIndex + 1]; for (k = adj1; k < adj2; k++) { option = -1; v = verLocInd[k]; - + if ((v >= StartIndex) && (v <= EndIndex)) { // If Local Vertex: - + #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")v: " << v << " c(v)= " << candidateMate[v - StartIndex] << " Mate[v]: " << Mate[v]; fflush(stdout); @@ -102,27 +102,27 @@ void processMatchedVertices( GMate, Mate, Ghost2LocalMap); - + candidateMate[v - StartIndex] = w; - + #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")" << v << " Points to: " << w; fflush(stdout); #endif // If found a dominating edge: - if (w >= 0) { + if (w >= 0) { if ((w < StartIndex) || (w > EndIndex)) { // A ghost #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")Sending a request message:"; cout << "\n(" << myRank << ")Ghost is " << w << " Owner is: " << findOwnerOfGhost(w, verDistance, myRank, numProcs); #endif option = 2; - + if (candidateMate[NLVer + Ghost2LocalMap[w]] == v) { option = 1; Mate[v - StartIndex] = w; // v is a local vertex GMate[Ghost2LocalMap[w]] = v; // w is a ghost vertex - + } // End of if CandidateMate[w] = v } // End of if a Ghost Vertex else { // w is a local vertex @@ -130,7 +130,7 @@ void processMatchedVertices( option = 3; Mate[v - StartIndex] = w; // v is a local vertex Mate[w - StartIndex] = v; // w is a local vertex - + #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") "; fflush(stdout); @@ -146,7 +146,7 @@ void processMatchedVertices( } // mateval < 0 } // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex: else { // Neighbor is a ghost vertex - + #pragma omp critical { if (candidateMate[NLVer + Ghost2LocalMap[v]] == u) @@ -155,7 +155,7 @@ void processMatchedVertices( option = 5; // u is local } // End of critical } // End of Else //A Ghost Vertex - + switch (option) { case -1: @@ -165,7 +165,7 @@ void processMatchedVertices( // Found a dominating edge, it is a ghost and candidateMate[NLVer + Ghost2LocalMap[w]] == v privateU.push_back(v); privateU.push_back(w); - + (*myCard)++; #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") "; @@ -174,7 +174,7 @@ void processMatchedVertices( // Decrement the counter: PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[w]], SPtr); case 2: - + // Found a dominating edge, it is a ghost ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); // assert(ghostOwner != -1); @@ -182,7 +182,7 @@ void processMatchedVertices( PCounter[ghostOwner]++; (*NumMessagesBundled)++; (*msgInd)++; - + privateQLocalVtx.push_back(v); privateQGhostVtx.push_back(w); privateQMsgType.push_back(REQUEST); @@ -191,7 +191,7 @@ void processMatchedVertices( case 3: privateU.push_back(v); privateU.push_back(w); - + (*myCard)++; break; case 4: @@ -201,94 +201,95 @@ void processMatchedVertices( for (k1 = adj11; k1 < adj12; k1++) { w = verLocInd[k1]; if ((w < StartIndex) || (w > EndIndex)) { // A ghost - + #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")Sending a failure message: "; cout << "\n(" << myRank << ")Ghost is " << w << " Owner is: " << findOwnerOfGhost(w, verDistance, myRank, numProcs); fflush(stdout); #endif - + ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); // assert(ghostOwner != -1); // assert(ghostOwner != myRank); - + PCounter[ghostOwner]++; (*NumMessagesBundled)++; (*msgInd)++; - + privateQLocalVtx.push_back(v); privateQGhostVtx.push_back(w); privateQMsgType.push_back(FAILURE); privateQOwner.push_back(ghostOwner); - + } // End of if(GHOST) } // End of for loop break; case 5: default: - + #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")Sending a success message: "; cout << "\n(" << myRank << ")Ghost is " << v << " Owner is: " << findOwnerOfGhost(v, verDistance, myRank, numProcs) << "\n"; fflush(stdout); #endif - + ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs); // assert(ghostOwner != -1); // assert(ghostOwner != myRank); - + (*NumMessagesBundled)++; PCounter[ghostOwner]++; (*msgInd)++; - + privateQLocalVtx.push_back(u); privateQGhostVtx.push_back(v); privateQMsgType.push_back(SUCCESS); privateQOwner.push_back(ghostOwner); - + break; } // End of switch - + } // End of inner for } } // End of outer for - + queuesTransfer(U, privateU, QLocalVtx, QGhostVtx, QMsgType, QOwner, privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner); - + #pragma omp critical(U) { U.insert(U.end(), privateU.begin(), privateU.end()); } - + privateU.clear(); - + #pragma omp critical(sendMessageTransfer) { - + QLocalVtx.insert(QLocalVtx.end(), privateQLocalVtx.begin(), privateQLocalVtx.end()); QGhostVtx.insert(QGhostVtx.end(), privateQGhostVtx.begin(), privateQGhostVtx.end()); QMsgType.insert(QMsgType.end(), privateQMsgType.begin(), privateQMsgType.end()); QOwner.insert(QOwner.end(), privateQOwner.begin(), privateQOwner.end()); } - + privateQLocalVtx.clear(); privateQGhostVtx.clear(); privateQMsgType.clear(); privateQOwner.clear(); - + } // End of while ( !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 } +#endif diff --git a/amgprec/impl/aggregator/processMatchedVerticesAndSendMessages.cpp b/amgprec/impl/aggregator/processMatchedVerticesAndSendMessages.cpp index 469d7a16..4a9cfcba 100644 --- a/amgprec/impl/aggregator/processMatchedVerticesAndSendMessages.cpp +++ b/amgprec/impl/aggregator/processMatchedVerticesAndSendMessages.cpp @@ -1,4 +1,5 @@ #include "MatchBoxPC.h" +#ifdef OMP //#define DEBUG_HANG_ void processMatchedVerticesAndSendMessages( MilanLongInt NLVer, @@ -63,29 +64,29 @@ void processMatchedVerticesAndSendMessages( { while (!U.empty()) { - + extractUChunk(UChunkBeingProcessed, U, privateU); - + for (MilanLongInt u : UChunkBeingProcessed) { #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")u: " << u; fflush(stdout); #endif if ((u >= StartIndex) && (u <= EndIndex)) { // Process Only the Local Vertices - + #ifdef COUNT_LOCAL_VERTEX localVertices++; #endif - + // Get the Adjacency list for u adj1 = verLocPtr[u - StartIndex]; // Pointer adj2 = verLocPtr[u - StartIndex + 1]; for (k = adj1; k < adj2; k++) { option = -1; v = verLocInd[k]; - + if ((v >= StartIndex) && (v <= EndIndex)) { // If Local Vertex: - + #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")v: " << v << " c(v)= " << candidateMate[v - StartIndex] << " Mate[v]: " << Mate[v]; fflush(stdout); @@ -107,28 +108,28 @@ void processMatchedVerticesAndSendMessages( GMate, Mate, Ghost2LocalMap); - + candidateMate[v - StartIndex] = w; - + #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")" << v << " Points to: " << w; fflush(stdout); #endif // If found a dominating edge: if (w >= 0) { - + if ((w < StartIndex) || (w > EndIndex)) { // A ghost #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")Sending a request message:"; cout << "\n(" << myRank << ")Ghost is " << w << " Owner is: " << findOwnerOfGhost(w, verDistance, myRank, numProcs); #endif option = 2; - + if (candidateMate[NLVer + Ghost2LocalMap[w]] == v) { option = 1; Mate[v - StartIndex] = w; // v is a local vertex GMate[Ghost2LocalMap[w]] = v; // w is a ghost vertex - + } // End of if CandidateMate[w] = v } // End of if a Ghost Vertex else { // w is a local vertex @@ -136,7 +137,7 @@ void processMatchedVerticesAndSendMessages( option = 3; Mate[v - StartIndex] = w; // v is a local vertex Mate[w - StartIndex] = v; // w is a local vertex - + #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") "; fflush(stdout); @@ -152,7 +153,7 @@ void processMatchedVerticesAndSendMessages( } // mateval < 0 } // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex: else { // Neighbor is a ghost vertex - + #pragma omp critical { if (candidateMate[NLVer + Ghost2LocalMap[v]] == u) @@ -161,7 +162,7 @@ void processMatchedVerticesAndSendMessages( option = 5; // u is local } // End of critical } // End of Else //A Ghost Vertex - + switch (option) { case -1: @@ -179,20 +180,20 @@ void processMatchedVerticesAndSendMessages( // Decrement the counter: PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[w]], SPtr); case 2: - + // Found a dominating edge, it is a ghost ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); - + // Build the Message Packet: // Message[0] = v; // LOCAL // Message[1] = w; // GHOST // Message[2] = REQUEST; // TYPE // Send a Request (Asynchronous) // MPI_Bsend(&Message[0], 3, TypeMap(), ghostOwner, ComputeTag, comm); - + (*msgActual)++; (*msgInd)++; - + privateQLocalVtx.push_back(v); privateQGhostVtx.push_back(w); privateQMsgType.push_back(REQUEST); @@ -210,94 +211,94 @@ void processMatchedVerticesAndSendMessages( for (k1 = adj11; k1 < adj12; k1++) { w = verLocInd[k1]; if ((w < StartIndex) || (w > EndIndex)) { // A ghost - + #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")Sending a failure message: "; cout << "\n(" << myRank << ")Ghost is " << w << " Owner is: " << findOwnerOfGhost(w, verDistance, myRank, numProcs); fflush(stdout); #endif - + ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); - + // Build the Message Packet: // Message[0] = v; // LOCAL // Message[1] = w; // GHOST // Message[2] = FAILURE; // TYPE // Send a Request (Asynchronous) // MPI_Bsend(&Message[0], 3, TypeMap(), ghostOwner, ComputeTag, comm); - + (*msgActual)++; (*msgInd)++; - + privateQLocalVtx.push_back(v); privateQGhostVtx.push_back(w); privateQMsgType.push_back(FAILURE); privateQOwner.push_back(ghostOwner); - + } // End of if(GHOST) } // End of for loop break; case 5: default: - + #ifdef PRINT_DEBUG_INFO_ cout << "\n(" << myRank << ")Sending a success message: "; cout << "\n(" << myRank << ")Ghost is " << v << " Owner is: " << findOwnerOfGhost(v, verDistance, myRank, numProcs) << "\n"; fflush(stdout); #endif - + ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs); - + // Build the Message Packet: // Message[0] = u; // LOCAL // Message[1] = v; // GHOST // Message[2] = SUCCESS; // TYPE // Send a Request (Asynchronous) // MPI_Bsend(&Message[0], 3, TypeMap(), ghostOwner, ComputeTag, comm); - + (*msgActual)++; (*msgInd)++; - + privateQLocalVtx.push_back(u); privateQGhostVtx.push_back(v); privateQMsgType.push_back(SUCCESS); privateQOwner.push_back(ghostOwner); - + break; } // End of switch } // End of inner for } } // End of outer for - + queuesTransfer(U, privateU, QLocalVtx, QGhostVtx, QMsgType, QOwner, privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner); - + } // End of while ( !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 - + // Send the messages #ifdef DEBUG_HANG_ cout << myRank<<" Sending: "<(), ghostOwner, ComputeTag, comm); //cout << myRank<<" Sending to "<(), ghostOwner, ComputeTag, comm); @@ -306,3 +307,4 @@ void processMatchedVerticesAndSendMessages( cout << myRank<<" Done sending messages"< EndIndex)) { cout << "\n(" << myRank << ") From ReceiveBuffer: This should not happen: u= " << u << " v= " << v << " Type= " << message_type << " StartIndex " << StartIndex << " EndIndex " << EndIndex << endl; @@ -160,7 +161,7 @@ void processMessages( u = ReceiveBuffer[bundleCounter - 3]; // GHOST v = ReceiveBuffer[bundleCounter - 2]; // LOCAL message_type = ReceiveBuffer[bundleCounter - 1]; // TYPE - + // CASE I: REQUEST if (message_type == REQUEST) { #ifdef PRINT_DEBUG_INFO_ @@ -188,7 +189,7 @@ void processMessages( cout << "\n(" << myRank << ")MATCH: (" << v << "," << u << ") " << endl; fflush(stdout); #endif - + PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[u]], S); } // End of if ( candidateMate[v-StartIndex] == u )e } // End of if ( Mate[v] == -1 ) @@ -249,7 +250,7 @@ void processMessages( cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") " << endl; fflush(stdout); #endif - + PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[w]], S); } // End of if CandidateMate[w] = v } // End of if a Ghost Vertex @@ -310,6 +311,7 @@ void processMessages( } // End of else: CASE III } // End of else: CASE I } - + return; } +#endif diff --git a/amgprec/impl/aggregator/queueTransfer.cpp b/amgprec/impl/aggregator/queueTransfer.cpp index 33c65749..e51095da 100644 --- a/amgprec/impl/aggregator/queueTransfer.cpp +++ b/amgprec/impl/aggregator/queueTransfer.cpp @@ -1,5 +1,5 @@ #include "MatchBoxPC.h" - +#ifdef OMP void queuesTransfer(vector &U, vector &privateU, vector &QLocalVtx, @@ -34,3 +34,4 @@ void queuesTransfer(vector &U, privateQOwner.clear(); } +#endif diff --git a/amgprec/impl/aggregator/sendBundledMessages.cpp b/amgprec/impl/aggregator/sendBundledMessages.cpp index 80a88b94..919dc7e9 100644 --- a/amgprec/impl/aggregator/sendBundledMessages.cpp +++ b/amgprec/impl/aggregator/sendBundledMessages.cpp @@ -1,5 +1,5 @@ #include "MatchBoxPC.h" - +#ifdef OMP void sendBundledMessages(MilanLongInt *numGhostEdges, MilanInt *BufferSize, MilanLongInt *Buffer, @@ -62,7 +62,7 @@ void sendBundledMessages(MilanLongInt *numGhostEdges, for (i = 0; i < numProcs; i++) PCumulative[i + 1] = PCumulative[i] + PCounter[i]; } - + #pragma omp task depend(inout \ : PCounter) { @@ -84,7 +84,7 @@ void sendBundledMessages(MilanLongInt *numGhostEdges, PCounter[QOwner[i]]++; } } - + // Send the Bundled Messages: Use ISend #pragma omp task depend(out \ : SRequest, SStatus) @@ -101,7 +101,7 @@ void sendBundledMessages(MilanLongInt *numGhostEdges, exit(1); } } - + // Send the Messages #pragma omp task depend(inout \ : SRequest, PSizeInfoMessages, PCumulative) depend(out \ @@ -207,3 +207,4 @@ void sendBundledMessages(MilanLongInt *numGhostEdges, } } } +#endif