public inbox for gsl-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Heiko Bauke <heiko.bauke@mail.de>
To: gsl-discuss@sourceware.org
Subject: random number generation algorithms
Date: Tue, 14 Nov 2017 08:40:00 -0000	[thread overview]
Message-ID: <a5bcdab8-73ef-6811-21a8-0709be4b7b6d@mail.de> (raw)

Hi,

quite some time ago (in 2003) I provided some fixes for some random 
number generation algorithms to the GSL.  My implementation was mainly 
focused on correctness and portability.  Thus it was implemented in C89, 
which is portable but does not guarantee to have a 64 bit integer type.

The performance of some random number generation algorithms, however, 
can benefit a lot from an implementation that uses 64 integers for 
intermediate values.  This holds often not only for genuine 64 bit 
architectures but also for 32 bit CPUs where the compiler emits more 
complex code to emulate 64 bit arithmetics.  Thus I reimplemented these 
generators in C99 and 64 bit arithmetics and wrote a simple benchmark 
that generates a few million random floating point numbers, sums them 
up, prints this sum and the elapsed time.  For some generators the 
performance difference is substantial.

How can I submit my revised code?  The code is backward compatible to 
C89 via preprocessor switches.

Here my results to give you an idea of the performance impact of the new 
implementation:  (Note that a substantial amount of time is actually 
spent in making just the function call to the generator's get routine, 
performing the loop and so on.  An empty get function, yields a running 
time of 0.6 sec. on my computer.)

Current code:

generator type: cmrg
time = 3.13553 sec.
sum = 67102809.40374

generator type: mrg
time = 1.85819 sec.
sum = 67103626.29699

generator type: minstd
time = 0.87232 sec.
sum = 67112858.69032

generator type: knuthran2
time = 4.21356 sec.
sum = 67111295.37067

generator type: fishman18
time = 2.28581 sec.
sum = 67112445.93199

generator type: fishman20
time = 0.90139 sec.
sum = 67104902.87940

generator type: lecuyer21
time = 1.05779 sec.
sum = 67107194.15891

generator type: fishman2x
time = 1.14781 sec.
sum = 67118684.47031



New code:

generator type: cmrg
time = 1.03106 sec.
sum = 67102809.40374

generator type: mrg
time = 0.72681 sec.
sum = 67103626.29699

generator type: minstd
time = 0.66231 sec.
sum = 67112858.69032

generator type: knuthran2
time = 0.70982 sec.
sum = 67111295.37067

generator type: fishman18
time = 0.66595 sec.
sum = 67112445.93199

generator type: fishman20
time = 0.66089 sec.
sum = 67104902.87940

generator type: lecuyer21
time = 0.80597 sec.
sum = 67107194.15891

generator type: fishman2x
time = 0.90818 sec.
sum = 67118684.47031


	Regards,

	Heiko

-- 
-- Number Crunch Blog @ https://www.numbercrunch.de
--  Cluster Computing @ http://www.clustercomputing.de
--       Professional @ https://www.mpi-hd.mpg.de/personalhomes/bauke
--  Social Networking @ https://www.researchgate.net/profile/Heiko_Bauke

             reply	other threads:[~2017-11-14  8:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-14  8:40 Heiko Bauke [this message]
2017-12-01 17:35 ` Patrick Alken

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a5bcdab8-73ef-6811-21a8-0709be4b7b6d@mail.de \
    --to=heiko.bauke@mail.de \
    --cc=gsl-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).