Modify 'maxnorm' value insider critical section when using OpenMP with integer samples

This commit is contained in:
oparviai 2017-03-05 13:56:03 +00:00
parent 5d9bc2fdf3
commit 6f82bdebdb
2 changed files with 12 additions and 2 deletions

View File

@ -909,10 +909,15 @@ double TDStretch::calcCrossCorr(const short *mixingPos, const short *compare, do
mixingPos[i + 3] * mixingPos[i + 3]) >> overlapDividerBitsNorm; mixingPos[i + 3] * mixingPos[i + 3]) >> overlapDividerBitsNorm;
} }
if (lnorm > maxnorm)
{
// modify 'maxnorm' inside critical section to avoid multi-access conflict if in OpenMP mode
#pragma omp critical
if (lnorm > maxnorm) if (lnorm > maxnorm)
{ {
maxnorm = lnorm; maxnorm = lnorm;
} }
}
// Normalize result by dividing by sqrt(norm) - this step is easiest // Normalize result by dividing by sqrt(norm) - this step is easiest
// done using floating point operation // done using floating point operation
norm = (double)lnorm; norm = (double)lnorm;

View File

@ -123,10 +123,15 @@ double TDStretchMMX::calcCrossCorr(const short *pV1, const short *pV2, double &d
// Clear MMS state // Clear MMS state
_m_empty(); _m_empty();
if (norm > (long)maxnorm)
{
// modify 'maxnorm' inside critical section to avoid multi-access conflict if in OpenMP mode
#pragma omp critical
if (norm > (long)maxnorm) if (norm > (long)maxnorm)
{ {
maxnorm = norm; maxnorm = norm;
} }
}
// Normalize result by dividing by sqrt(norm) - this step is easiest // Normalize result by dividing by sqrt(norm) - this step is easiest
// done using floating point operation // done using floating point operation