OpenMP® Forum

Discussion on the OpenMP specification run by the OpenMP ARB. OpenMP and the OpenMP logo are registered trademarks of the OpenMP Architecture Review Board in the United States and other countries. All rights reserved.

The problem is that the line for checking correctness of the func function doesn't always prints SIZE, but sometimes (~15-20%) something very close to it, like 4999.9 or 5000.1 (if SIZE is 5000). The problem doesn't emerge when SIZE is rather small (10, 100, 1000), but it's there for SIZE > 5000. I can't understand it at all neither can find any potential explanation.

This is just a loss of precision problem in floating point arithmetic: by the time the row sums are large enough (around 10^7), they can no longer be represented at full accuracy in a float type. If you use doubles instead of floats you should see the problem go away (at least for SIZE = 5000). This is nothing to do with OpenMP or parallelism, by the way: the problem is just the same in the sequential code.