PROCESS_CROSS_EDGE refactoring

omp-walther
StefanoPetrilli 3 years ago
parent 3de1e607eb
commit df1e4a4616

@ -9,6 +9,7 @@
#include "processExposedVertex.cpp" #include "processExposedVertex.cpp"
#include "processMatchedVertices.cpp" #include "processMatchedVertices.cpp"
#include "sendBundledMessages.cpp" #include "sendBundledMessages.cpp"
//#include "processCrossEdge.cpp"
// *********************************************************************** // ***********************************************************************
// //
@ -506,21 +507,9 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") "; cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") ";
fflush(stdout); fflush(stdout);
#endif #endif
// Decrement the counter:
// Start: PARALLEL_PROCESS_CROSS_EDGE_B(v,w) PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, w, &S);
if (Counter[Ghost2LocalMap[w]] > 0)
{
Counter[Ghost2LocalMap[w]] = Counter[Ghost2LocalMap[w]] - 1; // Decrement
if (Counter[Ghost2LocalMap[w]] == 0)
{
S--; // Decrement S
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Decrementing S: Ghost vertex " << w << " has received all its messages";
fflush(stdout);
#endif
}
} // End of if Counter[w] > 0
// End: PARALLEL_PROCESS_CROSS_EDGE_B(v,w)
} // 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
@ -759,20 +748,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
cout << "\n(" << myRank << ")MATCH: (" << v << "," << u << ") " << endl; cout << "\n(" << myRank << ")MATCH: (" << v << "," << u << ") " << endl;
fflush(stdout); fflush(stdout);
#endif #endif
// Start: PARALLEL_PROCESS_CROSS_EDGE_B(v,u) PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, u, &S);
if (Counter[Ghost2LocalMap[u]] > 0)
{
Counter[Ghost2LocalMap[u]] = Counter[Ghost2LocalMap[u]] - 1; // Decrement
if (Counter[Ghost2LocalMap[u]] == 0)
{
S--; // Decrement S
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Decrementing S: Ghost vertex " << u << " has received all its messages" << endl;
fflush(stdout);
#endif
}
} // End of if Counter[w] > 0
// End: PARALLEL_PROCESS_CROSS_EDGE_B(v,u)
} // 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
@ -784,22 +760,8 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
cout << "\n(" << myRank << ")Message type is SUCCESS" << endl; cout << "\n(" << myRank << ")Message type is SUCCESS" << endl;
fflush(stdout); fflush(stdout);
#endif #endif
// Start: PARALLEL_PROCESS_CROSS_EDGE_B(v,u)
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);
if (Counter[Ghost2LocalMap[u]] > 0)
{
Counter[Ghost2LocalMap[u]] = Counter[Ghost2LocalMap[u]] - 1; // Decrement
if (Counter[Ghost2LocalMap[u]] == 0)
{
S--; // Decrement S
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Decrementing S: Ghost vertex " << u << " has received all its messages";
fflush(stdout);
#endif
}
} // End of if Counter[w] > 0
// End: PARALLEL_PROCESS_CROSS_EDGE_B(v,u)
#ifdef DEBUG_GHOST_ #ifdef DEBUG_GHOST_
if ((v < 0) || (v < StartIndex) || ((v - StartIndex) > NLVer)) if ((v < 0) || (v < StartIndex) || ((v - StartIndex) > NLVer))
{ {
@ -877,20 +839,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
fflush(stdout); fflush(stdout);
#endif #endif
// Decrement the counter: // Decrement the counter:
// Start: PARALLEL_PROCESS_CROSS_EDGE_B(v,w) PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, w, &S);
if (Counter[Ghost2LocalMap[w]] > 0)
{
Counter[Ghost2LocalMap[w]] = Counter[Ghost2LocalMap[w]] - 1; // Decrement
if (Counter[Ghost2LocalMap[w]] == 0)
{
S--; // Decrement S
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Decrementing S: Ghost vertex " << w << " has received all its messages";
fflush(stdout);
#endif
}
} // End of if Counter[w] > 0
// End: PARALLEL_PROCESS_CROSS_EDGE_B(v,w)
} // 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
@ -949,22 +898,8 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
cout << "\n(" << myRank << ")Message type is FAILURE" << endl; cout << "\n(" << myRank << ")Message type is FAILURE" << endl;
fflush(stdout); fflush(stdout);
#endif #endif
// Start: PARALLEL_PROCESS_CROSS_EDGE_B(v,u)
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);
if (Counter[Ghost2LocalMap[u]] > 0)
{
Counter[Ghost2LocalMap[u]] = Counter[Ghost2LocalMap[u]] - 1; // Decrement
if (Counter[Ghost2LocalMap[u]] == 0)
{
S--; // Decrement S
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Decrementing S: Ghost vertex " << u << " has received all its messages";
fflush(stdout);
#endif
}
} // End of if Counter[w] > 0
// End: PARALLEL_PROCESS_CROSS_EDGE_B(v,u)
} // End of else: CASE III } // End of else: CASE III
} // End of else: CASE I } // End of else: CASE I
} // End of if (!MsgQ.empty()) } // End of if (!MsgQ.empty())

@ -0,0 +1,33 @@
#include "MatchBoxPC.h"
#include <stdio.h>
#include <iostream>
#include <assert.h>
#include <map>
#include <vector>
#include "primitiveDataTypeDefinitions.h"
#include "dataStrStaticQueue.h"
#include "omp.h"
inline void PROCESS_CROSS_EDGE(vector<MilanLongInt> &Counter,
map<MilanLongInt, MilanLongInt> &Ghost2LocalMap,
MilanLongInt edge,
MilanLongInt *SPtr)
{
MilanLongInt S = *SPtr;
// Decrement the counter:
// Start: PARALLEL_PROCESS_CROSS_EDGE_B
if (Counter[Ghost2LocalMap[edge]] > 0)
{
Counter[Ghost2LocalMap[edge]] -= 1; // Decrement
if (Counter[Ghost2LocalMap[edge]] == 0)
{
S--; // Decrement S
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Decrementing S: Ghost vertex " << edge << " has received all its messages";
fflush(stdout);
#endif
}
} // End of if Counter[edge] > 0
// End: PARALLEL_PROCESS_CROSS_EDGE_B
*SPtr = S;
}

@ -8,6 +8,7 @@
#include "dataStrStaticQueue.h" #include "dataStrStaticQueue.h"
#include "omp.h" #include "omp.h"
#include "queueTransfer.cpp" #include "queueTransfer.cpp"
#include "processCrossEdge.cpp"
inline void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer, inline void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
MilanLongInt *candidateMate, MilanLongInt *candidateMate,
@ -129,24 +130,7 @@ inline void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
//TODO refactor this!! //TODO refactor this!!
// Decrement the counter: // Decrement the counter:
// Start: PARALLEL_PROCESS_CROSS_EDGE_B(v) PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, w, &S);
#pragma omp critical
{
if (Counter[Ghost2LocalMap[w]] > 0)
{
Counter[Ghost2LocalMap[w]] -= 1; // Decrement
if (Counter[Ghost2LocalMap[w]] == 0)
{
S--; // Decrement S
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Decrementing S: Ghost vertex " << w << " has received all its messages";
fflush(stdout);
#endif
}
}
} // End of if Counter[w] > 0
// End: PARALLEL_PROCESS_CROSS_EDGE_B(v)
} // End of if CandidateMate[w] = v } // End of if CandidateMate[w] = v
} // End of if a Ghost Vertex } // End of if a Ghost Vertex

@ -177,20 +177,8 @@ inline void processMatchedVertices(
// TODO refactor this // TODO refactor this
// Decrement the counter: // Decrement the counter:
// Start: PARALLEL_PROCESS_CROSS_EDGE_B(v,w) PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap, w, &S);
if (Counter[Ghost2LocalMap[w]] > 0)
{
Counter[Ghost2LocalMap[w]] = Counter[Ghost2LocalMap[w]] - 1; // Decrement
if (Counter[Ghost2LocalMap[w]] == 0)
{
S--; // Decrement S
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Decrementing S: Ghost vertex " << w << " has received all its messages";
fflush(stdout);
#endif
}
} // End of if Counter[w] > 0
// End: PARALLEL_PROCESS_CROSS_EDGE_B(v,w)
} // 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

Loading…
Cancel
Save