Boost logo

Boost :

Subject: Re: [boost] problems with the Random library in Boost v1.47
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2011-07-15 12:04:47


AMDG

On 07/15/2011 08:40 AM, Hongyu Miao wrote:
> Hi, Steven
>
> Thanks for your reply. I'm using MSVC 2010, too. I met such problems when I
> generated a million random numbers with the mersenne_twister generator and
> OpenMP. I'm not sure whether v1.47 is thread safe, though.

Using a generator concurrently in multiple
threads has never been supported. Even
if this code worked (or more likely, appeared
to work) in previous versions, it's wrong.

> Here is the code
> triggered the memory access violation:
>
> int num_point = 1000;
> int n_para = 1000;
> boost::numeric::ublas::matrix<double> ui(num_point, n_para);
> #pragma omp parallel for shared(ui, num_point, n_para) private(i, j)
> for (i=0; i<num_point; i++)
> {
> for (j=0; j<n_para; j++)
> {
> ui(i,j) = unirand_real(0.0,1.0);
> }
> }
>

In Christ,
Steven Watanabe




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk