Additional OpenMP tinkering in matchboxp

PolySmooth
sfilippone 5 months ago
parent 897c5229a6
commit bd2d1e3b26

@ -62,58 +62,41 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
fflush(stdout); fflush(stdout);
#endif #endif
// If found a dominating edge: // If found a dominating edge:
if (w >= 0) if (w >= 0) {
{ #pragma omp critical(Matching)
{
#pragma omp critical(processExposed) if (isAlreadyMatched(verLocInd[k], StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap)) {
{ w = computeCandidateMate(verLocPtr[v], verLocPtr[v + 1], edgeLocWeight, 0,
if (isAlreadyMatched(verLocInd[k], StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap)) { verLocInd, StartIndex, EndIndex,
w = computeCandidateMate(verLocPtr[v], GMate, Mate, Ghost2LocalMap);
verLocPtr[v + 1], candidateMate[v] = w;
edgeLocWeight, 0, }
verLocInd, }
StartIndex, if (w >= 0) {
EndIndex, (*myCard)++;
GMate, if ((w < StartIndex) || (w > EndIndex)) { // w is a ghost vertex
Mate, option = 2;
Ghost2LocalMap); if (candidateMate[NLVer + Ghost2LocalMap[w]] == v + StartIndex) {
candidateMate[v] = w; option = 1;
} Mate[v] = w;
GMate[Ghost2LocalMap[w]] = v + StartIndex; // w is a Ghost
if (w >= 0) { } // End of if CandidateMate[w] = v
(*myCard)++; } // End of if a Ghost Vertex
if ((w < StartIndex) || (w > EndIndex)) { // w is a ghost vertex else { // w is a local vertex
option = 2; if (candidateMate[w - StartIndex] == (v + StartIndex)) {
if (candidateMate[NLVer + Ghost2LocalMap[w]] == v + StartIndex) { option = 3;
option = 1; Mate[v] = w; // v is local
Mate[v] = w; Mate[w - StartIndex] = v + StartIndex; // w is local
GMate[Ghost2LocalMap[w]] = v + StartIndex; // w is a Ghost
} // End of if CandidateMate[w] = v
} // End of if a Ghost Vertex
else { // w is a local vertex
if (candidateMate[w - StartIndex] == (v + StartIndex)) {
option = 3;
Mate[v] = w; // v is local
Mate[w - StartIndex] = v + StartIndex; // w is local
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")MATCH: (" << v + StartIndex << "," << w << ") "; cout << "\n(" << myRank << ")MATCH: (" << v + StartIndex << "," << w << ") ";
fflush(stdout); fflush(stdout);
#endif #endif
} // End of if ( candidateMate[w-StartIndex] == (v+StartIndex) )
} // End of if ( candidateMate[w-StartIndex] == (v+StartIndex) ) } // End of Else
} // End of Else } // End of second if
} // End of second if
} // End critical processExposed
} // End of if(w >=0) } // End of if(w >=0)
else { else {
#pragma omp critical(adjuse) //#pragma omp critical(adjuse)
{ {
// This piece of code is executed a really small number of times // This piece of code is executed a really small number of times
adj11 = verLocPtr[v]; adj11 = verLocPtr[v];
@ -132,6 +115,7 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs);
// assert(ghostOwner != -1); // assert(ghostOwner != -1);
// assert(ghostOwner != myRank); // assert(ghostOwner != myRank);
#pragma omp atomic
PCounter[ghostOwner]++; PCounter[ghostOwner]++;
privateQLocalVtx.push_back(v + StartIndex); privateQLocalVtx.push_back(v + StartIndex);
@ -144,23 +128,23 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
} }
} }
// End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) // End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
switch (option) switch (option)
{ {
case -1: case -1:
break; break;
case 1: case 1:
privateU.push_back(v + StartIndex); privateU.push_back(v + StartIndex);
privateU.push_back(w); privateU.push_back(w);
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")MATCH: (" << v + StartIndex << "," << w << ")"; cout << "\n(" << myRank << ")MATCH: (" << v + StartIndex << "," << w << ")";
fflush(stdout); fflush(stdout);
#endif #endif
// Decrement the counter: // Decrement the counter:
PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[w]], S); PROCESS_CROSS_EDGE(&Counter[Ghost2LocalMap[w]], S);
case 2: case 2:
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Sending a request message (291):"; cout << "\n(" << myRank << ")Sending a request message (291):";
cout << "\n(" << myRank << ")Local is: " << v + StartIndex << " Ghost is " << w << " Owner is: " << findOwnerOfGhost(w, verDistance, myRank, numProcs) << endl; cout << "\n(" << myRank << ")Local is: " << v + StartIndex << " Ghost is " << w << " Owner is: " << findOwnerOfGhost(w, verDistance, myRank, numProcs) << endl;
@ -171,29 +155,30 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs);
// assert(ghostOwner != -1); // assert(ghostOwner != -1);
// assert(ghostOwner != myRank); // assert(ghostOwner != myRank);
#pragma omp atomic
PCounter[ghostOwner]++; PCounter[ghostOwner]++;
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);
break; break;
case 3: case 3:
default: default:
privateU.push_back(v + StartIndex); privateU.push_back(v + StartIndex);
privateU.push_back(w); privateU.push_back(w);
break; break;
} }
} // End of for ( v=0; v < NLVer; v++ ) } // End of for ( v=0; v < NLVer; v++ )
queuesTransfer(U, privateU, QLocalVtx, queuesTransfer(U, privateU, QLocalVtx,
QGhostVtx, QGhostVtx,
QMsgType, QOwner, privateQLocalVtx, QMsgType, QOwner, privateQLocalVtx,
privateQGhostVtx, privateQGhostVtx,
privateQMsgType, privateQMsgType,
privateQOwner); privateQOwner);
} // End of parallel region } // End of parallel region
} }
#endif #endif

@ -15,11 +15,9 @@ void queuesTransfer(vector<MilanLongInt> &U,
#pragma omp critical(U) #pragma omp critical(U)
{ {
U.insert(U.end(), privateU.begin(), privateU.end()); U.insert(U.end(), privateU.begin(), privateU.end());
}
#pragma omp critical(sendMessageTransfer)
{
//#pragma omp critical(sendMessageTransfer)
//{
QLocalVtx.insert(QLocalVtx.end(), privateQLocalVtx.begin(), privateQLocalVtx.end()); QLocalVtx.insert(QLocalVtx.end(), privateQLocalVtx.begin(), privateQLocalVtx.end());
QGhostVtx.insert(QGhostVtx.end(), privateQGhostVtx.begin(), privateQGhostVtx.end()); QGhostVtx.insert(QGhostVtx.end(), privateQGhostVtx.begin(), privateQGhostVtx.end());
QMsgType.insert(QMsgType.end(), privateQMsgType.begin(), privateQMsgType.end()); QMsgType.insert(QMsgType.end(), privateQMsgType.begin(), privateQMsgType.end());

Loading…
Cancel
Save