skip to main content
research-article
Open Access

LXM: better splittable pseudorandom number generators (and almost as fast)

Published:15 October 2021Publication History
Skip Abstract Section

Abstract

In 2014, Steele, Lea, and Flood presented SplitMix, an object-oriented pseudorandom number generator (prng) that is quite fast (9 64-bit arithmetic/logical operations per 64 bits generated) and also splittable. A conventional prng object provides a generate method that returns one pseudorandom value and updates the state of the prng; a splittable prng object also has a second operation, split, that replaces the original prng object with two (seemingly) independent prng objects, by creating and returning a new such object and updating the state of the original object. Splittable prng objects make it easy to organize the use of pseudorandom numbers in multithreaded programs structured using fork-join parallelism. This overall strategy still appears to be sound, but the specific arithmetic calculation used for generate in the SplitMix algorithm has some detectable weaknesses, and the period of any one generator is limited to 264.

Here we present the LXM family of prng algorithms. The idea is an old one: combine the outputs of two independent prng algorithms, then (optionally) feed the result to a mixing function. An LXM algorithm uses a linear congruential subgenerator and an F2-linear subgenerator; the examples studied in this paper use a linear congruential generator (LCG) of period 216, 232, 264, or 2128 with one of the multipliers recommended by L’Ecuyer or by Steele and Vigna, and an F2-linear xor-based generator (XBG) of the xoshiro family or xoroshiro family as described by Blackman and Vigna. For mixing functions we study the MurmurHash3 finalizer function; variants by David Stafford, Doug Lea, and degski; and the null (identity) mixing function.

Like SplitMix, LXM provides both a generate operation and a split operation. Also like SplitMix, LXM requires no locking or other synchronization (other than the usual memory fence after instance initialization), and is suitable for use with simd instruction sets because it has no branches or loops.

We analyze the period and equidistribution properties of LXM generators, and present the results of thorough testing of specific members of this family, using the TestU01 and PractRand test suites, not only on single instances of the algorithm but also for collections of instances, used in parallel, ranging in size from 2 to 224. Single instances of LXM that include a strong mixing function appear to have no major weaknesses, and LXM is significantly more robust than SplitMix against accidental correlation in a multithreaded setting. We believe that LXM, like SplitMix, is suitable for “everyday” scientific and machine-learning applications (but not cryptographic applications), especially when concurrent threads or distributed processes are involved.

Skip Supplemental Material Section

Supplemental Material

Auxiliary Presentation Video

Brief description of the LXM algorithm for pseudorandom number generation. Details are in the published conference paper at ACM OOPSLA 2021.

References

  1. Austin Appleby. 2011. MurmurHash3. 3 April 2011, https://github.com/aappleby/smhasher/wiki/MurmurHash3 Formerly at http://code.google.com/ p/ smhasher/ wiki/ MurmurHash3 Retrieved 10 Sept. 2013.Google ScholarGoogle Scholar
  2. Austin Appleby. 2016. SMHasher. 8 Jan. 2016, https://github.com/aappleby/smhasherGoogle ScholarGoogle Scholar
  3. David Blackman and Sebastiano Vigna. 2018. Scrambled Linear Pseudorandom Number Generators. 3 May 2018, 41 pages. arxiv:1805.01407 To appear in ACM Transactions on Mathematical Software.Google ScholarGoogle Scholar
  4. Lenore Blum, Manuel Blum, and Mike Shub. 1986. A simple unpredictable pseudo-random number generator. SIAM Journal on computing, 15, 2, 364–383.Google ScholarGoogle Scholar
  5. Manuel Blum and Silvio Micali. 1984. How to Generate Cryptographically Strong Sequences of Pseudorandom Bits. SIAM J. Comput., 13, 4, 850–864. https://doi.org/10.1137/0213053 Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Richard P. Brent. 2004. Note on Marsaglia’s Xorshift Random Number Generators. Journal of Statistical Software, 11, 5, Aug., 1–5. coden:JSSOBK https://doi.org/10.18637/jss.v011.i05 Google ScholarGoogle ScholarCross RefCross Ref
  7. Richard P. Brent. 2010. Some long-period random number generators using shifts and xors. 10 April 2010, 11 pages. arxiv:1004.3115Google ScholarGoogle Scholar
  8. Robert G. Brown, Dirk Eddelbuettel, and David Bauer. 2003–2006. Dieharder: A Random Number Test Suite, version 3.31.1. 2003, https://webhome.phy.duke.edu/~rgb/General/dieharder.phpGoogle ScholarGoogle Scholar
  9. Koen Claessen and Michał H. Pał ka. 2013. Splittable Pseudorandom Number Generators Using Cryptographic Hashing. In Proceedings of the 2013 ACM SIGPLAN Symposium on Haskell (Haskell ’13). Association for Computing Machinery, New York, New York, USA. Sept., 47–58. isbn:9781450323833 https://doi.org/10.1145/2503778.2503784 Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. R. R. Coveyou. 1969. Random Number Generation Is Too Important to Be Left to Chance. In Studies in Applied Mathematics 3, B. R. Agins and M. H. Kalos (Eds.). Society for Industrial and Applied Mathematics, Philadelphia, Pennsylvania, USA. 70–111. A collection of papers presented by invitations at the Symposia on Applied Probability and Monte Carlo Methods and Modern Aspects of Dynamics sponsored by the Air Force Office of Scentific Research at the 1967 National Meetings of SIAM in Washington, D.C., June 11–15, 1967.Google ScholarGoogle Scholar
  11. R. R. Coveyou and R. D. Macpherson. 1967. Fourier Analysis of Uniform Random Number Generators. J. ACM, 14, 1, Jan., 100–119. issn:0004-5411 https://doi.org/10.1145/321371.321379 Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. degski. 2018. invertibleḩar ’137hashḩar ’137functions.hpp. https://gist.github.com/degski/6e2069d6035ae04d5d6f64981c995ec2 23 March 2019, Code for four hash functions similar in structure to MurmurHash3.Google ScholarGoogle Scholar
  13. Chris Doty-Humphrey. 2011–2021. PractRand. 2011, http://pracrand.sourceforge.net/ Undated; the year 2011 for its first appearance has been inferred from external sources. The software is called “PractRand” but the SourceForge project name is “ pracrand”.Google ScholarGoogle Scholar
  14. Mark J. Durst. 1989. Using Linear Congruential Generators for Parallel Random Number Generation. In Proceedings of the 21st Conference on Winter Simulation (WSC ’89). Association for Computing Machinery, New York, New York, USA. 462–466. isbn:0911801588 https://doi.org/10.1145/76738.76798 Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Shlomo Engelberg. 2015. A Mathematical Introduction To Control Theory (second ed.) (Series in Electrical and Computer Engineering, Vol. 4). Imperial College Press, London, England. isbn:9781860945700Google ScholarGoogle Scholar
  16. Tommy Ettinger. 2019. PelicanRNG. 16 July 2019, https://github.com/tommyettinger/sarong/blob/master/src/main/java/sarong/PelicanRNG.java GitHub project; accessed April 2, 2021.Google ScholarGoogle Scholar
  17. Pelle Evensen. 2018. On the mixing functions in “Fast Splittable Pseudorandom Number Generators”, MurmurHash3 and David Stafford’s improved variants on the MurmurHash3 finalizer. 13 July 2018, http://mostlymangling.blogspot.com/2018/07/on-mixing-functions-in-fast-splittable.htmlGoogle ScholarGoogle Scholar
  18. Pelle Evensen. 2019. Better, stronger mixer and a test procedure. 24 Jan. 2019, http://mostlymangling.blogspot.com/2019/01/better-stronger-mixer-and-test-procedure.htmlGoogle ScholarGoogle Scholar
  19. Pelle Evensen. 2020. NASAM: Not Another Strange Acronym Mixer!. 3 Jan. 2020, http://mostlymangling.blogspot.com/2020/01/nasam-not-another-strange-acronym-mixer.htmlGoogle ScholarGoogle Scholar
  20. George E. Forsythe. 1951. Generation and Testing of Random Digits at the National Bureau of Standards, Los Angeles. In Monte Carlo Method, A. S. Householder, G. E. Forsythe, and H. H. Germond (Eds.) (National Bureau of Standards Applied Mathematics Series, Vol. 12). United States Government Printing Office, Washington, DC, USA. 11 June, 34–35. https://babel.hathitrust.org/cgi/pt?id=osu.32435030295547 Proceedings of a symposium held June 29, 30, and July 1, 1949, in Los Angeles, California, under the sponsorship of the RAND Corporation, and the National Bureau of Standards, with the cooperation of the Oak Ridge National Laboratory.Google ScholarGoogle Scholar
  21. Solomon W. Golomb. 2006. Shift Register Sequences: A Retrospective Account. In Sequences and Their Applications – SETA 2006, Guang Gong, Tor Helleseth, Hong-Yeop Song, and Kyeongcheol Yang (Eds.). Springer, Berlin and Heidelberg, Germany. 1–4. isbn:978-3-540-44524-1Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. Solomon W Golomb. 2017. Shift Register Sequences (3rd revised ed.). World Scientific, Hackensack, New Jersey, USA. isbn:978-9814632003 https://doi.org/10.1142/9361 See also first edition, 1967, Holden-Day, San Francisco, California, USA; second edition, 1982, Aegean Park Press, Laguna Hills, California, USA, ISBN 978-0894120480. Google ScholarGoogle ScholarCross RefCross Ref
  23. Mark Goresky and Andrew Klapper. 2012. Algebraic Shift Register Sequences. Cambridge University Press, Cambridge, UK. isbn:9781107014992Google ScholarGoogle Scholar
  24. Preston C. Hammer. 1951. The Mid-Square Method of Generating Digits. In Monte Carlo Method, A. S. Householder, G. E. Forsythe, and H. H. Germond (Eds.) (National Bureau of Standards Applied Mathematics Series, Vol. 12). United States Government Printing Office, Washington, DC, USA. 11 June, 33. https://babel.hathitrust.org/cgi/pt?id=osu.32435030295547 Proceedings of a symposium held June 29, 30, and July 1, 1949, in Los Angeles, California, under the sponsorship of the RAND Corporation, and the National Bureau of Standards, with the cooperation of the Oak Ridge National Laboratory.Google ScholarGoogle Scholar
  25. Donald E. Knuth. 1998. The Art of Computer Programming, Volume 2: Seminumerical Algorithms (third ed.). Addison-Wesley, Reading, Massachusetts, USA. isbn:9780201896848Google ScholarGoogle Scholar
  26. Doug Lea. 2013. SplittableRandom progress. 15 Nov. 2013, Series of three email messages on the subject of MurmurHash3-like mixing functions.Google ScholarGoogle Scholar
  27. Pierre L’Ecuyer. 1999. Good Parameters and Implementations for Combined Multiple Recursive Random Number Generators. Operations Research, 47, 1, Jan., 159–164. issn:0030-364X https://doi.org/10.1287/opre.47.1.159 Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. Pierre L’Ecuyer. 1999. Tables of Linear Congruential Generators of Different Sizes and Good Lattice Structure. Math. Comp., 68, 225, Jan., 249–260. issn:0025-5718 https://doi.org/10.1090/S0025-5718-99-00996-5 Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Pierre L’Ecuyer. 2017. History of Uniform Random Number Generation. In Proceedings of the 2017 Winter Simulation Conference (WSC), W. K. V. Chan, A. D’Ambrogio, G. Zacharewicz, N. Mustafee, G. Wainer, and E. Page (Eds.). IEEE, Dec., 202–230. https://doi.org/10.1109/WSC.2017.8247790 Google ScholarGoogle ScholarCross RefCross Ref
  30. Pierre L’Ecuyer and Jacinthe Granger-Piché. 2003. Combined generators with components from different families. Mathematics and Computers in Simulation, 62, 3, 3 March, 395–404. issn:0378-4754 https://doi.org/10.1016/S0378-4754(02)00234-3 3rd IMACS Seminar on Monte Carlo Methods. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. Pierre L’Ecuyer and François Panneton. 2009. F_2-Linear Random Number Generators. In Advancing the Frontiers of Simulation: A Festschrift in Honor of George Samuel Fishman, Christos Alexopoulos, David Goldsman, and James R. Wilson (Eds.) (International Series in Operations Research & Management Science, Vol. 133). Springer Science and Business Media, New York, New York, USA. 169–193. isbn:9781441908162 https://doi.org/10.1007/b110059_9 Google ScholarGoogle ScholarCross RefCross Ref
  32. Pierre L’Ecuyer and Richard Simard. 2007. TestU01: A C Library for Empirical Testing of Random Number Generators. ACM Trans. Math. Software, 33, 4, Aug., Article 22, 40 pages. issn:0098-3500 https://doi.org/10.1145/1268776.1268777 Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Pierre L’Ecuyer and Richard Simard. 2013. TestU01: A Software Library in ANSI C for Empirical Testing of Random Number Generators: User’s guide, compact version. 16 May 2013, http://simul.iro.umontreal.ca/testu01/guideshorttestu01.pdfGoogle ScholarGoogle Scholar
  34. D. H. Lehmer. 1951. Mathematical Methods in Large-Scale Computing Units. In Proceedings of a Second Symposium on Large-Scale Digital Calculating Machinery: Jointly Sponsored by The Navy Department Bureauof Ordnance and Harvard Universtiry at The Computation Laboratory, 13–16 September 1949 (The Annals of the Computation Laboratory of Harvard University, Vol. XXVI). Harvard University Press, Cambridge, Massachusetts, USA. 141–146. http://www.bitsavers.org/pdf/harvard/Proceedings_of_a_Second_Symposium_on_Large-Scale_Digital_Calculating_Machinery_Sep49.pdf 5 May 2010.Google ScholarGoogle Scholar
  35. Charles E. Leiserson, Tao B. Schardl, and Jim Sukha. 2012. Deterministic Parallel Random-Number Generation for Dynamic-Multithreading Platforms. In Proceedings of the 17th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming (PPoPP ’12). Association for Computing Machinery, New York, New York, USA. 193–204. isbn:9781450311601 https://doi.org/10.1145/2145816.2145841 Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Alex Losego. 2016. Super Mario World—Random Number Generation. YouTube. 5 Oct. 2016, https://youtu.be/q15yNrJHOakGoogle ScholarGoogle Scholar
  37. M. Donald MacLaren and George Marsaglia. 1965. Uniform Random Number Generators. J. ACM, 12, 1, Jan., 83–89. issn:0004-5411 https://doi.org/10.1145/321250.321257 Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. George Marsaglia. 1968. Random Numbers Fall Mainly in the Planes. Proceedings of the National Academy of Sciences of the United States of America, 61, 1, 25–28. issn:0027-8424 https://doi.org/10.1073/pnas.61.1.25 Google ScholarGoogle ScholarCross RefCross Ref
  39. George Marsaglia. 1985. A Current View Of Random Number Generators. In Computer Science and Statistics: Proceedings of the 16th Symposium on the Interface, Lynne Billard (Ed.). North-Holland/Elsevier Science Publishers BV, Amsterdam, The Netherlands. 3–10. isbn:978-0444877253 http://www.evensen.org/marsaglia/keynote.ps 19 July 2004, Keynote address.Google ScholarGoogle Scholar
  40. George Marsaglia. 1995. The Marsaglia Random Number CDROM including the Diehard Battery of Tests of Randomness. https://web.archive.org/web/20010515072724/http://www.stat.fsu.edu/pub/diehard/ Contents of a CD-ROM published in 1995.Google ScholarGoogle Scholar
  41. George Marsaglia. 2003. Xorshift RNGs. Journal of Statistical Software, 8, 14, 1–6. issn:1548-7660 https://doi.org/10.18637/jss.v008.i14 Google ScholarGoogle ScholarCross RefCross Ref
  42. George Marsaglia and Wai Wan Tsang. 2002. Some Difficult-to-Pass Tests of Randomness. Journal of Statistical Software, 7, 3, 1–9. issn:1548-7660 https://doi.org/10.18637/jss.v007.i03 Google ScholarGoogle ScholarCross RefCross Ref
  43. George Marsaglia and Arif Zaman. 1993. The KISS Generator. Florida State University, Tallahassee, Florida, USA.Google ScholarGoogle Scholar
  44. Bret Mulvey. 2016. Hash Functions. 2016, https://papa.bretmulvey.com/post/124027987928/hash-functionsGoogle ScholarGoogle Scholar
  45. Nintendo. 1990. Super Mario World. 21 Nov. 1990, Sold in the form of a proprietary cartridge.Google ScholarGoogle Scholar
  46. Oracle. 2014. Interface Spliterator<T>. https://docs.oracle.com/javase/8/docs/api/java/util/Spliterator.html 29 March 2014, Documentation for Java^ TM Platform Standard Ed. 8.Google ScholarGoogle Scholar
  47. Oracle Corporation. 2014. Java Platform Standard Edition 8 Documentation: Class Random. https://docs.oracle.com/javase/8/docs/api/java/util/Random.html 31 March 2014.Google ScholarGoogle Scholar
  48. Oracle Corporation. 2014. Java Platform Standard Edition 8 Documentation: Class SplittableRandom. https://docs.oracle.com/javase/8/docs/api/java/util/SplittableRandom.html 30 March 2014.Google ScholarGoogle Scholar
  49. Gregory G. Rose. 2018. KISS: A Bit Too Simple. Cryptography and Communications, 10, 123–137. issn:1936-2455 https://doi.org/10.1007/s12095-017-0225-x Includes the original code for Marsaglia and Zaman’s KISS generator. Google ScholarGoogle ScholarDigital LibraryDigital Library
  50. A. Rotenberg. 1960. A New Pseudo-Random Number Generator. J. ACM, 7, 1, Jan., 75–77. issn:0004-5411 https://doi.org/10.1145/321008.321019 Google ScholarGoogle ScholarDigital LibraryDigital Library
  51. Andrew Rukhin, Juan Soto, James Nechvatal, Miles Smid, Elaine Barker, Stefan Leigh, Mark Levenson, Mark Vangel, David Banks, Alan Heckert, James Dray, and San Vo. 2001. A Statistical Test Suite for Random and Pseudorandom Number Generators for Cryptographic Applications. Booz Allen and Hamilton Inc., McLean, Virginia, USA. https://apps.dtic.mil/sti/pdfs/ADA393366.pdf 13 Aug. 2021, With revisions dated May 15, 2001.Google ScholarGoogle Scholar
  52. Andrew Rukhin, Juan Soto, James Nechvatal, Miles Smid, Elaine Barker, Stefan Leigh, Mark Levenson, Mark Vangel, David Banks, Alan Heckert, James Dray, San Vo, and Lawrence E. Bassham III. 2010. A Statistical Test Suite for Random and Pseudorandom Number Generators for Cryptographic Applications. National Institute of Standards and Technology, United States Department of Commerce, Gaithersburg, Maryland, USA. April, 131. https://nvlpubs.nist.gov/nistpubs/Legacy/SP/nistspecialpublication800-22r1a.pdfGoogle ScholarGoogle Scholar
  53. John K. Salmon, Mark A. Moraes, Ron O. Dror, and David E. Shaw. 2011. Parallel Random Numbers: As Easy as 1, 2, 3. In Proceedings of 2011 International Conference for High Performance Computing, Networking, Storage and Analysis (SC ’11). Association for Computing Machinery, New York, New York, USA. Article 16, 12 pages. isbn:9781450307710 https://doi.org/10.1145/2063384.2063405 Google ScholarGoogle ScholarDigital LibraryDigital Library
  54. Hans Georg Schaathun. 2015. Evaluation of splittable pseudo-random generators. Journal of Functional Programming, 25, 17 June, Article e6, 19 pages. https://doi.org/10.1017/S095679681500012X Google ScholarGoogle ScholarCross RefCross Ref
  55. Richard Simard. 2009. TestU01 version 1.2.3. Aug. 2009, http://simul.iro.umontreal.ca/testu01/tu01.htmlGoogle ScholarGoogle Scholar
  56. Guy Steele and Sebastiano Vigna. 2021. Computationally Easy, Spectrally Good Multipliers for Congruential Pseudorandom Number Generators. 22 Jan. 2021, 23 pages. arxiv:2001.05304Google ScholarGoogle Scholar
  57. Guy L. Steele Jr., Doug Lea, and Christine H. Flood. 2014. Fast Splittable Pseudorandom Number Generators. In OOPSLA ’14: Proceedings of the 2014 ACM International Conference on Object-oriented Programming, Systems, Languages, and Applications (OOPSLA ’14). ACM, New York, New York, USA. 453–472. isbn:9781450325851 https://doi.org/10.1145/2660193.2660195 Google ScholarGoogle ScholarDigital LibraryDigital Library
  58. W. E. Thomson. 1958. A Modified Congruence Method of Generating Pseudo-random Numbers. Comput. J., 1, 2, 83, 86. issn:0010-4620 https://doi.org/10.1093/comjnl/1.2.83 Google ScholarGoogle ScholarCross RefCross Ref
  59. Sebastiano Vigna. 2014–2021. xoshiro / xoroshiro generators and the PRNG shootout. 2014, https://prng.di.unimi.it/Google ScholarGoogle Scholar
  60. John von Neumann. 1951. Various Techniques Used in Connection with Random Digits. In Monte Carlo Method, A. S. Householder, G. E. Forsythe, and H. H. Germond (Eds.) (National Bureau of Standards Applied Mathematics Series, Vol. 12). United States Government Printing Office, Washington, DC, USA. 11 June, 36–38. https://dornsifecms.usc.edu/assets/sites/520/docs/VonNeumann-ams12p36-38.pdf Proceedings of a symposium held June 29, 30, and July 1, 1949, in Los Angeles, California, under the sponsorship of the RAND Corporation, and the National Bureau of Standards, with the cooperation of the Oak Ridge National Laboratory.Google ScholarGoogle Scholar
  61. John Walker. 1996. HotBits: Genuine random numbers, generated by radioactive decay. May 1996, http://www.fourmilab.ch/hotbits/Google ScholarGoogle Scholar
  62. Tony T. Warnock. 1983. Synchronization of random number generators. Congressus numerantium, 37, 135–144.Google ScholarGoogle Scholar
  63. Henry S. Warren, Jr.. 2012. Hacker’s Delight. Pearson Education, Boston, Massachusetts, USA. isbn:9780133085013Google ScholarGoogle Scholar
  64. Chris Wellons. 2018. Prospecting for Hash Functions. 31 July 2018, https://nullprogram.com/blog/2018/07/31/Google ScholarGoogle Scholar
  65. Christopher Wellons. 2019. Hash Function Prospector. March 2019, https://github.com/skeeto/hash-prospectorGoogle ScholarGoogle Scholar
  66. Stephen Wolfram. 2016. Solomon Golomb (1932–2016). 25 May 2016, https://writings.stephenwolfram.com/2016/05/solomon-golomb-19322016/Google ScholarGoogle Scholar

Index Terms

  1. LXM: better splittable pseudorandom number generators (and almost as fast)

      Recommendations

      Comments

      Login options

      Check if you have access through your login credentials or your institution to get full access on this article.

      Sign in

      Full Access

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader
      About Cookies On This Site

      We use cookies to ensure that we give you the best experience on our website.

      Learn more

      Got it!