Boost logo

Boost :

Subject: Re: [boost] [random] new threefry random engine
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2014-04-27 07:39:30

On 22/04/14 01:51, Steven Watanabe wrote:
> On 04/21/2014 02:28 PM, John Salmon wrote:
>> <snip>
>> I would love to see a boost implementation that captured and exposed
>> this capability for general use. Thus, I think a better approach is
>> as follows:
>> - define a new "RandomFunction" concept that dscribes/enforces the
>> essential, common features of the randomizing function in Threefry,
>> Philox, ARS and other counter-based random generators.
> I don't think this is a particularly useful
> abstraction. Most users should not care at
> all about this, since they should be using
> the predefined engine typedefs. If more
> similar generators are added later, then the
> implementation can be adjusted to factor
> out the common boilerplate, but I really
> don't see the point of creating a whole new
> concept for this.

People usually want to do something like this

#pragma omp for
for(int i=0; i<n; ++i)
   out[i] = in[i] * random_value();

If the random_value generator is shared, not only do you get poor
performance due to synchronization, but you also get non-deterministic

If you use a per-thread generator, this is a bit more annoying to set
up, manage and reproduce as the results will still depend on which
threads get to do what and how each of them are seeded.

With a single, stateless generator, everything is much simpler. One
seed, one generator, completely reproducible results regardless of
scheduling. The interface i want to have is this:

#pragma omp for
for(int i=0; i<n; ++i)
   out[i] = in[i] * random_value(i);

Boost list run by bdawes at, gregod at, cpdaniel at, john at