diff --git a/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp b/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp index f232cfa2..27014cca 100644 --- a/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp +++ b/amgprec/impl/aggregator/algoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP.cpp @@ -204,23 +204,25 @@ void dalgoDistEdgeApproxDomEdgesLinearSearchMesgBndlSmallMateCMP( vector verGhostPtr, verGhostInd, tempCounter; //Mate array for ghost vertices: vector GMate; //Proportional to the number of ghost vertices - + MilanLongInt S; + staticQueue U; #ifdef TIME_TRACKER double Ghost2LocalInitialization = MPI_Wtime(); #endif - -#pragma omp parallel private(insertMe, k, adj1, adj2) firstprivate(StartIndex, EndIndex) default(shared) num_threads(4) +#pragma omp parallel private(insertMe, k, adj1, adj2, heaviestEdgeWt) firstprivate(StartIndex, EndIndex) default(shared) num_threads(4) { -#pragma omp for + // TODO comments about the fking reduction + +#pragma omp for reduction(+ : numGhostEdges) for (i = 0; i < NLEdge; i++) { //O(m) - Each edge stored twice insertMe = verLocInd[i]; //cout<<"InsertMe on Process "< EndIndex)) { //Find a ghost + numGhostEdges++; #pragma omp critical { - numGhostEdges++; storedAlready = Ghost2LocalMap.find(insertMe); if (storedAlready != Ghost2LocalMap.end()) { //Has already been added //cout<<"Process "<first<<" - "<second< 0 ) - cout< 0 ) + cout< EndIndex) ) { //Find a ghost + + //TODO why the nowait here fails? + +#pragma omp for nowait + for (v = 0; v < NLVer; v++) { + adj1 = verLocPtr[v]; //Vertex Pointer + adj2 = verLocPtr[v + 1]; + for (k = adj1; k < adj2; k++) { + w = verLocInd[k]; //Get the adjacent vertex + if ((w < StartIndex) || (w > EndIndex)) { //Find a ghost #pragma omp critical - { - insertMe = verGhostPtr[Ghost2LocalMap[w]] + tempCounter[Ghost2LocalMap[w]]; //Where to insert - verGhostInd[insertMe] = v + StartIndex; //Add the adjacency - tempCounter[Ghost2LocalMap[w]]++; //Increment the counter - } - } //End of if((w < StartIndex) || (w > EndIndex)) - } //End of for(k) - } //End of for (v) - tempCounter.clear(); //Do not need this any more + { + insertMe = verGhostPtr[Ghost2LocalMap[w]] + tempCounter[Ghost2LocalMap[w]]; //Where to insert + verGhostInd[insertMe] = v + StartIndex; //Add the adjacency + tempCounter[Ghost2LocalMap[w]]++; //Increment the counter + } + } //End of if((w < StartIndex) || (w > EndIndex)) + } //End of for(k) + } //End of for (v) #pragma omp single { #ifdef TIME_TRACKER - verGhostIndInitialization = MPI_Wtime() - verGhostIndInitialization; - fprintf(stderr, "verGhostIndInitialization time: %f\n", verGhostIndInitialization); + verGhostIndInitialization = MPI_Wtime() - verGhostIndInitialization; + fprintf(stderr, "verGhostIndInitialization time: %f\n", verGhostIndInitialization); #endif #ifdef PRINT_DEBUG_INFO_ - cout<<"\n("<EndIndex) ) { //Is it a ghost vertex? - if(GMate[Ghost2LocalMap[verLocInd[k]]] >= 0 )// Already matched + for (k = adj1; k < adj2; k++) { + if ((verLocInd[k] < StartIndex) || (verLocInd[k] > EndIndex)) { //Is it a ghost vertex? + if (GMate[Ghost2LocalMap[verLocInd[k]]] >= 0)// Already matched continue; } else { //A local vertex - if( Mate[verLocInd[k]-StartIndex] >= 0 ) // Already matched + if (Mate[verLocInd[k] - StartIndex] >= 0) // Already matched continue; } - if( (edgeLocWeight[k] > heaviestEdgeWt) || - ((edgeLocWeight[k] == heaviestEdgeWt)&&(w < verLocInd[k])) ) { + if ((edgeLocWeight[k] > heaviestEdgeWt) || + ((edgeLocWeight[k] == heaviestEdgeWt) && (w < verLocInd[k]))) { heaviestEdgeWt = edgeLocWeight[k]; w = verLocInd[k]; } } //End of for loop candidateMate[v] = w; + // } - //End: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v) -#ifdef PRINT_DEBUG_INFO_ - cout<<"\n("<= 0 ) { - if ( (w < StartIndex) || (w > EndIndex) ) { //w is a ghost vertex - //Build the Message Packet: - //Message[0] = v+StartIndex; //LOCAL - //Message[1] = w; //GHOST - //Message[2] = REQUEST; //TYPE - //Send a Request (Asynchronous) -#ifdef PRINT_DEBUG_INFO_ - cout<<"\n("< 0 ) { - Counter[Ghost2LocalMap[w]] = Counter[Ghost2LocalMap[w]] - 1; //Decrement - if ( Counter[Ghost2LocalMap[w]] == 0 ) { - S--; //Decrement S + /* + for ( v=0; v < NLVer; v++ ) { #ifdef PRINT_DEBUG_INFO_ - cout<<"\n("< 0 - //End: PARALLEL_PROCESS_CROSS_EDGE_B(v) - } //End of if CandidateMate[w] = v - } //End of if a Ghost Vertex - else { // w is a local vertex - if ( candidateMate[w-StartIndex] == (v+StartIndex) ) { - Mate[v] = w; //v is local - Mate[w-StartIndex] = v+StartIndex; //w is local - //Q.push_back(u); - U.push_back(v+StartIndex); - U.push_back(w); - myCard++; -#ifdef PRINT_DEBUG_INFO_ - cout<<"\n("<=0) - else { - adj11 = verLocPtr[v]; - adj12 = verLocPtr[v+1]; - for( k1 = adj11; k1 < adj12; k1++ ) { - w = verLocInd[k1]; - if ( (w < StartIndex) || (w > EndIndex) ) { //A ghost + //Start: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) + //Start: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v) + adj1 = verLocPtr[v]; + adj2 = verLocPtr[v + 1]; + w = candidateMate[v]; +*/ +//#pragma omp critical + // { + //End: PARALLEL_COMPUTE_CANDIDATE_MATE_B(v) +#ifdef PRINT_DEBUG_INFO_ + cout<<"\n("<= 0) { + if ((w < StartIndex) || (w > EndIndex)) { //w is a ghost vertex //Build the Message Packet: //Message[0] = v+StartIndex; //LOCAL //Message[1] = w; //GHOST - //Message[2] = FAILURE; //TYPE + //Message[2] = REQUEST; //TYPE //Send a Request (Asynchronous) #ifdef PRINT_DEBUG_INFO_ - cout<<"\n("< 0) { + Counter[Ghost2LocalMap[w]] = Counter[Ghost2LocalMap[w]] - 1; //Decrement + if (Counter[Ghost2LocalMap[w]] == 0) { + S--; //Decrement S +#ifdef PRINT_DEBUG_INFO_ + cout<<"\n("< 0 + //End: PARALLEL_PROCESS_CROSS_EDGE_B(v) + } //End of if CandidateMate[w] = v + } //End of if a Ghost Vertex + else { // w is a local vertex + if (candidateMate[w - StartIndex] == (v + StartIndex)) { + Mate[v] = w; //v is local + Mate[w - StartIndex] = v + StartIndex; //w is local + //Q.push_back(u); + U.push_back(v + StartIndex); + U.push_back(w); + myCard++; +#ifdef PRINT_DEBUG_INFO_ + cout<<"\n("<=0) + else { + adj11 = verLocPtr[v]; + adj12 = verLocPtr[v + 1]; + for (k1 = adj11; k1 < adj12; k1++) { + w = verLocInd[k1]; + if ((w < StartIndex) || (w > EndIndex)) { //A ghost + //Build the Message Packet: + //Message[0] = v+StartIndex; //LOCAL + //Message[1] = w; //GHOST + //Message[2] = FAILURE; //TYPE + //Send a Request (Asynchronous) +#ifdef PRINT_DEBUG_INFO_ + cout<<"\n("<