fix private queues in PARALLEL_PROCESS_EXPOSED_VERTEX_B

omp-walther
StefanoPetrilli 2 years ago
parent 63b7602d3a
commit 6dcae6d0c1

@ -275,34 +275,34 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
candidateMate); candidateMate);
PARALLEL_PROCESS_EXPOSED_VERTEX_B(NLVer, PARALLEL_PROCESS_EXPOSED_VERTEX_B(NLVer,
candidateMate, candidateMate,
verLocInd, verLocInd,
verLocPtr, verLocPtr,
StartIndex, StartIndex,
EndIndex, EndIndex,
Mate, Mate,
GMate, GMate,
Ghost2LocalMap, Ghost2LocalMap,
edgeLocWeight, edgeLocWeight,
&myCard, &myCard,
&msgInd, &msgInd,
&NumMessagesBundled, &NumMessagesBundled,
&S, &S,
verDistance, verDistance,
PCounter, PCounter,
Counter, Counter,
myRank, myRank,
numProcs, numProcs,
U, U,
privateU, privateU,
QLocalVtx, QLocalVtx,
QGhostVtx, QGhostVtx,
QMsgType, QMsgType,
QOwner, QOwner,
privateQLocalVtx, privateQLocalVtx,
privateQGhostVtx, privateQGhostVtx,
privateQMsgType, privateQMsgType,
privateQOwner); privateQOwner);
tempCounter.clear(); // Do not need this any more tempCounter.clear(); // Do not need this any more
@ -455,6 +455,8 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") "; cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") ";
fflush(stdout); fflush(stdout);
#endif #endif
// TODO refactor this
// Decrement the counter: // Decrement the counter:
// Start: PARALLEL_PROCESS_CROSS_EDGE_B(v,w) // Start: PARALLEL_PROCESS_CROSS_EDGE_B(v,w)
if (Counter[Ghost2LocalMap[w]] > 0) if (Counter[Ghost2LocalMap[w]] > 0)
@ -579,29 +581,25 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
// Avoid to ask for the critical section if there is nothing to add // Avoid to ask for the critical section if there is nothing to add
if (privateU.size() < UCHUNK && !U.empty()) if (privateU.size() < UCHUNK && !U.empty())
continue; continue;
#pragma omp critical(U) queuesTransfer(U, privateU, QLocalVtx,
{ QGhostVtx,
while (!privateU.empty()) QMsgType, QOwner, privateQLocalVtx,
{ privateQGhostVtx,
U.push_back(privateU.pop_front()); privateQMsgType,
} privateQOwner);
myCard += privateMyCard;
} // End of critical U
} }
} // End of while ( /*!Q.empty()*/ !U.empty() ) } // End of while ( /*!Q.empty()*/ !U.empty() )
#pragma omp critical(privateMsg) #pragma omp critical
{ {
while (!privateQLocalVtx.empty()) myCard += privateMyCard;
{
QLocalVtx.push_back(privateQLocalVtx.pop_front());
QGhostVtx.push_back(privateQGhostVtx.pop_front());
QMsgType.push_back(privateQMsgType.pop_front());
QOwner.push_back(privateQOwner.pop_front());
}
} }
queuesTransfer(U, privateU, QLocalVtx,
QGhostVtx,
QMsgType, QOwner, privateQLocalVtx,
privateQGhostVtx,
privateQMsgType,
privateQOwner);
#ifdef COUNT_LOCAL_VERTEX #ifdef COUNT_LOCAL_VERTEX
printf("Count local vertexes: %ld for thread %d of processor %d\n", printf("Count local vertexes: %ld for thread %d of processor %d\n",

@ -11,14 +11,9 @@
/* /*
* PARALLEL_PROCESS_EXPOSED_VERTEX_B * PARALLEL_PROCESS_EXPOSED_VERTEX_B
* The sequential version could be a bit more * TODO: write comment
* efficient.
* *
* TODO: Maybe it is possible to append the values of QLocalVtx, QGhostVtx, QMsgType and QOwner * TODO: Test when it's actually more efficient to execute this code
* first in a local variable and then, only at the end, append them to the real data structure
* to remove the critical sections.
*
* TODO: Test when it's more efficient to execute this code
* in parallel. * in parallel.
*/ */
@ -119,22 +114,11 @@ inline void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
assert(ghostOwner != myRank); assert(ghostOwner != myRank);
PCounter[ghostOwner]++; PCounter[ghostOwner]++;
/*
//TODO why does it fail if I use a private data structure???
privateQLocalVtx.push_back(v + StartIndex); privateQLocalVtx.push_back(v + StartIndex);
privateQGhostVtx.push_back(w); privateQGhostVtx.push_back(w);
privateQMsgType.push_back(REQUEST); privateQMsgType.push_back(REQUEST);
privateQOwner.push_back(ghostOwner); privateQOwner.push_back(ghostOwner);
*/
#pragma omp critical(MSG)
{
QLocalVtx.push_back(v + StartIndex);
QGhostVtx.push_back(w);
QMsgType.push_back(REQUEST);
QOwner.push_back(ghostOwner);
} // end of critical region
if (candidateMate[NLVer + Ghost2LocalMap[w]] == v + StartIndex) if (candidateMate[NLVer + Ghost2LocalMap[w]] == v + StartIndex)
{ {
@ -149,6 +133,8 @@ inline void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
cout << "\n(" << myRank << ")MATCH: (" << v + StartIndex << "," << w << ")"; cout << "\n(" << myRank << ")MATCH: (" << v + StartIndex << "," << w << ")";
fflush(stdout); fflush(stdout);
#endif #endif
//TODO refactor this!!
// Decrement the counter: // Decrement the counter:
// Start: PARALLEL_PROCESS_CROSS_EDGE_B(v) // Start: PARALLEL_PROCESS_CROSS_EDGE_B(v)
#pragma omp critical #pragma omp critical
@ -218,10 +204,11 @@ inline void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
assert(ghostOwner != -1); assert(ghostOwner != -1);
assert(ghostOwner != myRank); assert(ghostOwner != myRank);
PCounter[ghostOwner]++; PCounter[ghostOwner]++;
QLocalVtx.push_back(v + StartIndex);
QGhostVtx.push_back(w); privateQLocalVtx.push_back(v + StartIndex);
QMsgType.push_back(FAILURE); privateQGhostVtx.push_back(w);
QOwner.push_back(ghostOwner); privateQMsgType.push_back(FAILURE);
privateQOwner.push_back(ghostOwner);
} // End of if(GHOST) } // End of if(GHOST)
} // End of for loop } // End of for loop

@ -22,17 +22,17 @@ inline void queuesTransfer(staticQueue &U,
#pragma omp critical(U) #pragma omp critical(U)
{ {
while (!privateU.empty()) while (!privateU.empty())
U.push_back(privateU.pop_front()); U.push_back(privateU.pop_back());
} }
#pragma omp critical(privateMsg) #pragma omp critical(privateMsg)
{ {
while (!privateQLocalVtx.empty()) while (!privateQLocalVtx.empty())
{ {
QLocalVtx.push_back(privateQLocalVtx.pop_front()); QLocalVtx.push_back(privateQLocalVtx.pop_back());
QGhostVtx.push_back(privateQGhostVtx.pop_front()); QGhostVtx.push_back(privateQGhostVtx.pop_back());
QMsgType.push_back(privateQMsgType.pop_front()); QMsgType.push_back(privateQMsgType.pop_back());
QOwner.push_back(privateQOwner.pop_front()); QOwner.push_back(privateQOwner.pop_back());
} }
} }
} }
Loading…
Cancel
Save