नोट
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप साइन इन करने या निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
इस पृष्ठ तक पहुंच के लिए प्राधिकरण की आवश्यकता होती है। आप निर्देशिकाएँ बदलने का प्रयास कर सकते हैं।
'var' : Floating point reduction variable may cause inconsistent results under /fp:strict or #pragma fenv_access
Remarks
You should not use /fp:strict or fenv_access with OpenMP floating-point reductions, because the sum is computed in a different order. Thus, results can differ from the results without /openmp.
Example
The following example generates C4938:
// C4938.cpp
// compile with: /openmp /W4 /fp:strict /c
// #pragma fenv_access(on)
extern double *a;
double test(int first, int last) {
double sum = 0.0;
#pragma omp parallel for reduction(+: sum) // C4938
for (int i = first ; i <= last ; ++i)
sum += a[i];
return sum;
}
Without explicit parallelization, the sum is computed as follows:
sum = a[first] + a[first + 1] + ... + a[last];
With explicit parallelization (and two threads), the sum is computed as follows:
sum1 = a[first] + ... a[first + last / 2];
sum2 = a[(first + last / 2) + 1] + ... a[last];
sum = sum1 + sum2;