URNG: A portable optimization technique for software applications requiring pseudo-random numbers
Introduction
In most research fields various problems remain very tedious if not intractable if they are tackled with deterministic algorithms and this is the main reason why scientists often develop stochastic algorithms. For small problem size, this kind of randomized approach has proved to be less efficient than its deterministic counterpart. However, it is now well known that stochastic algorithms can efficiently tackle various large-scale problems and we have gained this certitude also from our experience [2], [6], [15]. Such stochastic algorithms need a source of randomness. Pseudo-random number generators (PRNGs) are frequently preferred to physical devices mainly because they authorize results reproducibility, they are often portable and facilitate program debugging. For computer scientists specialized in stochastic computations and or simulations, it is well known that there are no safe and universal random number generators [14], [19]. Since generators of any kind have their side effects, it is at least strongly recommended to check the results with different kinds of generators. In addition to the study of their theoretical and empirical qualities [1], [4], [18], [21], [23], [26], the efficiency and optimization of random numbers has often been considered by specialists in their sequential [10], [17]] and parallel versions [3], [5], [24], [28]. Despite a fair amount of sound theoretical work on pseudo-random number generation algorithms, the theoretical gain is often eradicated by poor computer implementations. Indeed, the concern for speed often results in shortcuts which most of the time rely on approximations. Such approximations can be disastrous in random number generation and some are very machine-specific [11]. In this paper we will concentrate on the coding considerations for a very portable speedup technique: i.e. applicable to any programming language and to any PRNG.
Section snippets
The unrolling technique applied to pseudo-random numbers generation
In every stochastic software and particularly if we deal with stochastic simulation, the number of calls to the pseudo-random generator is responsible for getting a great account of CPU resources [16]. In this paragraph we will describe the URNG implementation technique (unrolling random number generators) to optimize the access to random numbers of any generator. This method will be described hereafter as the “unrolling” method. It consists in generating automatically a source file containing
The need to apply this technique to different PRNGs
Knowing that there is no universal generator, it is strongly recommended to test a stochastic application with widely different PRNGs. They can be classified in four major classes: linear generators, lagged generators, inversive generators and mixed generators. It is interesting to maintain at least one large sequence file for each major type of generator. For instance, inversive generators are very interesting for verifying simulation results obtained with an linear congruential generator
Benchmark description
We have built a benchmark with several PRNGs on a simple Monte Carlo simulation (PI computation). The main goal of these tests was not to compute an approximated PI value, but rather to measure the average speed of the generators. We decided to compare the unrolling technique to two kinds of generators described in [22]: an ultra fast implementation of the “quick and dirty” generator (coded with a macroinstruction) and the shuffled version of ran2 in Numerical Recipies. After some preliminary
Conclusion
We have presented an implementation technique able to speed up software that makes an intensive use of PRNGs. The essence of speed is based on the unrolling optimization technique, and thus we named it the URNG technique (unrolled random number generator). With this technique, we obtain the same speedup ratio independently from the PRNG. Whatever the generation algorithm, arrays are generated and compiled to be present in memory after the loading of the executable program. Instead of computing
Acknowledgements
I would like to thank my research assistant Alexandre Roche, for his technical report, the implementation and testing on various computers of this speedup technique. In addition, the author would also like to thank the reviewers for their very informative contributions.
References (28)
Criteria for the assessment of random number generators
Journal of Computational and Applied Mathematics
(1990)- et al.
Neural networks metamodelling for the prediction of Caulerpa taxifolia development in the Mediterranean sea
Neurocomputing Letters, Neurocomputing
(2000) - et al.
Simulation of the mollusc Ascoglossa Elysia subornata population dynamics: application to the potential biocontrol of caulerpa taxifolia growth in the mediterranean sea
Ecological Modelling
(2000) - et al.
Optimization of random number generators: efficient search for high-quality LCGs
Probabilistic Engineering Mechanics
(2001) Computer implementation of random number generators
Journal of Computational and Applied Mathematics
(1990)A note on pseudorandom number generators
Simulation Practice and Theory
(1997)Good random number generators are (not so) easy to find
Mathematics and Computers in Simulation
(1998)- et al.
Acceleration of RANLUX
Computer Physics Communications
(1997) - et al.
The PLFG parallel pseudo-random number generator
Future Generation Computer Systems
(2002) Analysis of random number generators using Monte Carlo simulation
International Journal of Modern Physics C
(1994)
A non linear congruential pseudo random number generator
Statistical Papers
Explicit inversive congruential pseudorandom numbers: the compound approach
Computing
Statistical independence of a new class of inversive congruential pseudorandom numbers
Mathematics of Computation
Cited by (6)
Optimizing discrete modeling and simulation for real-time constraints with metaprogramming
2017, Real-Time Simulation Technologies: Principles, Methodologies, and ApplicationsARNG: Accelerating discrete event simulation RNGs by asynchronous random number generation
2016, European Simulation and Modelling Conference 2016, ESM 2016Distribution of random streams for simulation practitioners
2013, Concurrency and Computation: Practice and ExperiencePseudo-random streams for distributed and parallel stochastic simulations on GP-GPU
2012, Journal of SimulationPractical distribution of random streams for stochastic High Performance Computing
2010, Proceedings of the 2010 International Conference on High Performance Computing and Simulation, HPCS 2010