Newsgroups: comp.parallel.pvm
From: dantowitz@interramp.com (David M. Dantowitz)
Subject: Re: random number seeds
Organization: Dantowitz Consulting & Research
Date: Mon, 08 May 1995 14:02:39 -0500
Message-ID: <dantowitz-0805951402390001@ip157.newark.nj.interramp.com>

In article <3jj4vj$c43@nntp3.u.washington.edu>,
lovato@biostat.washington.edu (James Lovato) wrote:

> I'm sure this has been solved.
> What is the best way to keep track of random number generator seeds
> across slave programs?
> 
> I am running a simulation that spawns slave programs that call a random
> number generator k times.
> 
> How can I set up the program so that I have reproducible results?
> 
> The only way I can think of is
> 
>       do 30 i = 1, n
>            call pvmfspawn(slave, ...)
>            seed = advsd(seed,k)
>            pvmfinitsend(PVMDEFAULT,ibuff)
>            pvmfpack(REAL8,seed,1,1,ierr)
>   30  continue
> 
> where advsd(seed,k) advances the seed k places.
> That is, send each slave a seed that is k places from the last seed.
> 
> Please reply to lovato@panda.fhcrc.org. I'll summarizes and post any replys.
> Thanks
> James

I've just completed some code to compute random numbers quickly
based on sequences of the form:
                                     n
                 X    = (X * A) mod 2
                  k+1     k

The sample code uses A=5^13 and n = 46 or 52.  (This particular
sequence is based on the NAS EP benchmark's generator.)

Two functions are supported, compute

         X    from X    and    X    from X  and i (for i>0)
          k+1       k           k+i       k

(note that values for i>2^32 are supported as well)

The code is highly optimized by pre-computing many sub-expressions
and replacing most FP operations with integer operations.  On the
four platforms tested, the cost for each rn is reduced by 33-66%.

For a copy of the C source (in generic ANSI C) send me mail.

David Dantowitz
dantowitz@aol.com

