[Omp] Reproducing results from randomizer

Olaf Lenz olenz at Physik.Uni-Bielefeld.DE
Sun Jul 24 02:12:28 PDT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello!

C J Kenneth Tan -- OptimaNumerics wrote:
> Unfortunately, MT19937 is a serial RNG.  What you need is a parallel
> RNG.

Hmm, as far as I understood, a RNG algorithm can not be serial or
parallel, only the implementation can be.

In general, a RNG algorithm produces a stream of random numbers. To do
this, it saves a state.

If you have a RNG implementation that saves its state in a global
variable, then it does not make sense to use it in a parallel
environment, as the state of the RNG will be shared and it will be
accessed by all threads concurrently.

If, however, it saves the state in a local structure, then you can
create more than one instance of the RNG and have more than one stream
of random numbers.

If you have an implementation of the RNG algorithm that works like this,
then you can easily use it in a parallel environment like this:

In the serial region:
1. Create a RNG (the "seeding RNG"). Seed it with the manually provided
seed. This seed can be saved and it can be used to reproduce the
results. This RNG can be a very simple one, and it should probably be
another one than the one used for the actual work.
2. Use the seeding RNG to generate a seed for each thread (e.g. save
them in an array)

In the parallel region:
1. Generate a local instance of the main RNG (in this case MT19937) for
each thread.
2. Seed the RNG with the seed generated in the serial region.

Attached, you'll find a simple sample code (in C) that uses the RNGs of
the GSL (GNU Scientific Library, http://sources.redhat.com/gsl/). I've
not actually tested this code, but it should work.

Or am I missing something?

Cheers
	Olaf
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFC41t7tQ3riQ3oo/oRAur4AJ4tD3RIiKiOCstgVQ7MNCpyWmUwPACfZhM+
+zMvH+ZWSvQkhpDFVWDOCOE=
=WeDA
-----END PGP SIGNATURE-----




More information about the Omp mailing list