Refactoring isAlreadyMatched and processCrossEdge

omp-walther
StefanoPetrilli 2 years ago
parent f17082b337
commit 5ca78fb871

@ -290,7 +290,6 @@ extern "C"
staticQueue &privateQOwner); staticQueue &privateQOwner);
void PROCESS_CROSS_EDGE(vector<MilanLongInt> &Counter, void PROCESS_CROSS_EDGE(vector<MilanLongInt> &Counter,
map<MilanLongInt, MilanLongInt> &Ghost2LocalMap,
MilanLongInt edge, MilanLongInt edge,
MilanLongInt *SPtr); MilanLongInt *SPtr);

@ -142,7 +142,6 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
vector<MilanLongInt> QLocalVtx, QGhostVtx, QMsgType; vector<MilanLongInt> QLocalVtx, QGhostVtx, QMsgType;
vector<MilanInt> QOwner; // Changed by Fabio to be an integer, addresses needs to be integers! vector<MilanInt> QOwner; // Changed by Fabio to be an integer, addresses needs to be integers!
// TODO move this inseide the initialization function
MilanLongInt *PCounter = new MilanLongInt[numProcs]; MilanLongInt *PCounter = new MilanLongInt[numProcs];
for (int i = 0; i < numProcs; i++) for (int i = 0; i < numProcs; i++)
PCounter[i] = 0; PCounter[i] = 0;
@ -358,7 +357,6 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Entering While(true) loop.."; cout << "\n(" << myRank << ")Entering While(true) loop..";
fflush(stdout); fflush(stdout);
// U.display(); fflush(stdout);
#endif #endif
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << "=========================************===============================" << endl; cout << "\n(" << myRank << "=========================************===============================" << endl;
@ -468,7 +466,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
fflush(stdout); fflush(stdout);
#endif #endif
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, w, &S); PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[w], &S);
} // End of if CandidateMate[w] = v } // End of if CandidateMate[w] = v
} // End of if a Ghost Vertex } // End of if a Ghost Vertex

@ -23,11 +23,9 @@ bool isAlreadyMatched(MilanLongInt node,
#pragma omp critical(Mate) #pragma omp critical(Mate)
{ {
if ((node < StartIndex) || (node > EndIndex)) { //Is it a ghost vertex? if ((node < StartIndex) || (node > EndIndex)) { //Is it a ghost vertex?
if (GMate[Ghost2LocalMap[node]] >= 0)// Already matched result = GMate[Ghost2LocalMap[node]] >= 0;// Already matched
result = true;
} else { //A local vertex } else { //A local vertex
if (Mate[node - StartIndex] >= 0) // Already matched result = (Mate[node - StartIndex] >= 0); // Already matched
result = true;
} }
} }

@ -1,16 +1,15 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
void PROCESS_CROSS_EDGE(vector<MilanLongInt> &Counter, void PROCESS_CROSS_EDGE(vector<MilanLongInt> &Counter,
map<MilanLongInt, MilanLongInt> &Ghost2LocalMap,
MilanLongInt edge, MilanLongInt edge,
MilanLongInt *SPtr) MilanLongInt *SPtr)
{ {
// Decrement the counter: // Decrement the counter:
// Start: PARALLEL_PROCESS_CROSS_EDGE_B // Start: PARALLEL_PROCESS_CROSS_EDGE_B
if (Counter[Ghost2LocalMap[edge]] > 0) if (Counter[edge] > 0)
{ {
Counter[Ghost2LocalMap[edge]] -= 1; // Decrement Counter[edge] -= 1; // Decrement
if (Counter[Ghost2LocalMap[edge]] == 0) if (Counter[edge] == 0)
{ {
(*SPtr)--; // Decrement S (*SPtr)--; // Decrement S
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_

@ -115,7 +115,7 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
//TODO refactor this!! //TODO refactor this!!
// Decrement the counter: // Decrement the counter:
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, w, &S); PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[w], &S);
} // End of if CandidateMate[w] = v } // End of if CandidateMate[w] = v
} // End of if a Ghost Vertex } // End of if a Ghost Vertex

@ -174,7 +174,7 @@ void processMatchedVertices(
// TODO refactor this // TODO refactor this
// Decrement the counter: // Decrement the counter:
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, w, &S); PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[w], &S);
} // End of if CandidateMate[w] = v } // End of if CandidateMate[w] = v
} // End of if a Ghost Vertex } // End of if a Ghost Vertex

@ -30,7 +30,7 @@ void processMessages(
MilanInt Sender; MilanInt Sender;
MPI_Status computeStatus; MPI_Status computeStatus;
MilanLongInt bundleSize, bundleCounter = 0, myCard = *myCardPtr, msgInd = *msgIndPtr, msgActual = *msgActualPtr, w; MilanLongInt bundleSize, myCard = *myCardPtr, msgInd = *msgIndPtr, msgActual = *msgActualPtr, w;
MilanLongInt adj11, adj12, k1; MilanLongInt adj11, adj12, k1;
MilanLongInt ghostOwner; MilanLongInt ghostOwner;
int error_codeC; int error_codeC;
@ -155,15 +155,13 @@ void processMessages(
fflush(stdout); fflush(stdout);
#endif #endif
bundleCounter = 0;
while (bundleCounter < bundleSize) //Most of the time bundleSize == 3, thus, it's not worth parallelizing thi loop
for (MilanLongInt bundleCounter = 3; bundleCounter < bundleSize + 3; bundleCounter += 3)
{ {
u = ReceiveBuffer[bundleCounter]; // GHOST u = ReceiveBuffer[bundleCounter - 3]; // GHOST
bundleCounter++; v = ReceiveBuffer[bundleCounter - 2]; // LOCAL
v = ReceiveBuffer[bundleCounter]; // LOCAL message_type = ReceiveBuffer[bundleCounter - 1]; // TYPE
bundleCounter++;
message_type = ReceiveBuffer[bundleCounter]; // TYPE
bundleCounter++;
// CASE I: REQUEST // CASE I: REQUEST
if (message_type == REQUEST) if (message_type == REQUEST)
@ -188,7 +186,6 @@ void processMessages(
{ {
GMate[Ghost2LocalMap[u]] = v; // u is ghost GMate[Ghost2LocalMap[u]] = v; // u is ghost
Mate[v - StartIndex] = u; // v is local Mate[v - StartIndex] = u; // v is local
// Q.push_back(u);
U.push_back(v); U.push_back(v);
U.push_back(u); U.push_back(u);
myCard++; myCard++;
@ -196,7 +193,8 @@ void processMessages(
cout << "\n(" << myRank << ")MATCH: (" << v << "," << u << ") " << endl; cout << "\n(" << myRank << ")MATCH: (" << v << "," << u << ") " << endl;
fflush(stdout); fflush(stdout);
#endif #endif
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, u, S);
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[u], S);
} // End of if ( candidateMate[v-StartIndex] == u )e } // End of if ( candidateMate[v-StartIndex] == u )e
} // End of if ( Mate[v] == -1 ) } // End of if ( Mate[v] == -1 )
} // End of REQUEST } // End of REQUEST
@ -208,8 +206,8 @@ void processMessages(
cout << "\n(" << myRank << ")Message type is SUCCESS" << endl; cout << "\n(" << myRank << ")Message type is SUCCESS" << endl;
fflush(stdout); fflush(stdout);
#endif #endif
GMate[Ghost2LocalMap[u]] = EndIndex + 1; // Set a Dummy Mate to make sure that we do not (u is a ghost) GMate[Ghost2LocalMap[u]] = EndIndex + 1; // Set a Dummy Mate to make sure that we do not (u is a ghost) process it again
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, u, S); PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[u], S);
#ifdef DEBUG_GHOST_ #ifdef DEBUG_GHOST_
if ((v < 0) || (v < StartIndex) || ((v - StartIndex) > NLVer)) if ((v < 0) || (v < StartIndex) || ((v - StartIndex) > NLVer))
{ {
@ -261,8 +259,8 @@ void processMessages(
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") " << endl; cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") " << endl;
fflush(stdout); fflush(stdout);
#endif #endif
// Decrement the counter:
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, w, S); PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[w], S);
} // End of if CandidateMate[w] = v } // End of if CandidateMate[w] = v
} // End of if a Ghost Vertex } // End of if a Ghost Vertex
else else
@ -321,7 +319,7 @@ void processMessages(
fflush(stdout); fflush(stdout);
#endif #endif
GMate[Ghost2LocalMap[u]] = EndIndex + 1; // Set a Dummy Mate to make sure that we do not (u is a ghost) process this anymore GMate[Ghost2LocalMap[u]] = EndIndex + 1; // Set a Dummy Mate to make sure that we do not (u is a ghost) process this anymore
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, u, S); // Decrease the counter PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[u], S); // Decrease the counter
} // End of else: CASE III } // End of else: CASE III
} // End of else: CASE I } // End of else: CASE I
} }

Loading…
Cancel
Save