Newsgroups: comp.parallel
From: dantowitz@interramp.com (David M. Dantowitz)
Subject: Random number and fast mod 2^n code available
Organization: Dantowitz Consulting & Research
Date: 29 May 1995 15:25:31 GMT
Message-ID: <3qcp1b$22k@usenet.srv.cis.pitt.edu>

I recently 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
david@cs.ucla.edu

