Further improved critical region U

omp-walther
StefanoPetrilli 2 years ago
parent b2230a6d6d
commit bf35c1659b

@ -72,6 +72,8 @@
Statistics: ph1_card, ph2_card : Size: |P| number of processes in the comm-world (number of matched edges in Phase 1 and Phase 2) Statistics: ph1_card, ph2_card : Size: |P| number of processes in the comm-world (number of matched edges in Phase 1 and Phase 2)
*/ */
#define UCHUNK 1000
#ifdef SERIAL_MPI #ifdef SERIAL_MPI
#else #else
//MPI type map //MPI type map
@ -658,16 +660,34 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
MilanLongInt localVertices = 0; MilanLongInt localVertices = 0;
#endif #endif
while( true ) //TODO what would be the optimal UCHUNK
{ vector <MilanLongInt> Us;
Us.reserve(UCHUNK);
while( true ) {
Us.clear();
#pragma omp critical(U) #pragma omp critical(U)
{ {
if (U.empty()) isEmpty = true; //If U is emptu and there are no new node to add to U
else u = U.pop_front(); if (U.empty() && privateU.empty())
isEmpty = true;
else {
if (U.empty() && !privateU.empty()) // If U is empty but there are nodes in private U
while (!privateU.empty()) {
U.push_back(privateU.pop_front());
myCard += privateMyCard;
}
for (int i = 0; i < UCHUNK; i++) { // Pop the new nodes
if (U.empty()) break;
Us.push_back(U.pop_front());
}
}
} // End of critical U } // End of critical U
if (isEmpty) break; if (isEmpty) break;
for (MilanLongInt u : Us)
{
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout<<"\n("<<myRank<<")u: "<<u; fflush(stdout); cout<<"\n("<<myRank<<")u: "<<u; fflush(stdout);
#endif #endif
@ -847,7 +867,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
} //End of if ( (u >= StartIndex) && (u <= EndIndex) ) //Process Only If a Local Vertex } //End of if ( (u >= StartIndex) && (u <= EndIndex) ) //Process Only If a Local Vertex
//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.empty()) continue; if (privateU.size() < UCHUNK && !U.empty()) continue;
#pragma omp critical(U) #pragma omp critical(U)
{ {
while (!privateU.empty()) { while (!privateU.empty()) {
@ -856,6 +876,8 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
myCard += privateMyCard; myCard += privateMyCard;
} //End of critical U } //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(privateMsg)

@ -1,6 +1,6 @@
%%%%%%%%%%% General arguments % Lines starting with % are ignored. %%%%%%%%%%% General arguments % Lines starting with % are ignored.
CSR ! Storage format CSR COO JAD CSR ! Storage format CSR COO JAD
0123 ! IDIM; domain size. Linear system size is IDIM**3 0080 ! IDIM; domain size. Linear system size is IDIM**3
CONST ! PDECOEFF: CONST, EXP, GAUSS Coefficients of the PDE CONST ! PDECOEFF: CONST, EXP, GAUSS Coefficients of the PDE
BICGSTAB ! Iterative method: BiCGSTAB BiCGSTABL BiCG CG CGS FCG GCR RGMRES BICGSTAB ! Iterative method: BiCGSTAB BiCGSTABL BiCG CG CGS FCG GCR RGMRES
2 ! ISTOPC 2 ! ISTOPC

Loading…
Cancel
Save