processCrossEdges is now atomic

omp-walther
StefanoPetrilli 2 years ago
parent 9ab54adf3f
commit d24c8c2d46

@ -4,20 +4,20 @@ void PROCESS_CROSS_EDGE(vector<MilanLongInt> &Counter,
MilanLongInt edge, MilanLongInt edge,
MilanLongInt *SPtr) MilanLongInt *SPtr)
{ {
// Decrement the counter:
// Start: PARALLEL_PROCESS_CROSS_EDGE_B // Start: PARALLEL_PROCESS_CROSS_EDGE_B
if (Counter[edge] > 0) MilanLongInt captureCounter;
{
Counter[edge] -= 1; // Decrement #pragma omp atomic capture
if (Counter[edge] == 0) captureCounter = --Counter[edge]; // Decrement
{
if (captureCounter == 0)
#pragma omp atomic
(*SPtr)--; // Decrement S (*SPtr)--; // Decrement S
#ifdef PRINT_DEBUG_INFO_ #ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Decrementing S: Ghost vertex " << edge << " has received all its messages"; cout << "\n(" << myRank << ")Decrementing S: Ghost vertex " << edge << " has received all its messages";
fflush(stdout); fflush(stdout);
#endif #endif
}
} // End of if Counter[edge] > 0
// End: PARALLEL_PROCESS_CROSS_EDGE_B // End: PARALLEL_PROCESS_CROSS_EDGE_B
} }

@ -130,8 +130,6 @@ void processMatchedVertices(
Mate[v - StartIndex] = w; // v is a local vertex Mate[v - StartIndex] = w; // v is a local vertex
GMate[Ghost2LocalMap[w]] = v; // w is a ghost vertex GMate[Ghost2LocalMap[w]] = v; // w is a ghost vertex
// Decrement the counter:
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[w], SPtr);
} // End of if CandidateMate[w] = v } // End of if CandidateMate[w] = v
} // End of if a Ghost Vertex } // End of if a Ghost Vertex
else else
@ -150,7 +148,8 @@ void processMatchedVertices(
} // End of Else } // End of Else
} // End of if(w >=0) } // End of if(w >=0)
else option = 4;// End of Else: w == -1 else
option = 4; // End of Else: w == -1
// End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v) // End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
} }
} // End of task } // End of task
@ -164,11 +163,11 @@ void processMatchedVertices(
{ {
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]) option = 5; // u is local if (v != Mate[u - StartIndex])
option = 5; // u is local
} // End of critical } // End of critical
} // End of Else //A Ghost Vertex } // End of Else //A Ghost Vertex
switch (option) switch (option)
{ {
case -1: case -1:
@ -184,6 +183,8 @@ void processMatchedVertices(
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") "; cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") ";
fflush(stdout); fflush(stdout);
#endif #endif
// Decrement the counter:
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[w], SPtr);
case 2: case 2:
// Found a dominating edge, it is a ghost // Found a dominating edge, it is a ghost
ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs); ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs);
@ -263,7 +264,7 @@ void processMatchedVertices(
privateQOwner.push_back(ghostOwner); privateQOwner.push_back(ghostOwner);
break; break;
} //End of switch } // End of switch
} // End of inner for } // End of inner for

Loading…
Cancel
Save