Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
17 Views

SVL MT2203 random number generator: Independence of different streams

Jump to solution

Hey there,

I just started some inital tests of the random number generators in SVL using Fortran90 and MPI. I am interested in having each core use its own stream. The easiest way to do this seems to be the Mersenne Twister MT2203 brng or the Wichmann-Hill WH brng.

The system I'm working on has MKL 10.0.1.014.

In the examples directory I found a number of programs that use a seed of 777 (e.g. in vslstream2file.f in examples/vslf/source), so I decided to use that. I wrote something very simple, like (this is a code fragment, so there's stuff missing):

[fortran]
double precision r(1), a, b
TYPE (VSL_STREAM_STATE) :: StreamListVSL(MaximumNumOfProcs)
integer errcode
integer brng, method, seed, n, i

n = 1 a = 0.0 b = 1.0 method=VSL_METHOD_DUNIFORM_STD seed=777 ! ***** Initializing ***** brng=VSL_BRNG_MT2203+MyRank errcode=vslnewstream( StreamListVSL(MyRank), brng, seed ) print *, MyRank, "errcode: ", errcode ! ***** Generating ***** do i = 1,10 errcode=vdrnguniform( method, StreamListVSL(MyRank), n, r, a, b ) print *, MyRank, i, r(1), errcode end do
[/fortran]

where MyRank is the rank of each core (and the array r doesn't need to be defined as r(1) -- I have checked that using a larger size doesn't change the point I'm making here, if in that case I print out the r(i)).

When I run this on, say, 100 cores, I notice that many cores give the same numbers for the first few i's! These usually come in groups of 2-3, i.e. 3 cores give the same number (to machine precision), 2 others another number, and so on.

Now, when I change the seed to, say, 77777777 this behavior disappears, i.e. each core gives completely different numbers.

The thing is, in section 7.3.1 of the VSL notes I read that:

"When calling initialization functions you may ignore acceptability of the passed initial values for a given basic generator. If the passed seeds are unacceptable, the initialization procedure replaces them with those acceptable for a given type of BRNG."

so I don't understand why using a small value of the seed leads to the observed behavior. All I could find in this regard in the VSL notes was in section 8.4.7 where it says:

"The stream tested is generated by calling the function vslNewStream with seed=7,777,777"

which doesn't really advise one on how to pick the seed. Especially given the fact that the examples directory uses a considerably smaller seed, I was wondering if anyone had some quantitative guidance to offer. Is there something I've missed?

Thanks,

Alex Gezerlis

0 Kudos

Accepted Solutions
Highlighted
Employee
17 Views

Hello Alex,

MKL\VSL provides support for parallel Monte Carlo simulations using different approaches, in particular Leap-frogging, Block-splitting (section 7.3 of VSL Notes considers them in more details; the examples which demonstratethose techniques are available in examples\vslf\source subdirectory of MKL tree). The generators which can produce independent streams like WH and MT2203 is another methodology todo parallel simulations.

Section 8.4 describes initialization of each VSL BRNG including its default behavior if an inappropriate value of the seed is passed into the initialization routine of the generator (see sections "Stream Initialization by the Function vslNewStream" and "Stream Initialization by the Function vslNewStreamEx").

MKL MT19937 and MT2203 BRNGs are initialized using the procedure whose description is available at http://www.math.sci.hiroshima-u.ac.jp/%7Em-mat/MT/MT2002/emt19937ar.html.

Due to specifics of the MT2203s algorithm, their parameters and initialization some seeds used to set the BRNG (like 777) can result in a few first identical outputs in different streams. If youvary the seed (for example, set it to 776)you would see a different picture. If having firstsimilar RNG outputs is inappropriate for your goals you might want to discard them (see also http://software.intel.com/en-us/forums/showthread.php?t=61916 for another forum thread which discusses similar topic on the choice of the seed).

The seeds in VSL examples are used for demonstration purpose only. We test the generators usingset of seeds and provide summary of empirical testing results in VSL Notes for one of them, 7,777,777.

While the different methodologies can be used to set the seed (for example, system time or a source of true random numbers), their usage is defined by the specifics of your application and may be inappropriate or"bulky" in some cases, and the choice of the suitable seed would be done on your side.

Please, let me know if this answers your questions.

Thanks, Andrey

View solution in original post

0 Kudos
2 Replies
Highlighted
Employee
18 Views

Hello Alex,

MKL\VSL provides support for parallel Monte Carlo simulations using different approaches, in particular Leap-frogging, Block-splitting (section 7.3 of VSL Notes considers them in more details; the examples which demonstratethose techniques are available in examples\vslf\source subdirectory of MKL tree). The generators which can produce independent streams like WH and MT2203 is another methodology todo parallel simulations.

Section 8.4 describes initialization of each VSL BRNG including its default behavior if an inappropriate value of the seed is passed into the initialization routine of the generator (see sections "Stream Initialization by the Function vslNewStream" and "Stream Initialization by the Function vslNewStreamEx").

MKL MT19937 and MT2203 BRNGs are initialized using the procedure whose description is available at http://www.math.sci.hiroshima-u.ac.jp/%7Em-mat/MT/MT2002/emt19937ar.html.

Due to specifics of the MT2203s algorithm, their parameters and initialization some seeds used to set the BRNG (like 777) can result in a few first identical outputs in different streams. If youvary the seed (for example, set it to 776)you would see a different picture. If having firstsimilar RNG outputs is inappropriate for your goals you might want to discard them (see also http://software.intel.com/en-us/forums/showthread.php?t=61916 for another forum thread which discusses similar topic on the choice of the seed).

The seeds in VSL examples are used for demonstration purpose only. We test the generators usingset of seeds and provide summary of empirical testing results in VSL Notes for one of them, 7,777,777.

While the different methodologies can be used to set the seed (for example, system time or a source of true random numbers), their usage is defined by the specifics of your application and may be inappropriate or"bulky" in some cases, and the choice of the suitable seed would be done on your side.

Please, let me know if this answers your questions.

Thanks, Andrey

View solution in original post

0 Kudos
Highlighted
17 Views

Hi Andrey,

Yes, this more or less covers it. Thanks for providing these links and for your detailed answer.

Thanks,

Alex

0 Kudos