The I/O Complexity of Computing Prime Tables
We revisit classical sieves for computing primes and analyze their performance in the external-memory model. Most prior sieves are analyzed in the RAM model, where the focus is on minimizing both the total number of operations and the size of the working set. The hope is that if the working set fits in RAM, then the sieve will have good I/O performance, though such an outcome is by no means guaranteed by a small working-set size.
We analyze our algorithms directly in terms of I/Os and operations. In the external-memory model, permutation can be the most expensive aspect of sieving, in contrast to the RAM model, where permutations are trivial. We show how to implement classical sieves so that they have both good I/O performance and good RAM performance, even when the problem size N becomes huge—even superpolynomially larger than RAM. Towards this goal, we give two I/O-efficient priority queues that are optimized for the operations incurred by these sieves.
KeywordsExternal-memory algorithms Prime tables Sorting Priority queues
We thank Oleksii Starov for suggesting this problem to us.
- 4.Arge, L., Bender, M.A., Demaine, E.D., Holland-Minkley, B., Munro, J.I.: Cache-oblivious priority queue and graph algorithm applications. In: Proceedings of the 34th Annual Symposium on Theory of Computing, pp. 268–276 (2002)Google Scholar
- 10.Cox, D.A.: Primes of the Form \(x^2+ny^2\): Fermat, Class Field Theory, and Complex Multiplication. Wiley, New York (1989)Google Scholar
- 13.Gale, R., Pratt, V.: CGOL-an Algebraic Notation for MACLISP Users. MIT Artificial Intelligence Library, Cambridge (1977)Google Scholar
- 21.News, F.: World’s largest prime number discovered - all 17 million digits, February 2013. https://web.archive.org/web/20130205223234/, http://www.foxnews.com/science/2013/02/05/worlds-largest-prime-number-discovered/
- 22.Patrascu, M., Thorup, M., Dynamic integer sets with optimal rank, select, predecessor search. In: FOCS, pp. 166–175 (2014)Google Scholar
- 24.Pomerance, C., Shparlinski, I.E.: On pseudosquares and pseudopowers. Comb. Number Theor., 171–184 (2009)Google Scholar
- 28.Schönhage, A., Grotefeld, A., Vetter, E.: Fast algorithms: a multitape turing machine implementation. Wissenschaftsverlag, B.I (1994)Google Scholar
- 30.Sorenson, J.: An introduction to prime number sieves. Technical report 909, Computer Sciences Department, University of Wisconsin-Madison (1990)Google Scholar
- 32.Villarino, M.B.: Mertens’ proof of mertens’ theorem. arXiv:math/0504289 (2005)
- 34.Williams, H.C.: Edouard Lucas and primality testing. Canadian Mathematics Society Series of Monographs and Advanced Texts, 22 (1998)Google Scholar