PROCESS MATCHED VERTICES parallelization improvement

omp-walther
StefanoPetrilli 2 years ago
parent 2c8dc2ffdd
commit 5bc4f2a080

@ -217,7 +217,7 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
double Ghost2LocalInitialization = MPI_Wtime(); double Ghost2LocalInitialization = MPI_Wtime();
#endif #endif
#pragma omp parallel private(insertMe, k, k1, adj1, adj2, adj11, adj12, heaviestEdgeWt, w, ghostOwner, u, privateU, privateMyCard, isEmpty) firstprivate(StartIndex, EndIndex) default(shared) num_threads(4) #pragma omp parallel private(insertMe, k, u, w, v, k1, adj1, adj2, adj11, adj12, heaviestEdgeWt, ghostOwner, privateU, privateMyCard, isEmpty) firstprivate(StartIndex, EndIndex) default(shared) num_threads(4)
{ {
// TODO comments about the reduction // TODO comments about the reduction
@ -627,11 +627,12 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
privateU.~staticQueue(); privateU.~staticQueue();
new(&privateU) staticQueue(1000); //TODO how can I put a meaningfull size? new(&privateU) staticQueue(1000); //TODO how can I put a meaningfull size?
/*
while ( !U.empty() ) {
u = U.pop_front(); //Get an element from the queue
*/
isEmpty = false; isEmpty = false;
#ifdef COUNT_LOCAL_VERTEX
MilanLongInt localVertices = 0;
#endif
while( true ) while( true )
{ {
@ -647,8 +648,10 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
#endif #endif
if ( (u >= StartIndex) && (u <= EndIndex) ) { //Process Only the Local Vertices if ( (u >= StartIndex) && (u <= EndIndex) ) { //Process Only the Local Vertices
#pragma omp critical #ifdef COUNT_LOCAL_VERTEX
{ localVertices ++;
#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];
@ -656,15 +659,16 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
v = verLocInd[k]; v = verLocInd[k];
if ((v >= StartIndex) && (v <= EndIndex)) { //If Local Vertex: if ((v >= StartIndex) && (v <= EndIndex)) { //If Local Vertex:
#pragma omp critical
if (isAlreadyMatched(v, StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap)) continue; {
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout<<"\n("<<myRank<<")v: "<<v<<" c(v)= "<<candidateMate[v-StartIndex]<<" Mate[v]: "<<Mate[v]; cout<<"\n("<<myRank<<")v: "<<v<<" c(v)= "<<candidateMate[v-StartIndex]<<" Mate[v]: "<<Mate[v];
fflush(stdout); fflush(stdout);
#endif #endif
if (candidateMate[v - StartIndex] == u) { //Only if pointing to the matched vertex if (not isAlreadyMatched(v, StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap) and
candidateMate[v - StartIndex] == u) { //Only if pointing to the matched vertex
//Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) //Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
//Start: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v) //Start: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v)
w = computeCandidateMate(verLocPtr[v - StartIndex], w = computeCandidateMate(verLocPtr[v - StartIndex],
@ -781,8 +785,14 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
} // End of Else: w == -1 } // 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 critical region if
} //End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex: } //End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex:
else { //Neighbor is a ghost vertex else { //Neighbor is a ghost vertex
#pragma omp critical
{
if (candidateMate[NLVer + Ghost2LocalMap[v]] == u) if (candidateMate[NLVer + Ghost2LocalMap[v]] == u)
candidateMate[NLVer + Ghost2LocalMap[v]] = -1; candidateMate[NLVer + Ghost2LocalMap[v]] = -1;
if (v != Mate[u - StartIndex]) { //u is local if (v != Mate[u - StartIndex]) { //u is local
@ -791,16 +801,15 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
//Message[1] = v; //GHOST //Message[1] = v; //GHOST
//Message[2] = SUCCESS; //TYPE //Message[2] = SUCCESS; //TYPE
//Send a Request (Asynchronous) //Send a Request (Asynchronous)
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout<<"\n("<<myRank<<")Sending a success message: "; cout<<"\n("<<myRank<<")Sending a success message: ";
cout<<"\n("<<myRank<<")Ghost is "<<v<<" Owner is: "<<findOwnerOfGhost(v, verDistance, myRank, numProcs)<<"\n"; fflush(stdout); cout<<"\n("<<myRank<<")Ghost is "<<v<<" Owner is: "<<findOwnerOfGhost(v, verDistance, myRank, numProcs)<<"\n"; fflush(stdout);
#endif #endif
/* MPI_Bsend(&Message[0], 3, MPI_INT, inputSubGraph.findOwner(v),
ComputeTag, comm); */
QLocalVtx.push_back(u); QLocalVtx.push_back(u);
QGhostVtx.push_back(v); QGhostVtx.push_back(v);
QMsgType.push_back(SUCCESS); QMsgType.push_back(SUCCESS);
//ghostOwner = inputSubGraph.findOwner(v);
ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs);
assert(ghostOwner != -1); assert(ghostOwner != -1);
assert(ghostOwner != myRank); assert(ghostOwner != myRank);
@ -809,11 +818,9 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
NumMessagesBundled++; NumMessagesBundled++;
msgInd++; msgInd++;
} //End of If( v != Mate[u] ) } //End of If( v != Mate[u] )
} //End of critical region
} //End of Else //A Ghost Vertex } //End of Else //A Ghost Vertex
} //End of For Loop adj(u) } //End of For Loop adj(u)
}
} //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
#pragma omp critical(U) #pragma omp critical(U)
@ -827,8 +834,15 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP(
} //End of while ( /*!Q.empty()*/ !U.empty() ) } //End of while ( /*!Q.empty()*/ !U.empty() )
#ifdef COUNT_LOCAL_VERTEX
printf("Count local vertexes: %ld for thread %d of processor %d\n",
localVertices,
omp_get_thread_num(),
myRank);
#endif
} // end of parallel region } // end of parallel region
///////////////////////// END OF PROCESS MATCHED VERTICES ///////////////////////// ///////////////////////// END OF PROCESS MATCHED VERTICES /////////////////////////
#ifdef DEBUG_HANG_ #ifdef DEBUG_HANG_
if (myRank == 0) cout<<"\n("<<myRank<<") Send Bundles" <<endl; fflush(stdout); if (myRank == 0) cout<<"\n("<<myRank<<") Send Bundles" <<endl; fflush(stdout);

@ -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
00030 ! IDIM; domain size. Linear system size is IDIM**3 00123 ! 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