From: Enblend <enb...@li...> - 2013-01-17 14:06:21
|
branch: stable-4_1 details: http://enblend.hg.sourceforge.net/hgweb/enblend/enblend/hg/p/enblend/code/rev/f2b012042c30 changeset: 887:f2b012042c30 user: Chris <cs...@us...> date: Thu Jan 17 15:05:33 2013 +0100 description: Fix data race to elements of std::vector convergedPoints inside GDAConfiguration::calculateStateProbabilitiesCPU(), which was signalled by Intel's Inspector tool. This is a transplant of patch #eeb59bd5adfc. diffstat: NEWS | 3 +++ VERSION | 2 +- src/anneal.h | 11 +++++++++++ 3 files changed, 15 insertions(+), 1 deletions(-) diffs (75 lines): diff -r 8278a8782d4c -r f2b012042c30 NEWS --- a/NEWS Thu Jan 17 15:05:23 2013 +0100 +++ b/NEWS Thu Jan 17 15:05:33 2013 +0100 @@ -1,5 +1,8 @@ * Version 4.1.x -- Stable Branch + - [Enblend only] Fix a race condition in the seam-line optimizer + that can cause wrongly placed seams. + - [Enblend and Enfuse] Use a per-thread storage of all OpenMP Vigra-functors. This avoids data races. diff -r 8278a8782d4c -r f2b012042c30 VERSION --- a/VERSION Thu Jan 17 15:05:23 2013 +0100 +++ b/VERSION Thu Jan 17 15:05:33 2013 +0100 @@ -1,1 +1,1 @@ -4.1.1-7c505563d377 +4.1.1-8278a8782d4c diff -r 8278a8782d4c -r f2b012042c30 src/anneal.h --- a/src/anneal.h Thu Jan 17 15:05:23 2013 +0100 +++ b/src/anneal.h Thu Jan 17 15:05:33 2013 +0100 @@ -321,9 +321,12 @@ #endif for (int index = 0; index < mf_size; ++index) { // Skip updating points that have already converged. + convergedPointsLock.set(); if (convergedPoints[index]) { + convergedPointsLock.unset(); continue; } + convergedPointsLock.unset(); const std::vector<vigra::Point2D>* stateSpace = pointStateSpaces[index]; std::vector<double>* stateProbabilities = pointStateProbabilities[index]; @@ -514,9 +517,12 @@ #pragma omp for nowait schedule(guided) #endif for (int index = 0; index < static_cast<int>(pointStateSpaces.size()); ++index) { + convergedPointsLock.set(); if (convergedPoints[index]) { + convergedPointsLock.unset(); continue; } + convergedPointsLock.unset(); std::vector<vigra::Point2D>* stateSpace = pointStateSpaces[index]; std::vector<double>* stateProbabilities = pointStateProbabilities[index]; @@ -566,7 +572,9 @@ } // omp critical // Skip this point from now on. + convergedPointsLock.set(); convergedPoints[index] = true; + convergedPointsLock.unset(); continue; } @@ -600,7 +608,9 @@ localK = stateSpace->size(); if (localK < 2) { + convergedPointsLock.set(); convergedPoints[index] = true; + convergedPointsLock.unset(); } kmax_local = std::max(kmax_local, stateProbabilities->size()); @@ -673,6 +683,7 @@ // Flags indicate which points have converged std::vector<bool> convergedPoints; + omp::lock convergedPointsLock; // Initial Temperature double tInitial; |