Newsgroups: comp.parallel.mpi
From: dantowitz@interramp.com (David M. Dantowitz)
Subject: random numbers and fast mod 2^N arithmetic
Organization: Dantowitz Consulting & Research
Date: Mon, 08 May 1995 14:06:57 -0500
Message-ID: <dantowitz-0805951406570001@ip157.newark.nj.interramp.com>

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)

This type of code is useful for distributing sections of the 
same random number sequence among m processors.

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

