ABSTRACT
The widely studied I/O and ideal-cache models were developed to account for the large difference in costs to access memory at different levels of the memory hierarchy. Both models are based on a two level memory hierarchy with a fixed size primary memory(cache) of size M, an unbounded secondary memory organized in blocks of size B. The cost measure is based purely on the number of block transfers between the primary and secondary memory. All other operations are free. Many algorithms have been analyzed in these models and indeed these models predict the relative performance of algorithms much more accurately than the standard RAM model. The models, however, require specifying algorithms at a very low level requiring the user to carefully lay out their data in arrays in memory and manage their own memory allocation.
In this paper we present a cost model for analyzing the memory efficiency of algorithms expressed in a simple functional language. We show how some algorithms written in standard forms using just lists and trees (no arrays) and requiring no explicit memory layout or memory management are efficient in the model. We then describe an implementation of the language and show provable bounds for mapping the cost in our model to the cost in the ideal-cache model. These bound imply that purely functional programs based on lists and trees with no special attention to any details of memory layout can be as asymptotically as efficient as the carefully designed imperative I/O efficient algorithms. For example we describe an O(n_B logM/Bn_B)cost sorting algorithm, which is optimal in the ideal cache and I/O models.
Supplemental Material
References
- J. Abello, A. L. Buchsbaum, and J. Westbrook. A functional approach to external graph algorithms. Algorithmica, 32 (3): 437--458, 2002.Google Scholar
Digital Library
- A. Aggarwal and J. S. Vitter. The input/output complexity of sorting and related problems. Commun. ACM, 31 (9): 1116--1127, 1988. Google Scholar
Digital Library
- A. W. Appel. Garbage collection can be faster than stack allocation. Inf. Process. Lett., 25 (4): 275--279, 1987. Google Scholar
Digital Library
- L. Arge, M. A. Bender, E. D. Demaine, C. E. Leiserson, and K. Mehlhorn, editors. Cache-Oblivious and Cache-Aware Algorithms, 18.07. - 23.07.2004, volume 04301 of Dagstuhl Seminar Proceedings, 2005. IBFI, Schloss Dagstuhl, Germany.Google Scholar
- G. E. Blelloch and J. Greiner. Parallelism in sequential functional languages. In FPCA, pages 226--237, 1995. Google Scholar
Digital Library
- Y.-J. Chiang, M. T. Goodrich, E. F. Grove, R. Tamassia, D. E. Vengroff, and J. S. Vitter. External-memory graph algorithms. In K. L. Clarkson, editor, SODA, pages 139--149. ACM/SIAM, 1995. ISBN 0--89871--349--8. Google Scholar
Digital Library
- T. M. Chilimbi and J. R. Larus. Using generational garbage collection to implement cache-conscious data placement. In S. L. P. Jones and R. E. Jones, editors, ISMM, pages 37--48. ACM, 1998. ISBN 1--58113--114--3. Google Scholar
Digital Library
- R. Courts. Improving locality of reference in a garbage-collecting memory management system. Commun. ACM, 31 (9): 1128--1138, 1988. Google Scholar
Digital Library
- M. Frigo, C. E. Leiserson, H. Prokop, and S. Ramachandran. Cache-oblivious algorithms. In FOCS, pages 285--298. IEEE Computer Society, 1999. Google Scholar
Digital Library
- M. T. Goodrich, J.-J. Tsay, D. E. Vengroff, and J. S. Vitter. External-memory computational geometry (preliminary version). In FOCS, pages 714--723. IEEE Computer Society, 1993. Google Scholar
Digital Library
- J. Greiner and G. E. Blelloch. A provably time-efficient parallel implementation of full speculation. ACM Trans. Program. Lang. Syst., 21 (2): 240--285, 1999. Google Scholar
Digital Library
- D. Grunwald, B. G. Zorn, and R. Henderson. Improving the cache locality of memory allocation. In R. Cartwright, editor, PLDI, pages 177--186. ACM, 1993. ISBN 0--89791--598--4. Google Scholar
Digital Library
- R. Harper. Practical Foundations for Programming Languages. Cambridge University Press, 2013. (Draft available at http://www.cs.cmu.edu/ rwh/plbook/book.pdf.). Google Scholar
Digital Library
- R. Jones and R. Lins. Garbage Collection: Algorithms for Automatic Dynamic Memory Management. Wiley, 1996. Google Scholar
Digital Library
- U. Meyer, P. Sanders, and J. F. Sibeyn, editors. Algorithms for Memory Hierarchies, Advanced Lectures {Dagstuhl Research Seminar, March 10--14, 2002}, volume 2625 of Lecture Notes in Computer Science, 2003. Springer. ISBN 3--540-00883--7. Google Scholar
Digital Library
- J. G. Morrisett, M. Felleisen, and R. Harper. Abstract models of memory management. In FPCA, pages 66--77, 1995. Google Scholar
Digital Library
- K. Munagala and A. G. Ranade. I/o-complexity of graph algorithms. In R. E. Tarjan and T. Warnow, editors, SODA, pages 687--694. ACM/SIAM, 1999. ISBN 0--89871--434--6. Google Scholar
Digital Library
- G. D. Plotkin. LCF considered as a programming language. Theor. Comput. Sci., 5 (3): 223--255, 1977.Google Scholar
Cross Ref
- M. Rahn, P. Sanders, and J. Singler. Scalable distributed-memory external sorting. In F. Li, M. M. Moro, S. Ghandeharizadeh, J. R. Haritsa, G. Weikum, M. J. Carey, F. Casati, E. Y. Chang, I. Manolescu, S. Mehrotra, U. Dayal, and V. J. Tsotras, editors, ICDE, pages 685--688. IEEE, 2010. ISBN 978--1--4244--5444-0.Google Scholar
- D. D. Sleator and R. E. Tarjan. Amortized efficiency of list update and paging rules. Commun. ACM, 28 (2): 202--208, 1985. Google Scholar
Digital Library
- D. Spoonhower, G. E. Blelloch, R. Harper, and P. B. Gibbons. Space profiling for parallel functional programs. In J. Hook and P. Thiemann, editors, ICFP, pages 253--264. ACM, 2008. ISBN 978--1--59593--919--7. Google Scholar
Digital Library
- J. S. Vitter. Algorithms and data structures for external memory. Foundations and Trends in Theoretical Computer Science, 2 (4): 305--474, 2006. Google Scholar
Digital Library
- P. R. Wilson, M. S. Lam, and T. G. Moher. Caching considerations for generational garbage collection. In LISP and Functional Programming, pages 32--42, 1992. Google Scholar
Digital Library
Index Terms
Cache and I/O efficent functional algorithms






Comments