Replaced some staticQueues with vectors for performance reasons

omp-walther
StefanoPetrilli 2 years ago
parent 066c1a5e62
commit 500403dbda

@ -189,10 +189,10 @@ extern "C"
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
vector<MilanInt> &QOwner, vector<MilanInt> &QOwner,
staticQueue &privateQLocalVtx, vector<MilanLongInt> &privateQLocalVtx,
staticQueue &privateQGhostVtx, vector<MilanLongInt> &privateQGhostVtx,
staticQueue &privateQMsgType, vector<MilanLongInt> &privateQMsgType,
staticQueue &privateQOwner); vector<MilanInt> &privateQOwner);
bool isAlreadyMatched(MilanLongInt node, bool isAlreadyMatched(MilanLongInt node,
MilanLongInt StartIndex, MilanLongInt StartIndex,
@ -233,10 +233,10 @@ extern "C"
MilanLongInt *&candidateMate, MilanLongInt *&candidateMate,
staticQueue &U, staticQueue &U,
staticQueue &privateU, staticQueue &privateU,
staticQueue &privateQLocalVtx, vector<MilanLongInt> &privateQLocalVtx,
staticQueue &privateQGhostVtx, vector<MilanLongInt> &privateQGhostVtx,
staticQueue &privateQMsgType, vector<MilanLongInt> &privateQMsgType,
staticQueue &privateQOwner); vector<MilanInt> &privateQOwner);
void clean(MilanLongInt NLVer, void clean(MilanLongInt NLVer,
MilanInt myRank, MilanInt myRank,
@ -284,10 +284,10 @@ extern "C"
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
vector<MilanInt> &QOwner, vector<MilanInt> &QOwner,
staticQueue &privateQLocalVtx, vector<MilanLongInt> &privateQLocalVtx,
staticQueue &privateQGhostVtx, vector<MilanLongInt> &privateQGhostVtx,
staticQueue &privateQMsgType, vector<MilanLongInt> &privateQMsgType,
staticQueue &privateQOwner); vector<MilanInt> &privateQOwner);
void PROCESS_CROSS_EDGE(MilanLongInt *edge, void PROCESS_CROSS_EDGE(MilanLongInt *edge,
MilanLongInt *SPtr); MilanLongInt *SPtr);
@ -319,10 +319,10 @@ extern "C"
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
vector<MilanInt> &QOwner, vector<MilanInt> &QOwner,
staticQueue &privateQLocalVtx, vector<MilanLongInt> &privateQLocalVtx,
staticQueue &privateQGhostVtx, vector<MilanLongInt> &privateQGhostVtx,
staticQueue &privateQMsgType, vector<MilanLongInt> &privateQMsgType,
staticQueue &privateQOwner); vector<MilanInt> &privateQOwner);
void processMatchedVerticesAndSendMessages( void processMatchedVerticesAndSendMessages(
MilanLongInt NLVer, MilanLongInt NLVer,
@ -351,6 +351,10 @@ extern "C"
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
vector<MilanInt> &QOwner, vector<MilanInt> &QOwner,
vector<MilanLongInt> &privateQLocalVtx,
vector<MilanLongInt> &privateQGhostVtx,
vector<MilanLongInt> &privateQMsgType,
vector<MilanInt> &privateQOwner,
MPI_Comm comm, MPI_Comm comm,
MilanLongInt *msgActual, MilanLongInt *msgActual,
vector<MilanLongInt> &Message); vector<MilanLongInt> &Message);

@ -182,7 +182,7 @@ 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, privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner; 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
@ -190,6 +190,9 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
MilanInt BufferSize; MilanInt BufferSize;
MilanLongInt *Buffer; MilanLongInt *Buffer;
vector<MilanLongInt> privateQLocalVtx, privateQGhostVtx, privateQMsgType;
vector<MilanInt> privateQOwner;
initialize(NLVer, NLEdge, StartIndex, initialize(NLVer, NLEdge, StartIndex,
EndIndex, &numGhostEdges, EndIndex, &numGhostEdges,
&numGhostVertices, &S, &numGhostVertices, &S,
@ -370,34 +373,38 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
processMatchedVerticesAndSendMessages(NLVer, processMatchedVerticesAndSendMessages(NLVer,
UChunkBeingProcessed, UChunkBeingProcessed,
U, U,
privateU, privateU,
StartIndex, StartIndex,
EndIndex, EndIndex,
&myCard, &myCard,
&msgInd, &msgInd,
&NumMessagesBundled, &NumMessagesBundled,
&S, &S,
verLocPtr, verLocPtr,
verLocInd, verLocInd,
verDistance, verDistance,
PCounter, PCounter,
Counter, Counter,
myRank, myRank,
numProcs, numProcs,
candidateMate, candidateMate,
GMate, GMate,
Mate, Mate,
Ghost2LocalMap, Ghost2LocalMap,
edgeLocWeight, edgeLocWeight,
QLocalVtx, QLocalVtx,
QGhostVtx, QGhostVtx,
QMsgType, QMsgType,
QOwner, QOwner,
comm, privateQLocalVtx,
&msgActual, privateQGhostVtx,
Message); privateQMsgType,
privateQOwner,
comm,
&msgActual,
Message);
///////////////////////// END OF PROCESS MATCHED VERTICES ///////////////////////// ///////////////////////// END OF PROCESS MATCHED VERTICES /////////////////////////

@ -21,10 +21,10 @@ void initialize(MilanLongInt NLVer, MilanLongInt NLEdge,
MilanLongInt *&candidateMate, MilanLongInt *&candidateMate,
staticQueue &U, staticQueue &U,
staticQueue &privateU, staticQueue &privateU,
staticQueue &privateQLocalVtx, vector<MilanLongInt> &privateQLocalVtx,
staticQueue &privateQGhostVtx, vector<MilanLongInt> &privateQGhostVtx,
staticQueue &privateQMsgType, vector<MilanLongInt> &privateQMsgType,
staticQueue &privateQOwner) vector<MilanInt> &privateQOwner)
{ {
MilanLongInt insertMe = 0; MilanLongInt insertMe = 0;
@ -295,10 +295,11 @@ void initialize(MilanLongInt NLVer, MilanLongInt NLEdge,
// Initialize the privte data structure // Initialize the privte data structure
new (&privateU) staticQueue(NLVer + (*numGhostVertices)); // TODO how can I put a meaningfull size? new (&privateU) staticQueue(NLVer + (*numGhostVertices)); // TODO how can I put a meaningfull size?
new (&privateQLocalVtx) staticQueue(size);
new (&privateQGhostVtx) staticQueue(size); privateQLocalVtx.reserve(*numGhostVertices);
new (&privateQMsgType) staticQueue(size); privateQGhostVtx.reserve(*numGhostVertices);
new (&privateQOwner) staticQueue(size); privateQMsgType.reserve(*numGhostVertices);
privateQOwner.reserve(*numGhostVertices);
} // end of task } // end of task
} // End of single region } // End of single region

@ -25,10 +25,10 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
vector<MilanInt> &QOwner, vector<MilanInt> &QOwner,
staticQueue &privateQLocalVtx, vector<MilanLongInt> &privateQLocalVtx,
staticQueue &privateQGhostVtx, vector<MilanLongInt> &privateQGhostVtx,
staticQueue &privateQMsgType, vector<MilanLongInt> &privateQMsgType,
staticQueue &privateQOwner) vector<MilanInt> &privateQOwner)
{ {
MilanLongInt v = -1, k = -1, w = -1, adj11 = 0, adj12 = 0, k1 = 0; MilanLongInt v = -1, k = -1, w = -1, adj11 = 0, adj12 = 0, k1 = 0;
@ -39,8 +39,11 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
num_threads(NUM_THREAD) num_threads(NUM_THREAD)
{ {
#pragma omp for reduction(+ \ #pragma omp for reduction(+ \
: PCounter[:numProcs], myCard[:1], msgInd[:1], NumMessagesBundled[:1]) schedule(static) : PCounter[:numProcs], myCard \
[:1], msgInd \
[:1], NumMessagesBundled \
[:1]) schedule(static)
for (v = 0; v < NLVer; v++) for (v = 0; v < NLVer; v++)
{ {
option = -1; option = -1;

@ -27,10 +27,10 @@ void processMatchedVertices(
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
vector<MilanInt> &QOwner, vector<MilanInt> &QOwner,
staticQueue &privateQLocalVtx, vector<MilanLongInt> &privateQLocalVtx,
staticQueue &privateQGhostVtx, vector<MilanLongInt> &privateQGhostVtx,
staticQueue &privateQMsgType, vector<MilanLongInt> &privateQMsgType,
staticQueue &privateQOwner) vector<MilanInt> &privateQOwner)
{ {
MilanLongInt adj1, adj2, adj11, adj12, k, k1, v = -1, w = -1, ghostOwner; MilanLongInt adj1, adj2, adj11, adj12, k, k1, v = -1, w = -1, ghostOwner;

@ -27,6 +27,10 @@ void processMatchedVerticesAndSendMessages(
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
vector<MilanInt> &QOwner, vector<MilanInt> &QOwner,
vector<MilanLongInt> &privateQLocalVtx,
vector<MilanLongInt> &privateQGhostVtx,
vector<MilanLongInt> &privateQMsgType,
vector<MilanInt> &privateQOwner,
MPI_Comm comm, MPI_Comm comm,
MilanLongInt *msgActual, MilanLongInt *msgActual,
vector<MilanLongInt> &Message) vector<MilanLongInt> &Message)
@ -37,13 +41,6 @@ void processMatchedVerticesAndSendMessages(
int option; int option;
MilanLongInt mateVal; MilanLongInt mateVal;
// TODO reserve!!!
vector<MilanLongInt> privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner;
privateQLocalVtx.reserve(100000);
privateQGhostVtx.reserve(100000);
privateQMsgType.reserve(100000);
privateQOwner.reserve(100000);
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << "=========================************===============================" << endl; cout << "\n(" << myRank << "=========================************===============================" << endl;
fflush(stdout); fflush(stdout);
@ -53,7 +50,7 @@ void processMatchedVerticesAndSendMessages(
#ifdef COUNT_LOCAL_VERTEX #ifdef COUNT_LOCAL_VERTEX
MilanLongInt localVertices = 0; MilanLongInt localVertices = 0;
#endif #endif
#pragma omp parallel private(k, w, v, k1, adj1, adj2, adj11, adj12, ghostOwner, option) \ #pragma omp parallel private(k, w, v, k1, adj1, adj2, adj11, adj12, ghostOwner, option) \
firstprivate(Message, privateU, StartIndex, EndIndex, privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner, UChunkBeingProcessed) default(shared) \ firstprivate(Message, privateU, StartIndex, EndIndex, privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner, UChunkBeingProcessed) default(shared) \
num_threads(NUM_THREAD) \ num_threads(NUM_THREAD) \
reduction(+ \ reduction(+ \
@ -286,25 +283,12 @@ void processMatchedVerticesAndSendMessages(
} }
} // End of outer for } // End of outer for
#pragma omp critical(U) queuesTransfer(U, privateU, QLocalVtx,
{ QGhostVtx,
while (!privateU.empty()) QMsgType, QOwner, privateQLocalVtx,
U.push_back(privateU.pop_back()); privateQGhostVtx,
} privateQMsgType,
privateQOwner);
#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() )
@ -317,7 +301,7 @@ void processMatchedVerticesAndSendMessages(
#endif #endif
} // End of parallel region } // End of parallel region
//Send the messages // Send the messages
for (int i = initialSize; i < QOwner.size(); i++) for (int i = initialSize; i < QOwner.size(); i++)
{ {

@ -1,32 +1,34 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
void queuesTransfer(staticQueue &U, void queuesTransfer(staticQueue &U,
staticQueue &privateU, staticQueue &privateU,
vector<MilanLongInt> &QLocalVtx, vector<MilanLongInt> &QLocalVtx,
vector<MilanLongInt> &QGhostVtx, vector<MilanLongInt> &QGhostVtx,
vector<MilanLongInt> &QMsgType, vector<MilanLongInt> &QMsgType,
vector<MilanInt> &QOwner, vector<MilanInt> &QOwner,
staticQueue &privateQLocalVtx, vector<MilanLongInt> &privateQLocalVtx,
staticQueue &privateQGhostVtx, vector<MilanLongInt> &privateQGhostVtx,
staticQueue &privateQMsgType, vector<MilanLongInt> &privateQMsgType,
staticQueue &privateQOwner) vector<MilanInt> &privateQOwner)
{ {
#pragma omp critical(U) #pragma omp critical(U)
{ {
while (!privateU.empty()) while (!privateU.empty())
U.push_back(privateU.pop_back()); U.push_back(privateU.pop_back());
} }
#pragma omp critical(privateMsg) #pragma omp critical(sendMessageTransfer)
{ {
while (!privateQLocalVtx.empty())
{ QLocalVtx.insert(QLocalVtx.end(), privateQLocalVtx.begin(), privateQLocalVtx.end());
QLocalVtx.push_back(privateQLocalVtx.pop_back()); QGhostVtx.insert(QGhostVtx.end(), privateQGhostVtx.begin(), privateQGhostVtx.end());
QGhostVtx.push_back(privateQGhostVtx.pop_back()); QMsgType.insert(QMsgType.end(), privateQMsgType.begin(), privateQMsgType.end());
QMsgType.push_back(privateQMsgType.pop_back()); QOwner.insert(QOwner.end(), privateQOwner.begin(), privateQOwner.end());
QOwner.push_back(privateQOwner.pop_back());
}
} }
privateQLocalVtx.clear();
privateQGhostVtx.clear();
privateQMsgType.clear();
privateQOwner.clear();
} }
Loading…
Cancel
Save