random_number: threadsafe?

Thomas Koenig tkoenig@alice-dsl.net
Fri Mar 23 20:00:00 GMT 2007


On Fri, 2007-03-23 at 11:04 +0100, Daniel Franke wrote:

> The is one nitpick, though: due to the mutexes used in the code, random_number 
> became a serialization point. An unexpected one for any user of the library.
> Let there be an algorithm that heavily relies on random number generation, 
> e.g. any Monte Carlo algorithm, this may render OpenMP parallelization 
> thereof useless. In the worst case, the parallel version may be slower due to 
> serialized threads and their overhead ...

We could provide per-thread state for the random number generator, and
initialize the seeds accordingly on thread startup.

Anything obviously (or not-so obviously) wrong with that idea?




More information about the Fortran mailing list