Boost logo

Boost Users :

From: Heiko Bauke (Heiko.Bauke_at_[hidden])
Date: 2005-06-01 05:04:32


Hi,

On Wed, 1 Jun 2005 09:10:49 +0100
"Sliwa, Przemyslaw (London)" <Przemyslaw_Sliwa_at_[hidden]> wrote:

> I have a question which is not related directly to boost.
> I am writing a multithreaded application and would like to make use of
> a multiprocessor machine in order to speed up our Monte Carlo
> simulation engine. We make use of the random number package (random
> number distributions). My question is: making the random number
> generator a global variable (object) it is possible to use it in
> several threads at the same time -> does it mean that the random
> sequences will be repeated and the entire simulation will be simply a
> repetition of n non-random sequences? This can be avoided when a lock
> is acquired on the random number generator and at a given time just
> one thread can access the rng and the advantage of the multiprocessor
> machine is lost. Can you advise?

in my opinion the Boost random number generators are not qualified for
parallel applications.

You need a mechanism to distribute streams of random numbers in an
_controlled_ way over the parallel processes. One way to do this is the
leap frog method. With three CPUs the original stream

original 1 2 4 6 2 5 1 5 2 4 6 4 6 2 3 1 1 6

would be distributed like this

CPU 1 1 6 1 4 6 1
CPU 2 2 2 5 6 2 1
CPU 3 4 5 2 4 3 6

In Tina's Random Number Generator Library (TRNG) you find a some long
period pseudo random number generators with special functions for
parallel computations like sequence splitting (leap frog) and jumping.
see http://tina.nat.uni-magdeburg.de/TRNG

Do not hesitate to ask me, if you have questions about TRNG or parallel
random number generators.

        Heiko

-- 
-- Gegen Angriffe kann man sich wehren, gegen Lob ist man machtlos.
-- (Sigmund Freud, österr. Psychologe u. Psychater, 1856-1939)
-- Supercomputing in Magdeburg @ http://tina.nat.uni-magdeburg.de
--                 Heiko Bauke @ http://www.uni-magdeburg.de/bauke

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