skip to main content
research-article

Cache and I/O efficent functional algorithms

Published:23 January 2013Publication History
Skip Abstract Section

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.

Skip Supplemental Material Section

Supplemental Material

r2d1_talk1.mp4

References

  1. J. Abello, A. L. Buchsbaum, and J. Westbrook. A functional approach to external graph algorithms. Algorithmica, 32 (3): 437--458, 2002.Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. A. Aggarwal and J. S. Vitter. The input/output complexity of sorting and related problems. Commun. ACM, 31 (9): 1116--1127, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. A. W. Appel. Garbage collection can be faster than stack allocation. Inf. Process. Lett., 25 (4): 275--279, 1987. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle Scholar
  5. G. E. Blelloch and J. Greiner. Parallelism in sequential functional languages. In FPCA, pages 226--237, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. R. Courts. Improving locality of reference in a garbage-collecting memory management system. Commun. ACM, 31 (9): 1128--1138, 1988. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. M. Frigo, C. E. Leiserson, H. Prokop, and S. Ramachandran. Cache-oblivious algorithms. In FOCS, pages 285--298. IEEE Computer Society, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. R. Harper. Practical Foundations for Programming Languages. Cambridge University Press, 2013. (Draft available at http://www.cs.cmu.edu/ rwh/plbook/book.pdf.). Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. R. Jones and R. Lins. Garbage Collection: Algorithms for Automatic Dynamic Memory Management. Wiley, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. J. G. Morrisett, M. Felleisen, and R. Harper. Abstract models of memory management. In FPCA, pages 66--77, 1995. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. G. D. Plotkin. LCF considered as a programming language. Theor. Comput. Sci., 5 (3): 223--255, 1977.Google ScholarGoogle ScholarCross RefCross Ref
  19. 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 ScholarGoogle Scholar
  20. D. D. Sleator and R. E. Tarjan. Amortized efficiency of list update and paging rules. Commun. ACM, 28 (2): 202--208, 1985. Google ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. J. S. Vitter. Algorithms and data structures for external memory. Foundations and Trends in Theoretical Computer Science, 2 (4): 305--474, 2006. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Cache and I/O efficent functional algorithms

      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

      • Published in

        cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 48, Issue 1
        POPL '13
        January 2013
        561 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2480359
        Issue’s Table of Contents
        • cover image ACM Conferences
          POPL '13: Proceedings of the 40th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
          January 2013
          586 pages
          ISBN:9781450318327
          DOI:10.1145/2429069

        Copyright © 2013 ACM

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 23 January 2013

        Check for updates

        Qualifiers

        • research-article

      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!