processMatchedVertices parallelized

omp-walther
StefanoPetrilli 3 years ago
parent 71d4cdc319
commit 9ab54adf3f

@ -36,6 +36,7 @@ void processMatchedVertices(
{
MilanLongInt adj1, adj2, adj11, adj12, k, k1, v = -1, w = -1, ghostOwner;
int option;
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << "=========================************===============================" << endl;
fflush(stdout);
@ -45,7 +46,7 @@ void processMatchedVertices(
#ifdef COUNT_LOCAL_VERTEX
MilanLongInt localVertices = 0;
#endif
#pragma omp parallel private(k, w, v, k1, adj1, adj2, adj11, adj12, ghostOwner) firstprivate(privateU, StartIndex, EndIndex, privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner) default(shared) num_threads(NUM_THREAD)
#pragma omp parallel private(k, w, v, k1, adj1, adj2, adj11, adj12, ghostOwner, option) firstprivate(privateU, StartIndex, EndIndex, privateQLocalVtx, privateQGhostVtx, privateQMsgType, privateQOwner) default(shared) num_threads(NUM_THREAD)
{
// TODO what would be the optimal UCHUNK
@ -76,6 +77,7 @@ void processMatchedVertices(
adj2 = verLocPtr[u - StartIndex + 1];
for (k = adj1; k < adj2; k++)
{
option = -1;
v = verLocInd[k];
if ((v >= StartIndex) && (v <= EndIndex))
@ -87,8 +89,6 @@ void processMatchedVertices(
#endif
// If the current vertex is pointing to a matched vertex and is not matched
// FIXME is there a way to make candidateMate private?
// for the moment it could generate an error.
if (not isAlreadyMatched(v, StartIndex, EndIndex, GMate, Mate, Ghost2LocalMap))
{
#pragma omp critical
@ -122,34 +122,13 @@ void processMatchedVertices(
cout << "\n(" << myRank << ")Sending a request message:";
cout << "\n(" << myRank << ")Ghost is " << w << " Owner is: " << findOwnerOfGhost(w, verDistance, myRank, numProcs);
#endif
ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs);
assert(ghostOwner != -1);
assert(ghostOwner != myRank);
#pragma omp atomic
PCounter[ghostOwner]++;
#pragma omp atomic
(*msgIndPtr)++;
#pragma omp atomic
(*NumMessagesBundledPtr)++;
privateQLocalVtx.push_back(v);
privateQGhostVtx.push_back(w);
privateQMsgType.push_back(REQUEST);
privateQOwner.push_back(ghostOwner);
option = 2;
if (candidateMate[NLVer + Ghost2LocalMap[w]] == v)
{
option = 1;
Mate[v - StartIndex] = w; // v is a local vertex
GMate[Ghost2LocalMap[w]] = v; // w is a ghost vertex
privateU.push_back(v);
privateU.push_back(w);
#pragma omp atomic
(*myCardPtr)++;
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") ";
fflush(stdout);
#endif
// Decrement the counter:
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[w], SPtr);
@ -159,12 +138,10 @@ void processMatchedVertices(
{ // w is a local vertex
if (candidateMate[w - StartIndex] == v)
{
option = 3;
Mate[v - StartIndex] = w; // v is a local vertex
Mate[w - StartIndex] = v; // w is a local vertex
privateU.push_back(v);
privateU.push_back(w);
#pragma omp atomic
(*myCardPtr)++;
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") ";
fflush(stdout);
@ -173,8 +150,64 @@ void processMatchedVertices(
} // End of Else
} // End of if(w >=0)
else option = 4;// End of Else: w == -1
// End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
}
} // End of task
} // End of If (candidateMate[v-StartIndex] == u
} // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex:
else
{ // Neighbor is a ghost vertex
#pragma omp critical
{
if (candidateMate[NLVer + Ghost2LocalMap[v]] == u)
candidateMate[NLVer + Ghost2LocalMap[v]] = -1;
if (v != Mate[u - StartIndex]) option = 5; // u is local
} // End of critical
} // End of Else //A Ghost Vertex
switch (option)
{
case -1:
// No things to do
break;
case 1:
// Found a dominating edge, it is a ghost and candidateMate[NLVer + Ghost2LocalMap[w]] == v
privateU.push_back(v);
privateU.push_back(w);
#pragma omp atomic
(*myCardPtr)++;
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") ";
fflush(stdout);
#endif
case 2:
// Found a dominating edge, it is a ghost
ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs);
assert(ghostOwner != -1);
assert(ghostOwner != myRank);
#pragma omp atomic
PCounter[ghostOwner]++;
#pragma omp atomic
(*msgIndPtr)++;
#pragma omp atomic
(*NumMessagesBundledPtr)++;
privateQLocalVtx.push_back(v);
privateQGhostVtx.push_back(w);
privateQMsgType.push_back(REQUEST);
privateQOwner.push_back(ghostOwner);
break;
case 3:
privateU.push_back(v);
privateU.push_back(w);
#pragma omp atomic
(*myCardPtr)++;
break;
case 4:
// Could not find a dominating vertex
adj11 = verLocPtr[v - StartIndex];
adj12 = verLocPtr[v - StartIndex + 1];
for (k1 = adj11; k1 < adj12; k1++)
@ -206,22 +239,8 @@ void processMatchedVertices(
} // End of if(GHOST)
} // End of for loop
} // End of Else: w == -1
// End: PARALLEL_PROCESS_EXPOSED_VERTEX_B(v)
}
} // End of task
} // End of If (candidateMate[v-StartIndex] == u
} // End of if ( (v >= StartIndex) && (v <= EndIndex) ) //If Local Vertex:
else
{ // Neighbor is a ghost vertex
#pragma omp critical
{
if (candidateMate[NLVer + Ghost2LocalMap[v]] == u)
candidateMate[NLVer + Ghost2LocalMap[v]] = -1;
if (v != Mate[u - StartIndex])
{ // u is local
break;
default:
#ifdef PRINT_DEBUG_INFO_
cout << "\n(" << myRank << ")Sending a success message: ";
@ -243,10 +262,9 @@ void processMatchedVertices(
privateQMsgType.push_back(SUCCESS);
privateQOwner.push_back(ghostOwner);
} // End of If( v != Mate[u] )
break;
} //End of switch
} // End of task
} // End of Else //A Ghost Vertex
} // End of inner for
// TODO privateU.size() < UCHUNK could be commented but it generate errors, why?

Loading…
Cancel
Save