From 6414d3aef32c0818babf5d3dc139c66ac5918328 Mon Sep 17 00:00:00 2001 From: StefanoPetrilli Date: Sat, 23 Jul 2022 12:47:43 -0500 Subject: [PATCH] U and privateU are now vectors --- amgprec/impl/aggregator/MatchBoxPC.h | 26 +++++++++---------- ...mEdgesLinearSearchMesgBndlSmallMateCMP.cpp | 3 +-- amgprec/impl/aggregator/extractUChunk.cpp | 12 +++++---- amgprec/impl/aggregator/initialize.cpp | 15 +++++------ .../impl/aggregator/processExposedVertex.cpp | 4 +-- .../aggregator/processMatchedVertices.cpp | 25 ++++++++++++++++-- .../processMatchedVerticesAndSendMessages.cpp | 4 +-- amgprec/impl/aggregator/processMessages.cpp | 2 +- amgprec/impl/aggregator/queueTransfer.cpp | 9 ++++--- 9 files changed, 60 insertions(+), 40 deletions(-) diff --git a/amgprec/impl/aggregator/MatchBoxPC.h b/amgprec/impl/aggregator/MatchBoxPC.h index 1066f8ef..a1fddb59 100644 --- a/amgprec/impl/aggregator/MatchBoxPC.h +++ b/amgprec/impl/aggregator/MatchBoxPC.h @@ -183,8 +183,8 @@ extern "C" MilanLongInt *verLocInd, MilanReal *edgeLocWeight); - void queuesTransfer(staticQueue &U, - staticQueue &privateU, + void queuesTransfer(vector &U, + vector &privateU, vector &QLocalVtx, vector &QGhostVtx, vector &QMsgType, @@ -231,8 +231,8 @@ extern "C" vector &QMsgType, vector &QOwner, MilanLongInt *&candidateMate, - staticQueue &U, - staticQueue &privateU, + vector &U, + vector &privateU, vector &privateQLocalVtx, vector &privateQGhostVtx, vector &privateQMsgType, @@ -278,8 +278,8 @@ extern "C" vector &Counter, MilanInt myRank, MilanInt numProcs, - staticQueue &U, - staticQueue &privateU, + vector &U, + vector &privateU, vector &QLocalVtx, vector &QGhostVtx, vector &QMsgType, @@ -295,8 +295,8 @@ extern "C" void processMatchedVertices( MilanLongInt NLVer, vector &UChunkBeingProcessed, - staticQueue &U, - staticQueue &privateU, + vector &U, + vector &privateU, MilanLongInt StartIndex, MilanLongInt EndIndex, MilanLongInt *myCardPtr, @@ -327,8 +327,8 @@ extern "C" void processMatchedVerticesAndSendMessages( MilanLongInt NLVer, vector &UChunkBeingProcessed, - staticQueue &U, - staticQueue &privateU, + vector &U, + vector &privateU, MilanLongInt StartIndex, MilanLongInt EndIndex, MilanLongInt *myCardPtr, @@ -404,12 +404,12 @@ extern "C" MilanLongInt u, MilanLongInt v, MilanLongInt *SPtr, - staticQueue &U); + vector &U); void extractUChunk( vector &UChunkBeingProcessed, - staticQueue &U, - staticQueue &privateU); + vector &U, + vector &privateU); void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( MilanLongInt NLVer, MilanLongInt NLEdge, diff --git a/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp b/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp index 4297391a..bb2dd5a7 100644 --- a/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp +++ b/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp @@ -182,7 +182,6 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( vector GMate; // Proportional to the number of ghost vertices MilanLongInt S; MilanLongInt privateMyCard = 0; - staticQueue U, privateU; vector PCumulative, PMessageBundle, PSizeInfoMessages; vector SRequest; // Requests that are used for each send message vector SStatus; // Status of sent messages, used in MPI_Wait @@ -192,6 +191,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( vector privateQLocalVtx, privateQGhostVtx, privateQMsgType; vector privateQOwner; + vector U, privateU; initialize(NLVer, NLEdge, StartIndex, EndIndex, &numGhostEdges, @@ -240,7 +240,6 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( * TODO: Test when it's actually more efficient to execute this code * in parallel. */ - PARALLEL_PROCESS_EXPOSED_VERTEX_B(NLVer, candidateMate, verLocInd, diff --git a/amgprec/impl/aggregator/extractUChunk.cpp b/amgprec/impl/aggregator/extractUChunk.cpp index e26d1011..923a0b51 100644 --- a/amgprec/impl/aggregator/extractUChunk.cpp +++ b/amgprec/impl/aggregator/extractUChunk.cpp @@ -2,8 +2,8 @@ void extractUChunk( vector &UChunkBeingProcessed, - staticQueue &U, - staticQueue &privateU) + vector &U, + vector &privateU) { UChunkBeingProcessed.clear(); @@ -13,7 +13,8 @@ void extractUChunk( if (U.empty() && !privateU.empty()) // If U is empty but there are nodes in private U { while (!privateU.empty()) - UChunkBeingProcessed.push_back(privateU.pop_back()); + UChunkBeingProcessed.push_back(privateU.back()); + privateU.pop_back(); } else { @@ -21,9 +22,10 @@ void extractUChunk( { // Pop the new nodes if (U.empty()) break; - UChunkBeingProcessed.push_back(U.pop_back()); + UChunkBeingProcessed.push_back(U.back()); + U.pop_back(); } } - } // End of critical U + } // End of critical U // End of critical U } \ No newline at end of file diff --git a/amgprec/impl/aggregator/initialize.cpp b/amgprec/impl/aggregator/initialize.cpp index 47f424fd..17a4169e 100644 --- a/amgprec/impl/aggregator/initialize.cpp +++ b/amgprec/impl/aggregator/initialize.cpp @@ -19,8 +19,8 @@ void initialize(MilanLongInt NLVer, MilanLongInt NLEdge, vector &QMsgType, vector &QOwner, MilanLongInt *&candidateMate, - staticQueue &U, - staticQueue &privateU, + vector &U, + vector &privateU, vector &privateQLocalVtx, vector &privateQGhostVtx, vector &privateQMsgType, @@ -288,18 +288,15 @@ void initialize(MilanLongInt NLVer, MilanLongInt NLEdge, * of a staticQueue I had to destroy the previous object and instantiate * a new one of the correct size. */ - new (&U) staticQueue(NLVer + (*numGhostVertices)); + //new (&U) staticQueue(NLVer + (*numGhostVertices)); + U.reserve(NLVer + (*numGhostVertices)); - // TODO how can I decide a more meaningfull size? - MilanLongInt size = (*numGhostVertices); - - // Initialize the privte data structure - new (&privateU) staticQueue(NLVer + (*numGhostVertices)); // TODO how can I put a meaningfull size? - + // Initialize the private vectors privateQLocalVtx.reserve(*numGhostVertices); privateQGhostVtx.reserve(*numGhostVertices); privateQMsgType.reserve(*numGhostVertices); privateQOwner.reserve(*numGhostVertices); + privateU.reserve(*numGhostVertices); } // end of task } // End of single region diff --git a/amgprec/impl/aggregator/processExposedVertex.cpp b/amgprec/impl/aggregator/processExposedVertex.cpp index c330e724..49227158 100644 --- a/amgprec/impl/aggregator/processExposedVertex.cpp +++ b/amgprec/impl/aggregator/processExposedVertex.cpp @@ -19,8 +19,8 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer, vector &Counter, MilanInt myRank, MilanInt numProcs, - staticQueue &U, - staticQueue &privateU, + vector &U, + vector &privateU, vector &QLocalVtx, vector &QGhostVtx, vector &QMsgType, diff --git a/amgprec/impl/aggregator/processMatchedVertices.cpp b/amgprec/impl/aggregator/processMatchedVertices.cpp index 510c9877..e96dcc1d 100644 --- a/amgprec/impl/aggregator/processMatchedVertices.cpp +++ b/amgprec/impl/aggregator/processMatchedVertices.cpp @@ -3,8 +3,8 @@ void processMatchedVertices( MilanLongInt NLVer, vector &UChunkBeingProcessed, - staticQueue &U, - staticQueue &privateU, + vector &U, + vector &privateU, MilanLongInt StartIndex, MilanLongInt EndIndex, MilanLongInt *myCard, @@ -275,6 +275,27 @@ void processMatchedVertices( 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 diff --git a/amgprec/impl/aggregator/processMatchedVerticesAndSendMessages.cpp b/amgprec/impl/aggregator/processMatchedVerticesAndSendMessages.cpp index debfc5ca..3322a05b 100644 --- a/amgprec/impl/aggregator/processMatchedVerticesAndSendMessages.cpp +++ b/amgprec/impl/aggregator/processMatchedVerticesAndSendMessages.cpp @@ -3,8 +3,8 @@ void processMatchedVerticesAndSendMessages( MilanLongInt NLVer, vector &UChunkBeingProcessed, - staticQueue &U, - staticQueue &privateU, + vector &U, + vector &privateU, MilanLongInt StartIndex, MilanLongInt EndIndex, MilanLongInt *myCard, diff --git a/amgprec/impl/aggregator/processMessages.cpp b/amgprec/impl/aggregator/processMessages.cpp index 4150a330..804790c6 100644 --- a/amgprec/impl/aggregator/processMessages.cpp +++ b/amgprec/impl/aggregator/processMessages.cpp @@ -25,7 +25,7 @@ void processMessages( MilanLongInt u, MilanLongInt v, MilanLongInt *S, - staticQueue &U) + vector &U) { //#define PRINT_DEBUG_INFO_ diff --git a/amgprec/impl/aggregator/queueTransfer.cpp b/amgprec/impl/aggregator/queueTransfer.cpp index 0439a08c..7200b43d 100644 --- a/amgprec/impl/aggregator/queueTransfer.cpp +++ b/amgprec/impl/aggregator/queueTransfer.cpp @@ -1,7 +1,7 @@ #include "MatchBoxPC.h" -void queuesTransfer(staticQueue &U, - staticQueue &privateU, +void queuesTransfer(vector &U, + vector &privateU, vector &QLocalVtx, vector &QGhostVtx, vector &QMsgType, @@ -14,10 +14,11 @@ void queuesTransfer(staticQueue &U, #pragma omp critical(U) { - while (!privateU.empty()) - U.push_back(privateU.pop_back()); + U.insert(U.end(), privateU.begin(), privateU.end()); } + privateU.clear(); + #pragma omp critical(sendMessageTransfer) {