diff --git a/amgprec/impl/aggregator/MatchBoxPC.h b/amgprec/impl/aggregator/MatchBoxPC.h index dfcb6f7e..0b3dcd74 100644 --- a/amgprec/impl/aggregator/MatchBoxPC.h +++ b/amgprec/impl/aggregator/MatchBoxPC.h @@ -234,7 +234,8 @@ extern "C" staticQueue &privateQMsgType, staticQueue &privateQOwner); - void clean(MilanInt myRank, + void clean(MilanLongInt NLVer, + MilanInt myRank, MilanLongInt MessageIndex, vector &SRequest, vector &SStatus, @@ -245,7 +246,8 @@ extern "C" MilanLongInt msgInd, MilanLongInt *msgIndSent, MilanLongInt NumMessagesBundled, - MilanReal *msgPercent); + MilanReal *msgPercent, + omp_lock_t *MateLock); void PARALLEL_COMPUTE_CANDIDATE_MATE_B(MilanLongInt NLVer, MilanLongInt *verLocPtr, diff --git a/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp b/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp index 50930601..e45ee792 100644 --- a/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp +++ b/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp @@ -789,7 +789,8 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( #endif } // End of while (true) - clean(myRank, + clean(NLVer, + myRank, MessageIndex, SRequest, SStatus, @@ -800,7 +801,8 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( msgInd, msgIndSent, NumMessagesBundled, - msgPercent); + msgPercent, + MateLock); finishTime = MPI_Wtime(); *ph2_time = finishTime - startTime; // Time taken for Phase-2 diff --git a/amgprec/impl/aggregator/clean.cpp b/amgprec/impl/aggregator/clean.cpp index 5204894a..d91076c9 100644 --- a/amgprec/impl/aggregator/clean.cpp +++ b/amgprec/impl/aggregator/clean.cpp @@ -1,79 +1,98 @@ #include "MatchBoxPC.h" -//TODO comment -//TODO use task -//TODO destroy the locks +// TODO comment +// TODO use task +// TODO destroy the locks -void clean(MilanInt myRank, - MilanLongInt MessageIndex, - vector &SRequest, - vector &SStatus, - MilanInt BufferSize, - MilanLongInt *Buffer, - MilanLongInt msgActual, - MilanLongInt *msgActualSent, - MilanLongInt msgInd, - MilanLongInt *msgIndSent, - MilanLongInt NumMessagesBundled, - MilanReal *msgPercent) +void clean(MilanLongInt NLVer, + MilanInt myRank, + MilanLongInt MessageIndex, + vector &SRequest, + vector &SStatus, + MilanInt BufferSize, + MilanLongInt *Buffer, + MilanLongInt msgActual, + MilanLongInt *msgActualSent, + MilanLongInt msgInd, + MilanLongInt *msgIndSent, + MilanLongInt NumMessagesBundled, + MilanReal *msgPercent, + omp_lock_t *MateLock) { // Cleanup Phase +#pragma omp parallel + { +#pragma omp master + { +#pragma omp task + { + #ifdef PRINT_DEBUG_INFO_ - cout << "\n(" << myRank << ") Waitall= " << endl; - fflush(stdout); + cout << "\n(" << myRank << ") Waitall= " << endl; + fflush(stdout); #endif #ifdef DEBUG_HANG_ - cout << "\n(" << myRank << ") Waitall " << endl; - fflush(stdout); + cout << "\n(" << myRank << ") Waitall " << endl; + fflush(stdout); #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 - if (BufferSize > 0) - { - MPI_Buffer_detach(&Buffer, &BufferSize); // Detach the Buffer - free(Buffer); // Free the memory that was allocated - } + // MPI_Buffer_attach(&Buffer, BufferSize); //Attach the Buffer + if (BufferSize > 0) + { + MPI_Buffer_detach(&Buffer, &BufferSize); // Detach the Buffer + free(Buffer); // Free the memory that was allocated + } + } #ifdef PRINT_DEBUG_INFO_ - cout << "\n(" << myRank << ")End of function to compute matching: " << endl; - fflush(stdout); - cout << "\n(" << myRank << ")myCardinality: " << myCard << endl; - fflush(stdout); - cout << "\n(" << myRank << ")Matching took " << finishTime - startTime << "seconds" << endl; - fflush(stdout); - cout << "\n(" << myRank << ")** Getting out of the matching function **" << endl; - fflush(stdout); + cout << "\n(" << myRank << ")End of function to compute matching: " << endl; + fflush(stdout); + cout << "\n(" << myRank << ")myCardinality: " << myCard << endl; + fflush(stdout); + cout << "\n(" << myRank << ")Matching took " << finishTime - startTime << "seconds" << endl; + fflush(stdout); + cout << "\n(" << myRank << ")** Getting out of the matching function **" << endl; + fflush(stdout); #endif #ifdef PRINT_DEBUG_INFO_ - cout << "\n(" << myRank << ") Number of Ghost edges = " << numGhostEdges; - cout << "\n(" << myRank << ") Total number of potential message X 2 = " << numGhostEdges * 2; - cout << "\n(" << myRank << ") Number messages bundled = " << NumMessagesBundled; - cout << "\n(" << myRank << ") Total Individual Messages sent = " << msgInd; - if (msgInd > 0) - { - cout << "\n(" << myRank << ") Percentage of messages bundled = " << ((double)NumMessagesBundled / (double)(msgInd)) * 100.0 << "% \n"; - } - fflush(stdout); + cout << "\n(" << myRank << ") Number of Ghost edges = " << numGhostEdges; + cout << "\n(" << myRank << ") Total number of potential message X 2 = " << numGhostEdges * 2; + cout << "\n(" << myRank << ") Number messages bundled = " << NumMessagesBundled; + cout << "\n(" << myRank << ") Total Individual Messages sent = " << msgInd; + if (msgInd > 0) + { + cout << "\n(" << myRank << ") Percentage of messages bundled = " << ((double)NumMessagesBundled / (double)(msgInd)) * 100.0 << "% \n"; + } + fflush(stdout); #endif - *msgActualSent = msgActual; - *msgIndSent = msgInd; - if (msgInd > 0) - { - *msgPercent = ((double)NumMessagesBundled / (double)(msgInd)) * 100.0; - } - else - { - *msgPercent = 0; - } +#pragma omp task + { + *msgActualSent = msgActual; + *msgIndSent = msgInd; + if (msgInd > 0) + { + *msgPercent = ((double)NumMessagesBundled / (double)(msgInd)) * 100.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_ - if (myRank == 0) - cout << "\n(" << myRank << ") Done" << endl; - fflush(stdout); + if (myRank == 0) + cout << "\n(" << myRank << ") Done" << endl; + fflush(stdout); #endif + } + } } \ No newline at end of file