Refactoring isAlreadyMatched and processCrossEdge

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

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

@ -142,7 +142,6 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
vector<MilanLongInt> QLocalVtx, QGhostVtx, QMsgType;
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];
for (int i = 0; i < numProcs; i++)
PCounter[i] = 0;
@ -358,7 +357,6 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Entering While(true) loop..";
fflush(stdout);
// U.display(); fflush(stdout);
#endif
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << "=========================************===============================" << endl;
@ -468,7 +466,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
fflush(stdout);
#endif
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, w, &S);
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[w], &S);
} // End of if CandidateMate[w] = v
} // End of if a Ghost Vertex

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

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

@ -115,7 +115,7 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
//TODO refactor this!!
// 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 a Ghost Vertex

@ -174,7 +174,7 @@ void processMatchedVertices(
// TODO refactor this
// 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 a Ghost Vertex

@ -30,7 +30,7 @@ void processMessages(
MilanInt Sender;
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 ghostOwner;
int error_codeC;
@ -155,15 +155,13 @@ void processMessages(
fflush(stdout);
#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
bundleCounter++;
v = ReceiveBuffer[bundleCounter]; // LOCAL
bundleCounter++;
message_type = ReceiveBuffer[bundleCounter]; // TYPE
bundleCounter++;
u = ReceiveBuffer[bundleCounter - 3]; // GHOST
v = ReceiveBuffer[bundleCounter - 2]; // LOCAL
message_type = ReceiveBuffer[bundleCounter - 1]; // TYPE
// CASE I: REQUEST
if (message_type == REQUEST)
@ -188,7 +186,6 @@ void processMessages(
{
GMate[Ghost2LocalMap[u]] = v; // u is ghost
Mate[v - StartIndex] = u; // v is local
// Q.push_back(u);
U.push_back(v);
U.push_back(u);
myCard++;
@ -196,7 +193,8 @@ void processMessages(
cout << "\n(" << myRank << ")MATCH: (" << v << "," << u << ") " << endl;
fflush(stdout);
#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 ( Mate[v] == -1 )
} // End of REQUEST
@ -208,8 +206,8 @@ void processMessages(
cout << "\n(" << myRank << ")Message type is SUCCESS" << endl;
fflush(stdout);
#endif
GMate[Ghost2LocalMap[u]] = EndIndex + 1; // Set a Dummy Mate to make sure that we do not (u is a ghost)
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, u, S);
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);
#ifdef DEBUG_GHOST_
if ((v < 0) || (v < StartIndex) || ((v - StartIndex) > NLVer))
{
@ -261,8 +259,8 @@ void processMessages(
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") " << endl;
fflush(stdout);
#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 a Ghost Vertex
else
@ -321,7 +319,7 @@ void processMessages(
fflush(stdout);
#endif
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 I
}

Loading…
Cancel
Save