Merge branch 'PolySmooth' of github.com:sfilippone/amg4psblas into PolySmooth

PolySmooth
sfilippone 7 months ago
commit 322e3f65d1

@ -62,24 +62,16 @@ 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)) { if (isAlreadyMatched(verLocInd[k], StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap)) {
w = computeCandidateMate(verLocPtr[v], w = computeCandidateMate(verLocPtr[v], verLocPtr[v + 1], edgeLocWeight, 0,
verLocPtr[v + 1], verLocInd, StartIndex, EndIndex,
edgeLocWeight, 0, GMate, Mate, Ghost2LocalMap);
verLocInd,
StartIndex,
EndIndex,
GMate,
Mate,
Ghost2LocalMap);
candidateMate[v] = w; candidateMate[v] = w;
} }
}
if (w >= 0) { if (w >= 0) {
(*myCard)++; (*myCard)++;
if ((w < StartIndex) || (w > EndIndex)) { // w is a ghost vertex if ((w < StartIndex) || (w > EndIndex)) { // w is a ghost vertex
@ -88,32 +80,23 @@ void PARALLEL_PROCESS_EXPOSED_VERTEX_B(MilanLongInt NLVer,
option = 1; option = 1;
Mate[v] = w; Mate[v] = w;
GMate[Ghost2LocalMap[w]] = v + StartIndex; // w is a Ghost GMate[Ghost2LocalMap[w]] = v + StartIndex; // w is a Ghost
} // 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 { // w is a local vertex else { // w is a local vertex
if (candidateMate[w - StartIndex] == (v + StartIndex)) { if (candidateMate[w - StartIndex] == (v + StartIndex)) {
option = 3; option = 3;
Mate[v] = w; // v is local Mate[v] = w; // v is local
Mate[w - StartIndex] = v + StartIndex; // w 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);
@ -171,6 +155,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);

@ -91,20 +91,19 @@ void processMatchedVertices(
if (mateVal < 0) { if (mateVal < 0) {
#pragma omp critical #pragma omp critical
{ {
#pragma omp atomic read
mateVal = Mate[v - StartIndex];
// If the current vertex is pointing to a matched vertex and is not matched
if (mateVal < 0) {
if (candidateMate[v - StartIndex] == u) { if (candidateMate[v - StartIndex] == u) {
// Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) // Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
w = computeCandidateMate(verLocPtr[v - StartIndex], w = computeCandidateMate(verLocPtr[v - StartIndex],
verLocPtr[v - StartIndex + 1], verLocPtr[v - StartIndex + 1],
edgeLocWeight, 0, edgeLocWeight, 0,
verLocInd, verLocInd, StartIndex, EndIndex,
StartIndex, GMate, Mate, Ghost2LocalMap);
EndIndex,
GMate,
Mate,
Ghost2LocalMap);
candidateMate[v - StartIndex] = w; candidateMate[v - StartIndex] = w;
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")" << v << " Points to: " << w; cout << "\n(" << myRank << ")" << v << " Points to: " << w;
fflush(stdout); fflush(stdout);
@ -142,6 +141,7 @@ void processMatchedVertices(
option = 4; // End of Else: w == -1 option = 4; // End of Else: w == -1
// End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) // End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
} // End of If (candidateMate[v-StartIndex] == u } // End of If (candidateMate[v-StartIndex] == u
}
} // End of task } // End of task
} // mateval < 0 } // mateval < 0
} // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex: } // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex:
@ -179,6 +179,7 @@ void processMatchedVertices(
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]++;
(*NumMessagesBundled)++; (*NumMessagesBundled)++;
(*msgInd)++; (*msgInd)++;
@ -211,7 +212,7 @@ void processMatchedVertices(
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]++;
(*NumMessagesBundled)++; (*NumMessagesBundled)++;
(*msgInd)++; (*msgInd)++;
@ -248,7 +249,6 @@ void processMatchedVertices(
break; break;
} // End of switch } // End of switch
} // End of inner for } // End of inner for
} }
} // End of outer for } // End of outer for
@ -265,17 +265,15 @@ void processMatchedVertices(
U.insert(U.end(), privateU.begin(), privateU.end()); U.insert(U.end(), privateU.begin(), privateU.end());
} }
privateU.clear();
#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());
QOwner.insert(QOwner.end(), privateQOwner.begin(), privateQOwner.end()); QOwner.insert(QOwner.end(), privateQOwner.begin(), privateQOwner.end());
} }
privateU.clear();
privateQLocalVtx.clear(); privateQLocalVtx.clear();
privateQGhostVtx.clear(); privateQGhostVtx.clear();
privateQMsgType.clear(); privateQMsgType.clear();

@ -77,7 +77,6 @@ void processMatchedVerticesAndSendMessages(
#ifdef COUNT_LOCAL_VERTEX #ifdef COUNT_LOCAL_VERTEX
localVertices++; localVertices++;
#endif #endif
// Get the Adjacency list for u // Get the Adjacency list for u
adj1 = verLocPtr[u - StartIndex]; // Pointer adj1 = verLocPtr[u - StartIndex]; // Pointer
adj2 = verLocPtr[u - StartIndex + 1]; adj2 = verLocPtr[u - StartIndex + 1];
@ -97,20 +96,19 @@ void processMatchedVerticesAndSendMessages(
if (mateVal < 0) { if (mateVal < 0) {
#pragma omp critical #pragma omp critical
{ {
#pragma omp atomic read
mateVal = Mate[v - StartIndex];
// If the current vertex is pointing to a matched vertex and is not matched
if (mateVal < 0) {
if (candidateMate[v - StartIndex] == u) { if (candidateMate[v - StartIndex] == u) {
// Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) // Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
w = computeCandidateMate(verLocPtr[v - StartIndex], w = computeCandidateMate(verLocPtr[v - StartIndex],
verLocPtr[v - StartIndex + 1], verLocPtr[v - StartIndex + 1],
edgeLocWeight, 0, edgeLocWeight, 0,
verLocInd, verLocInd, StartIndex, EndIndex,
StartIndex, GMate, Mate, Ghost2LocalMap);
EndIndex,
GMate,
Mate,
Ghost2LocalMap);
candidateMate[v - StartIndex] = w; candidateMate[v - StartIndex] = w;
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")" << v << " Points to: " << w; cout << "\n(" << myRank << ")" << v << " Points to: " << w;
fflush(stdout); fflush(stdout);
@ -137,7 +135,6 @@ void processMatchedVerticesAndSendMessages(
option = 3; option = 3;
Mate[v - StartIndex] = w; // v is a local vertex Mate[v - StartIndex] = w; // v is a local vertex
Mate[w - StartIndex] = v; // w is a local vertex Mate[w - StartIndex] = v; // w is a local vertex
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") "; cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") ";
fflush(stdout); fflush(stdout);
@ -149,6 +146,7 @@ void processMatchedVerticesAndSendMessages(
option = 4; // End of Else: w == -1 option = 4; // End of Else: w == -1
// End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) // End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
} // End of If (candidateMate[v-StartIndex] == u } // End of If (candidateMate[v-StartIndex] == u
}
} // End of task } // End of task
} // mateval < 0 } // mateval < 0
} // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex: } // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex:
@ -211,15 +209,12 @@ void processMatchedVerticesAndSendMessages(
for (k1 = adj11; k1 < adj12; k1++) { for (k1 = adj11; k1 < adj12; k1++) {
w = verLocInd[k1]; w = verLocInd[k1];
if ((w < StartIndex) || (w > EndIndex)) { // A ghost if ((w < StartIndex) || (w > EndIndex)) { // A ghost
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Sending a failure message: "; cout << "\n(" << myRank << ")Sending a failure message: ";
cout << "\n(" << myRank << ")Ghost is " << w << " Owner is: " << findOwnerOfGhost(w, verDistance, myRank, numProcs); cout << "\n(" << myRank << ")Ghost is " << w << " Owner is: " << findOwnerOfGhost(w, verDistance, myRank, numProcs);
fflush(stdout); fflush(stdout);
#endif #endif
ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs);
// Build the Message Packet: // Build the Message Packet:
// Message[0] = v; // LOCAL // Message[0] = v; // LOCAL
// Message[1] = w; // GHOST // Message[1] = w; // GHOST
@ -229,7 +224,6 @@ void processMatchedVerticesAndSendMessages(
(*msgActual)++; (*msgActual)++;
(*msgInd)++; (*msgInd)++;
privateQLocalVtx.push_back(v); privateQLocalVtx.push_back(v);
privateQGhostVtx.push_back(w); privateQGhostVtx.push_back(w);
privateQMsgType.push_back(FAILURE); privateQMsgType.push_back(FAILURE);
@ -248,17 +242,14 @@ void processMatchedVerticesAndSendMessages(
#endif #endif
ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs);
// Build the Message Packet: // Build the Message Packet:
// Message[0] = u; // LOCAL // Message[0] = u; // LOCAL
// Message[1] = v; // GHOST // Message[1] = v; // GHOST
// Message[2] = SUCCESS; // TYPE // Message[2] = SUCCESS; // TYPE
// Send a Request (Asynchronous) // Send a Request (Asynchronous)
// MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm); // MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm);
(*msgActual)++; (*msgActual)++;
(*msgInd)++; (*msgInd)++;
privateQLocalVtx.push_back(u); privateQLocalVtx.push_back(u);
privateQGhostVtx.push_back(v); privateQGhostVtx.push_back(v);
privateQMsgType.push_back(SUCCESS); privateQMsgType.push_back(SUCCESS);
@ -281,10 +272,7 @@ void processMatchedVerticesAndSendMessages(
#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",
localVertices, localVertices, mp_get_thread_num(), myRank);
omp_get_thread_num(),
myRank);
#endif #endif
} // End of parallel region } // End of parallel region
@ -293,12 +281,10 @@ void processMatchedVerticesAndSendMessages(
cout << myRank<<" Sending: "<<QOwner.size()-initialSize<<" messages" <<endl; cout << myRank<<" Sending: "<<QOwner.size()-initialSize<<" messages" <<endl;
#endif #endif
for (int i = initialSize; i < QOwner.size(); i++) { for (int i = initialSize; i < QOwner.size(); i++) {
Message[0] = QLocalVtx[i]; Message[0] = QLocalVtx[i];
Message[1] = QGhostVtx[i]; Message[1] = QGhostVtx[i];
Message[2] = QMsgType[i]; Message[2] = QMsgType[i];
ghostOwner = QOwner[i]; ghostOwner = QOwner[i];
//MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm); //MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm);
//cout << myRank<<" Sending to "<<ghostOwner<<endl; //cout << myRank<<" Sending to "<<ghostOwner<<endl;
MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm); MPI_Bsend(&Message[0], 3, TypeMap<MilanLongInt>(), ghostOwner, ComputeTag, comm);

@ -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