Compiling with the Intel Compiler reveals a problem:
tolerance-test.c(350): error: index variable "i" of for statement following an OpenMP for pragma must be private
# pragma omp parallel for default(none) shared(i) private (result)
^
In addition to this, the 'result' variable also should not be private
(otherwise its value does not survive after the end of the loop). It
needs to be either shared or use the reduction clause to describe how
the results from multiple threads are combined together. Reduction
seems to be more appropriate here.
else
{
#ifdef USE_OPENMP
-# pragma omp parallel for default(none) shared(i) private (result)
+# pragma omp parallel for default(none) reduction(|:result)
#endif
for (i = 0; i < N_TESTS; ++i)
{
if (!do_check (i))
- result = 1;
+ result |= 1;
}
}