mirror of
https://github.com/sfilippone/amg4psblas.git
synced 2026-10-06 22:55:12 +00:00
processCrossEdges is now atomic
This commit is contained in:
@@ -4,20 +4,20 @@ void PROCESS_CROSS_EDGE(vector<MilanLongInt> &Counter,
|
||||
MilanLongInt edge,
|
||||
MilanLongInt *SPtr)
|
||||
{
|
||||
// Decrement the counter:
|
||||
// Start: PARALLEL_PROCESS_CROSS_EDGE_B
|
||||
if (Counter[edge] > 0)
|
||||
{
|
||||
Counter[edge] -= 1; // Decrement
|
||||
if (Counter[edge] == 0)
|
||||
{
|
||||
(*SPtr)--; // Decrement S
|
||||
#ifdef PRINT_DEBUG_INFO_
|
||||
cout << "\n(" << myRank << ")Decrementing S: Ghost vertex " << edge << " has received all its messages";
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
MilanLongInt captureCounter;
|
||||
|
||||
} // End of if Counter[edge] > 0
|
||||
// End: PARALLEL_PROCESS_CROSS_EDGE_B
|
||||
#pragma omp atomic capture
|
||||
captureCounter = --Counter[edge]; // Decrement
|
||||
|
||||
if (captureCounter == 0)
|
||||
#pragma omp atomic
|
||||
(*SPtr)--; // Decrement S
|
||||
|
||||
#ifdef PRINT_DEBUG_INFO_
|
||||
cout << "\n(" << myRank << ")Decrementing S: Ghost vertex " << edge << " has received all its messages";
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
// End: PARALLEL_PROCESS_CROSS_EDGE_B
|
||||
}
|
||||
@@ -130,8 +130,6 @@ void processMatchedVertices(
|
||||
Mate[v - StartIndex] = w; // v is a local 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 a Ghost Vertex
|
||||
else
|
||||
@@ -150,7 +148,8 @@ void processMatchedVertices(
|
||||
} // End of Else
|
||||
|
||||
} // 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 of task
|
||||
@@ -164,10 +163,10 @@ void processMatchedVertices(
|
||||
{
|
||||
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
|
||||
|
||||
if (v != Mate[u - StartIndex])
|
||||
option = 5; // u is local
|
||||
} // End of critical
|
||||
} // End of Else //A Ghost Vertex
|
||||
|
||||
switch (option)
|
||||
{
|
||||
@@ -184,6 +183,8 @@ void processMatchedVertices(
|
||||
cout << "\n(" << myRank << ")MATCH: (" << v << "," << w << ") ";
|
||||
fflush(stdout);
|
||||
#endif
|
||||
// Decrement the counter:
|
||||
PROCESS_CROSS_EDGE(Counter, Ghost2LocalMap[w], SPtr);
|
||||
case 2:
|
||||
// Found a dominating edge, it is a ghost
|
||||
ghostOwner = findOwnerOfGhost(w, verDistance, myRank, numProcs);
|
||||
@@ -241,29 +242,29 @@ void processMatchedVertices(
|
||||
} // End of for loop
|
||||
break;
|
||||
default:
|
||||
|
||||
|
||||
#ifdef PRINT_DEBUG_INFO_
|
||||
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 << ")Sending a success message: ";
|
||||
cout << "\n(" << myRank << ")Ghost is " << v << " Owner is: " << findOwnerOfGhost(v, verDistance, myRank, numProcs) << "\n";
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs);
|
||||
assert(ghostOwner != -1);
|
||||
assert(ghostOwner != myRank);
|
||||
ghostOwner = findOwnerOfGhost(v, verDistance, myRank, numProcs);
|
||||
assert(ghostOwner != -1);
|
||||
assert(ghostOwner != myRank);
|
||||
#pragma omp atomic
|
||||
PCounter[ghostOwner]++;
|
||||
PCounter[ghostOwner]++;
|
||||
#pragma omp atomic
|
||||
(*msgIndPtr)++;
|
||||
(*msgIndPtr)++;
|
||||
#pragma omp atomic
|
||||
(*NumMessagesBundledPtr)++;
|
||||
privateQLocalVtx.push_back(u);
|
||||
privateQGhostVtx.push_back(v);
|
||||
privateQMsgType.push_back(SUCCESS);
|
||||
privateQOwner.push_back(ghostOwner);
|
||||
(*NumMessagesBundledPtr)++;
|
||||
privateQLocalVtx.push_back(u);
|
||||
privateQGhostVtx.push_back(v);
|
||||
privateQMsgType.push_back(SUCCESS);
|
||||
privateQOwner.push_back(ghostOwner);
|
||||
|
||||
break;
|
||||
} //End of switch
|
||||
} // End of switch
|
||||
|
||||
} // End of inner for
|
||||
|
||||
|
||||
Reference in New Issue
Block a user