Boost logo

Boost Users :

Subject: Re: [Boost-users] OpenMP and Boost - can they be used together?
From: dhruva (dhruvakm_at_[hidden])
Date: 2010-09-15 23:42:35


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 <max.kaznady_at_[hidden]> 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 list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net