
I fixed the problem... basically, entries of a double array get
rounded when summed, and the order in which the sum is performed
matters, so the final answer might differ by some small number due to
rounding. Using an "ordered" directive fixes this. If anyone else is
having this issue, here is sample code, see the comment in the code
about the for loop.
Also, notice how the reduction clause is used and how the sum variable
is no longer shared - that was another issue with the code.
#include <iostream>
#include
Hi, With my limited knowledge of OpenMP, I am attempting to give some hints.
On Thu, Sep 16, 2010 at 5:04 AM, Max S. Kaznady
wrote: Hello,
I wrote a simple parallel program which computes the sum of elements across a matrix using Boost. When I use OpenMP, the program runs give different sums. When I use just simple arrays like double array[N][N], instead of boost::numeric::ublas::matrix<double>, the code work just fine and as expected. Does anyone know what is going on? It looks like the score function is not being modified properly, because Boost array returns just fine.
[code]
double sc = 0.0; unsigned i, j; matrix<double> temp(N, N);
#pragma omp parallel \ shared(sc,temp) \
Not sure if you can share a user defined type which does not point to a contiguous block of memory. Could you please try using a normal array instead of boost array only for 'temp' and see what happens. I am doubting race conditions since OpenMP cannot guarantee synchronous write access to 'temp' IIRC using memory barriers.
-dhruva _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users