omp task in clean.cpp, lock destroy

omp-walther
StefanoPetrilli 2 years ago
parent 36bd3a51a2
commit c7e8193514

@ -234,7 +234,8 @@ extern "C"
staticQueue &privateQMsgType, staticQueue &privateQMsgType,
staticQueue &privateQOwner); staticQueue &privateQOwner);
void clean(MilanInt myRank, void clean(MilanLongInt NLVer,
MilanInt myRank,
MilanLongInt MessageIndex, MilanLongInt MessageIndex,
vector<MPI_Request> &SRequest, vector<MPI_Request> &SRequest,
vector<MPI_Status> &SStatus, vector<MPI_Status> &SStatus,
@ -245,7 +246,8 @@ extern "C"
MilanLongInt msgInd, MilanLongInt msgInd,
MilanLongInt *msgIndSent, MilanLongInt *msgIndSent,
MilanLongInt NumMessagesBundled, MilanLongInt NumMessagesBundled,
MilanReal *msgPercent); MilanReal *msgPercent,
omp_lock_t *MateLock);
void PARALLEL_COMPUTE_CANDIDATE_MATE_B(MilanLongInt NLVer, void PARALLEL_COMPUTE_CANDIDATE_MATE_B(MilanLongInt NLVer,
MilanLongInt *verLocPtr, MilanLongInt *verLocPtr,

@ -789,7 +789,8 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
#endif #endif
} // End of while (true) } // End of while (true)
clean(myRank, clean(NLVer,
myRank,
MessageIndex, MessageIndex,
SRequest, SRequest,
SStatus, SStatus,
@ -800,7 +801,8 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
msgInd, msgInd,
msgIndSent, msgIndSent,
NumMessagesBundled, NumMessagesBundled,
msgPercent); msgPercent,
MateLock);
finishTime = MPI_Wtime(); finishTime = MPI_Wtime();
*ph2_time = finishTime - startTime; // Time taken for Phase-2 *ph2_time = finishTime - startTime; // Time taken for Phase-2

@ -1,79 +1,98 @@
#include "MatchBoxPC.h" #include "MatchBoxPC.h"
//TODO comment // TODO comment
//TODO use task // TODO use task
//TODO destroy the locks // TODO destroy the locks
void clean(MilanInt myRank, void clean(MilanLongInt NLVer,
MilanLongInt MessageIndex, MilanInt myRank,
vector<MPI_Request> &SRequest, MilanLongInt MessageIndex,
vector<MPI_Status> &SStatus, vector<MPI_Request> &SRequest,
MilanInt BufferSize, vector<MPI_Status> &SStatus,
MilanLongInt *Buffer, MilanInt BufferSize,
MilanLongInt msgActual, MilanLongInt *Buffer,
MilanLongInt *msgActualSent, MilanLongInt msgActual,
MilanLongInt msgInd, MilanLongInt *msgActualSent,
MilanLongInt *msgIndSent, MilanLongInt msgInd,
MilanLongInt NumMessagesBundled, MilanLongInt *msgIndSent,
MilanReal *msgPercent) MilanLongInt NumMessagesBundled,
MilanReal *msgPercent,
omp_lock_t *MateLock)
{ {
// Cleanup Phase // Cleanup Phase
#pragma omp parallel
{
#pragma omp master
{
#pragma omp task
{
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ") Waitall= " << endl; cout << "\n(" << myRank << ") Waitall= " << endl;
fflush(stdout); fflush(stdout);
#endif #endif
#ifdef DEBUG_HANG_ #ifdef DEBUG_HANG_
cout << "\n(" << myRank << ") Waitall " << endl; cout << "\n(" << myRank << ") Waitall " << endl;
fflush(stdout); fflush(stdout);
#endif #endif
return; return;
MPI_Waitall(MessageIndex, &SRequest[0], &SStatus[0]); MPI_Waitall(MessageIndex, &SRequest[0], &SStatus[0]);
// MPI_Buffer_attach(&Buffer, BufferSize); //Attach the Buffer // MPI_Buffer_attach(&Buffer, BufferSize); //Attach the Buffer
if (BufferSize > 0) if (BufferSize > 0)
{ {
MPI_Buffer_detach(&Buffer, &BufferSize); // Detach the Buffer MPI_Buffer_detach(&Buffer, &BufferSize); // Detach the Buffer
free(Buffer); // Free the memory that was allocated free(Buffer); // Free the memory that was allocated
} }
}
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")End of function to compute matching: " << endl; cout << "\n(" << myRank << ")End of function to compute matching: " << endl;
fflush(stdout); fflush(stdout);
cout << "\n(" << myRank << ")myCardinality: " << myCard << endl; cout << "\n(" << myRank << ")myCardinality: " << myCard << endl;
fflush(stdout); fflush(stdout);
cout << "\n(" << myRank << ")Matching took " << finishTime - startTime << "seconds" << endl; cout << "\n(" << myRank << ")Matching took " << finishTime - startTime << "seconds" << endl;
fflush(stdout); fflush(stdout);
cout << "\n(" << myRank << ")** Getting out of the matching function **" << endl; cout << "\n(" << myRank << ")** Getting out of the matching function **" << endl;
fflush(stdout); fflush(stdout);
#endif #endif
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ") Number of Ghost edges = " << numGhostEdges; cout << "\n(" << myRank << ") Number of Ghost edges = " << numGhostEdges;
cout << "\n(" << myRank << ") Total number of potential message X 2 = " << numGhostEdges * 2; cout << "\n(" << myRank << ") Total number of potential message X 2 = " << numGhostEdges * 2;
cout << "\n(" << myRank << ") Number messages bundled = " << NumMessagesBundled; cout << "\n(" << myRank << ") Number messages bundled = " << NumMessagesBundled;
cout << "\n(" << myRank << ") Total Individual Messages sent = " << msgInd; cout << "\n(" << myRank << ") Total Individual Messages sent = " << msgInd;
if (msgInd > 0) if (msgInd > 0)
{ {
cout << "\n(" << myRank << ") Percentage of messages bundled = " << ((double)NumMessagesBundled / (double)(msgInd)) * 100.0 << "% \n"; cout << "\n(" << myRank << ") Percentage of messages bundled = " << ((double)NumMessagesBundled / (double)(msgInd)) * 100.0 << "% \n";
} }
fflush(stdout); fflush(stdout);
#endif #endif
*msgActualSent = msgActual; #pragma omp task
*msgIndSent = msgInd; {
if (msgInd > 0) *msgActualSent = msgActual;
{ *msgIndSent = msgInd;
*msgPercent = ((double)NumMessagesBundled / (double)(msgInd)) * 100.0; if (msgInd > 0)
} {
else *msgPercent = ((double)NumMessagesBundled / (double)(msgInd)) * 100.0;
{ }
*msgPercent = 0; else
} {
*msgPercent = 0;
}
}
// Destroy the locks
#pragma omp taskloop num_tasks(NUM_THREAD)
for (int i = 0; i < NLVer; i++)
omp_destroy_lock(&MateLock[i]);
#ifdef DEBUG_HANG_ #ifdef DEBUG_HANG_
if (myRank == 0) if (myRank == 0)
cout << "\n(" << myRank << ") Done" << endl; cout << "\n(" << myRank << ") Done" << endl;
fflush(stdout); fflush(stdout);
#endif #endif
}
}
} }
Loading…
Cancel
Save