U and privateU are now vectors

omp-walther
StefanoPetrilli 2 years ago
parent a259e8ab53
commit 6414d3aef3

@ -183,8 +183,8 @@ extern "C"
MilanLongInt *verLocInd, MilanLongInt *verLocInd,
MilanReal *edgeLocWeight); MilanReal *edgeLocWeight);
void queuesTransfer(staticQueue &U, void queuesTransfer(vector<MilanLongInt> &U,
staticQueue &privateU, vector<MilanLongInt> &privateU,
vector<MilanLongInt> &QLocalVtx, vector<MilanLongInt> &QLocalVtx,
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
@ -231,8 +231,8 @@ extern "C"
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
vector<MilanInt> &QOwner, vector<MilanInt> &QOwner,
MilanLongInt *&candidateMate, MilanLongInt *&candidateMate,
staticQueue &U, vector<MilanLongInt> &U,
staticQueue &privateU, vector<MilanLongInt> &privateU,
vector<MilanLongInt> &privateQLocalVtx, vector<MilanLongInt> &privateQLocalVtx,
vector<MilanLongInt> &privateQGhostVtx, vector<MilanLongInt> &privateQGhostVtx,
vector<MilanLongInt> &privateQMsgType, vector<MilanLongInt> &privateQMsgType,
@ -278,8 +278,8 @@ extern "C"
vector<MilanLongInt> &Counter, vector<MilanLongInt> &Counter,
MilanInt myRank, MilanInt myRank,
MilanInt numProcs, MilanInt numProcs,
staticQueue &U, vector<MilanLongInt> &U,
staticQueue &privateU, vector<MilanLongInt> &privateU,
vector<MilanLongInt> &QLocalVtx, vector<MilanLongInt> &QLocalVtx,
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
@ -295,8 +295,8 @@ extern "C"
void processMatchedVertices( void processMatchedVertices(
MilanLongInt NLVer, MilanLongInt NLVer,
vector<MilanLongInt> &UChunkBeingProcessed, vector<MilanLongInt> &UChunkBeingProcessed,
staticQueue &U, vector<MilanLongInt> &U,
staticQueue &privateU, vector<MilanLongInt> &privateU,
MilanLongInt StartIndex, MilanLongInt StartIndex,
MilanLongInt EndIndex, MilanLongInt EndIndex,
MilanLongInt *myCardPtr, MilanLongInt *myCardPtr,
@ -327,8 +327,8 @@ extern "C"
void processMatchedVerticesAndSendMessages( void processMatchedVerticesAndSendMessages(
MilanLongInt NLVer, MilanLongInt NLVer,
vector<MilanLongInt> &UChunkBeingProcessed, vector<MilanLongInt> &UChunkBeingProcessed,
staticQueue &U, vector<MilanLongInt> &U,
staticQueue &privateU, vector<MilanLongInt> &privateU,
MilanLongInt StartIndex, MilanLongInt StartIndex,
MilanLongInt EndIndex, MilanLongInt EndIndex,
MilanLongInt *myCardPtr, MilanLongInt *myCardPtr,
@ -404,12 +404,12 @@ extern "C"
MilanLongInt u, MilanLongInt u,
MilanLongInt v, MilanLongInt v,
MilanLongInt *SPtr, MilanLongInt *SPtr,
staticQueue &U); vector<MilanLongInt> &U);
void extractUChunk( void extractUChunk(
vector<MilanLongInt> &UChunkBeingProcessed, vector<MilanLongInt> &UChunkBeingProcessed,
staticQueue &U, vector<MilanLongInt> &U,
staticQueue &privateU); vector<MilanLongInt> &privateU);
void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
MilanLongInt NLVer, MilanLongInt NLEdge, MilanLongInt NLVer, MilanLongInt NLEdge,

@ -182,7 +182,6 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
vector<MilanLongInt> GMate; // Proportional to the number of ghost vertices vector<MilanLongInt> GMate; // Proportional to the number of ghost vertices
MilanLongInt S; MilanLongInt S;
MilanLongInt privateMyCard = 0; MilanLongInt privateMyCard = 0;
staticQueue U, privateU;
vector<MilanLongInt> PCumulative, PMessageBundle, PSizeInfoMessages; vector<MilanLongInt> PCumulative, PMessageBundle, PSizeInfoMessages;
vector<MPI_Request> SRequest; // Requests that are used for each send message vector<MPI_Request> SRequest; // Requests that are used for each send message
vector<MPI_Status> SStatus; // Status of sent messages, used in MPI_Wait vector<MPI_Status> SStatus; // Status of sent messages, used in MPI_Wait
@ -192,6 +191,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
vector<MilanLongInt> privateQLocalVtx, privateQGhostVtx, privateQMsgType; vector<MilanLongInt> privateQLocalVtx, privateQGhostVtx, privateQMsgType;
vector<MilanInt> privateQOwner; vector<MilanInt> privateQOwner;
vector<MilanLongInt> U, privateU;
initialize(NLVer, NLEdge, StartIndex, initialize(NLVer, NLEdge, StartIndex,
EndIndex, &numGhostEdges, EndIndex, &numGhostEdges,
@ -240,7 +240,6 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
* TODO: Test when it's actually more efficient to execute this code * TODO: Test when it's actually more efficient to execute this code
* in parallel. * in parallel.
*/ */
PARALLEL_PROCESS_EXPOSED_VERTEX_B(NLVer, PARALLEL_PROCESS_EXPOSED_VERTEX_B(NLVer,
candidateMate, candidateMate,
verLocInd, verLocInd,

@ -2,8 +2,8 @@
void extractUChunk( void extractUChunk(
vector<MilanLongInt> &UChunkBeingProcessed, vector<MilanLongInt> &UChunkBeingProcessed,
staticQueue &U, vector<MilanLongInt> &U,
staticQueue &privateU) vector<MilanLongInt> &privateU)
{ {
UChunkBeingProcessed.clear(); UChunkBeingProcessed.clear();
@ -13,7 +13,8 @@ void extractUChunk(
if (U.empty() && !privateU.empty()) // If U is empty but there are nodes in private U if (U.empty() && !privateU.empty()) // If U is empty but there are nodes in private U
{ {
while (!privateU.empty()) while (!privateU.empty())
UChunkBeingProcessed.push_back(privateU.pop_back()); UChunkBeingProcessed.push_back(privateU.back());
privateU.pop_back();
} }
else else
{ {
@ -21,9 +22,10 @@ void extractUChunk(
{ // Pop the new nodes { // Pop the new nodes
if (U.empty()) if (U.empty())
break; 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
} }

@ -19,8 +19,8 @@ void initialize(MilanLongInt NLVer, MilanLongInt NLEdge,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
vector<MilanInt> &QOwner, vector<MilanInt> &QOwner,
MilanLongInt *&candidateMate, MilanLongInt *&candidateMate,
staticQueue &U, vector<MilanLongInt> &U,
staticQueue &privateU, vector<MilanLongInt> &privateU,
vector<MilanLongInt> &privateQLocalVtx, vector<MilanLongInt> &privateQLocalVtx,
vector<MilanLongInt> &privateQGhostVtx, vector<MilanLongInt> &privateQGhostVtx,
vector<MilanLongInt> &privateQMsgType, vector<MilanLongInt> &privateQMsgType,
@ -288,18 +288,15 @@ void initialize(MilanLongInt NLVer, MilanLongInt NLEdge,
* of a staticQueue I had to destroy the previous object and instantiate * of a staticQueue I had to destroy the previous object and instantiate
* a new one of the correct size. * 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); privateQLocalVtx.reserve(*numGhostVertices);
privateQGhostVtx.reserve(*numGhostVertices); privateQGhostVtx.reserve(*numGhostVertices);
privateQMsgType.reserve(*numGhostVertices); privateQMsgType.reserve(*numGhostVertices);
privateQOwner.reserve(*numGhostVertices); privateQOwner.reserve(*numGhostVertices);
privateU.reserve(*numGhostVertices);
} // end of task } // end of task
} // End of single region } // End of single region

@ -19,8 +19,8 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
vector<MilanLongInt> &Counter, vector<MilanLongInt> &Counter,
MilanInt myRank, MilanInt myRank,
MilanInt numProcs, MilanInt numProcs,
staticQueue &U, vector<MilanLongInt> &U,
staticQueue &privateU, vector<MilanLongInt> &privateU,
vector<MilanLongInt> &QLocalVtx, vector<MilanLongInt> &QLocalVtx,
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,

@ -3,8 +3,8 @@
void processMatchedVertices( void processMatchedVertices(
MilanLongInt NLVer, MilanLongInt NLVer,
vector<MilanLongInt> &UChunkBeingProcessed, vector<MilanLongInt> &UChunkBeingProcessed,
staticQueue &U, vector<MilanLongInt> &U,
staticQueue &privateU, vector<MilanLongInt> &privateU,
MilanLongInt StartIndex, MilanLongInt StartIndex,
MilanLongInt EndIndex, MilanLongInt EndIndex,
MilanLongInt *myCard, MilanLongInt *myCard,
@ -275,6 +275,27 @@ void processMatchedVertices(
privateQMsgType, privateQMsgType,
privateQOwner); 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() ) } // End of while ( !U.empty() )
#ifdef COUNT_LOCAL_VERTEX #ifdef COUNT_LOCAL_VERTEX

@ -3,8 +3,8 @@
void processMatchedVerticesAndSendMessages( void processMatchedVerticesAndSendMessages(
MilanLongInt NLVer, MilanLongInt NLVer,
vector<MilanLongInt> &UChunkBeingProcessed, vector<MilanLongInt> &UChunkBeingProcessed,
staticQueue &U, vector<MilanLongInt> &U,
staticQueue &privateU, vector<MilanLongInt> &privateU,
MilanLongInt StartIndex, MilanLongInt StartIndex,
MilanLongInt EndIndex, MilanLongInt EndIndex,
MilanLongInt *myCard, MilanLongInt *myCard,

@ -25,7 +25,7 @@ void processMessages(
MilanLongInt u, MilanLongInt u,
MilanLongInt v, MilanLongInt v,
MilanLongInt *S, MilanLongInt *S,
staticQueue &U) vector<MilanLongInt> &U)
{ {
//#define PRINT_DEBUG_INFO_ //#define PRINT_DEBUG_INFO_

@ -1,7 +1,7 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
void queuesTransfer(staticQueue &U, void queuesTransfer(vector<MilanLongInt> &U,
staticQueue &privateU, vector<MilanLongInt> &privateU,
vector<MilanLongInt> &QLocalVtx, vector<MilanLongInt> &QLocalVtx,
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
@ -14,10 +14,11 @@ void queuesTransfer(staticQueue &U,
#pragma omp critical(U) #pragma omp critical(U)
{ {
while (!privateU.empty()) U.insert(U.end(), privateU.begin(), privateU.end());
U.push_back(privateU.pop_back());
} }
privateU.clear();
#pragma omp critical(sendMessageTransfer) #pragma omp critical(sendMessageTransfer)
{ {

Loading…
Cancel
Save