mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
#14596 Remove dead reserve and redundant barrier in NNC computation
totalNumberOfConnections was declared, listed in the reduction clause and used to size otherConnections, but it was never incremented. The counting was lost when the loop body was moved into extractConnectionsForFace, so the call has always been reserve( size() + 0 ), which RigConnectionContainer::reserve turns into a no-op. The reserve was also called by every thread on the shared container without synchronization. Removing it eliminates that data race. The explicit barrier is redundant as well, since the omp for construct has no nowait clause and therefore already synchronizes before the merge.
This commit is contained in:
@@ -177,18 +177,15 @@ RigConnectionContainer RigCellFaceGeometryTools::computeOtherNncs( const RigMain
|
||||
if ( atLeastOneCellActive ) activeFaceIndices.push_back( faceIdx );
|
||||
}
|
||||
|
||||
size_t totalNumberOfConnections = 0u;
|
||||
#pragma omp parallel
|
||||
{
|
||||
RigConnectionContainer threadConnections;
|
||||
#pragma omp for schedule( guided ) reduction( + : totalNumberOfConnections )
|
||||
#pragma omp for schedule( guided )
|
||||
for ( int activeFaceIdx = 0; activeFaceIdx < static_cast<int>( activeFaceIndices.size() ); activeFaceIdx++ )
|
||||
{
|
||||
size_t faceIdx = activeFaceIndices[activeFaceIdx];
|
||||
extractConnectionsForFace( faultFaces[faceIdx], mainGrid, nativeCellPairs, threadConnections );
|
||||
}
|
||||
#pragma omp barrier
|
||||
otherConnections.reserve( otherConnections.size() + totalNumberOfConnections );
|
||||
|
||||
// Merge together connections per thread
|
||||
assignThreadConnections( otherConnections, threadConnections );
|
||||
|
||||
Reference in New Issue
Block a user