skip to main content
10.1145/3122948.3122949acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Destination-passing style for efficient memory management

Published:07 September 2017Publication History

ABSTRACT

We show how to compile high-level functional array-processing programs, drawn from image processing and machine learning, into C code that runs as fast as hand-written C. The key idea is to transform the program to destination-passing style, which in turn enables a highly-efficient stack-like memory allocation discipline.

References

  1. Johan Anker and Josef Svenningsson. 2013. An EDSL approach to high performance Haskell programming. In ACM Haskell Symposium. 1–12. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Henry G Baker. 1992. Lively linear lisp: ‘look ma, no garbage!’. ACM Sigplan notices 27, 8 (1992), 89–98. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Lars Birkedal, Mads Tofte, and Magnus Vejlstrup. 1996. From Region Inference to Von Neumann Machines via Region Representation Inference (POPL ’96). ACM, NY, USA, 171–183. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Charisee Chiw, Gordon Kindlmann, John Reppy, Lamont Samuels, and Nick Seltzer. 2012. Diderot: A Parallel DSL for Image Analysis and Visualization (PLDI ’12). ACM, 111–120. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. Koen Claessen, Mary Sheeran, and Bo Joel Svensson. 2012. Expressive Array Constructs in an Embedded GPU Kernel Programming Language (DAMP ’12). ACM, NY, USA, 21–30. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. Duncan Coutts, Roman Leshchinskiy, and Don Stewart. Stream Fusion. From Lists to Streams to Nothing at All (ICFP ’07). Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Cormac Flanagan, Amr Sabry, Bruce F Duba, and Matthias Felleisen. 1993. The essence of compiling with continuations. In ACM Sigplan Notices, Vol. 28. ACM, 237–247. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Matthew Fluet, Greg Morrisett, and Amal Ahmed. 2006. Linear regions are all you need (ESOP ’06). Springer, 7–21. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. D Friedman and S Wise. 1975. Unwinding stylized recursions into iterations. Comput. Sci. Dep., Indiana University, Bloomington, IN, Tech. Rep 19 (1975).Google ScholarGoogle Scholar
  10. Andrew Gill, John Launchbury, and Simon L Peyton Jones. 1993. A short cut to deforestation (FPCA). ACM, 223–232. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Clemens Grelck and Sven-Bodo Scholz. 2006. SAC—A Functional Array Language for Efficient Multi-threaded Execution. Int. Journal of Parallel Programming 34, 4 (2006), 383–427. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Dan Grossman, Greg Morrisett, Trevor Jim, Michael Hicks, Yanling Wang, and James Cheney. 2002. Region-based Memory Management in Cyclone (PLDI ’02). ACM, NY, USA, 282–293. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Gaël Guennebaud, Benoit Jacob, and others. 2010. Eigen. URl: http://eigen. tuxfamily. org (2010).Google ScholarGoogle Scholar
  14. Niels Hallenberg, Martin Elsman, and Mads Tofte. 2002. Combining Region Inference and Garbage Collection (PLDI ’02). ACM, NY, USA, 141–152. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. Troels Henriksen, Martin Elsman, and Cosmin E. Oancea. 2014. Size Slicing: A Hybrid Approach to Size Inference in Futhark (FHPC ’14). ACM, New York, NY, USA, 31–42. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. Troels Henriksen and Cosmin E. Oancea. 2014. Bounds Checking: An Instance of Hybrid Analysis (ARRAY ’14). ACM, NY, USA.Google ScholarGoogle Scholar
  17. Troels Henriksen, Niels G. W. Serup, Martin Elsman, Fritz Henglein, and Cosmin E. Oancea. 2017. Futhark: Purely Functional GPU-programming with Nested Parallelism and In-place Array Updates (PLDI 2017). ACM, New York, NY, USA, 556–571. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. Martin Hofmann and Steffen Jost. 2003. Static Prediction of Heap Space Usage for First-order Functional Programs (POPL ’03). ACM, New York, NY, USA, 185–197. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Kenneth E Iverson. 1962. A Programming Language. In Proceedings of the May 1-3, 1962, spring joint computer conference. ACM, 345–351. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. C Barry Jay. 1999. Programming in FISh. International Journal on Software Tools for Technology Transfer 2, 3 (1999), 307–315.Google ScholarGoogle ScholarCross RefCross Ref
  21. C. Barry Jay and Milan Sekanina. 1997. Shape Checking of Array Programs. Technical Report. In Computing: the Australasian Theory Seminar, Proceedings.Google ScholarGoogle Scholar
  22. Oleg Kiselyov and Chung-chieh Shan. 2008. Lightweight monadic regions. In ACM Sigplan Notices, Vol. 44. ACM, 1–12. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. James R Larus. 1989. Restructuring symbolic programs for concurrent execution on multiprocessors. Ph.D. Dissertation. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Yasuhiko Minamide. 1998. A Functional Representation of Data Structures with a Hole (POPL ’98). 75–84. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Manuel Montenegro, Ricardo Peña, and Clara Segura. 2008. A type system for safe memory management and its proof of correctness (PPDP ’08). ACM, 152–162. Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Manuel Montenegro, Ricardo Peña, and Clara Segura. 2009. A simple region inference algorithm for a first-order functional language. In International Workshop on Functional and Constraint Logic Programming. Springer, 145–161. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Markus Puschel, José MF Moura, Jeremy R Johnson, David Padua, Manuela M Veloso, Bryan W Singer, Jianxin Xiong, Franz Franchetti, Aca Gacic, Yevgen Voronenko, and others. 2005. SPIRAL: Code generation for DSP transforms. Proc. IEEE 93, 2 (2005), 232–275.Google ScholarGoogle ScholarCross RefCross Ref
  28. Jonathan Ragan-Kelley, Connelly Barnes, Andrew Adams, Sylvain Paris, Frédo Durand, and Saman Amarasinghe. 2013. Halide: A Language and Compiler for Optimizing Parallelism, Locality, and Recomputation in Image Processing Pipelines (PLDI ’13). Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Daniele G Spampinato and Markus Püschel. A basic linear algebra compiler for structured matrices. In CGO ’16. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. Filip Srajer, Zuzana Kukelova, and Andrew Fitzgibbon. 2016. A Benchmark of Selected Algorithmic Differentiation Tools on Some Problems in Machine Learning and Computer Vision. (2016).Google ScholarGoogle Scholar
  31. Arvind Sujeeth, HyoukJoong Lee, Kevin Brown, Tiark Rompf, Hassan Chafi, Michael Wu, Anand Atreya, Martin Odersky, and Kunle Olukotun. 2011. OptiML: An Implicitly Parallel Domain-Specific Language for Machine Learning (ICML ’11). 609–616. Google ScholarGoogle ScholarDigital LibraryDigital Library
  32. Josef Svenningsson. 2002. Shortcut Fusion for Accumulating Parameters & Zip-like Functions (ICFP ’02). ACM, 124–132. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. Bo Joel Svensson and Josef Svenningsson. 2014. Defunctionalizing Push Arrays (FHPC ’14). ACM, NY, USA, 43–52.Google ScholarGoogle Scholar
  34. Don Syme. 2006. Leveraging .NET Meta-programming Components from F#: Integrated Queries and Interoperable Heterogeneous Execution (ML ’06). ACM, 43–54. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. Jonathan Taylor, Richard Stebbing, Varun Ramakrishna, Cem Keskin, Jamie Shotton, Shahram Izadi, Aaron Hertzmann, and Andrew Fitzgibbon. 2014. Userspecific hand modeling from monocular depth sequences (CVPR ’14). 644–651. Google ScholarGoogle ScholarDigital LibraryDigital Library
  36. Mads Tofte, Lars Birkedal, Martin Elsman, and Niels Hallenberg. 2004. A Retrospective on Region-Based Memory Management. Higher Order Symbol. Comput. 17, 3 (Sept. 2004), 245–265. Google ScholarGoogle ScholarDigital LibraryDigital Library
  37. Mads Tofte and Jean-Pierre Talpin. 1997. Region-Based Memory Management. Information and Computation 132, 2 (1997). Google ScholarGoogle ScholarDigital LibraryDigital Library
  38. Bill Triggs, Philip F McLauchlan, Richard I Hartley, and Andrew W Fitzgibbon. 1999. Bundle adjustment—a modern synthesis. In Inter. workshop on vision algorithms. Springer, 298–372. Google ScholarGoogle ScholarDigital LibraryDigital Library
  39. Pedro B Vasconcelos. 2008. Space cost analysis using sized types. Ph.D. Dissertation. University of St Andrews.Google ScholarGoogle Scholar
  40. Philip Wadler. 1984. Listlessness is better than laziness: Lazy evaluation and garbage collection at compile-time. In Proc. of ACM Symp. on LISP and functional programming. 45–52. Google ScholarGoogle ScholarDigital LibraryDigital Library
  41. Philip Wadler. 1988. Deforestation: Transforming programs to eliminate trees. In ESOP’88. Springer, 344–358. Google ScholarGoogle ScholarDigital LibraryDigital Library
  42. Philip Wadler. 1990. Linear types can change the world. In IFIP TC, Vol. 2. Citeseer, 347–359.Google ScholarGoogle Scholar
  43. David Walker and Greg Morrisett. 2000. Alias types for recursive data structures. In Inter. Workshop on Types in Compilation. Springer, 177–206. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Destination-passing style for efficient memory management

      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
      • Published in

        cover image ACM Conferences
        FHPC 2017: Proceedings of the 6th ACM SIGPLAN International Workshop on Functional High-Performance Computing
        September 2017
        52 pages
        ISBN:9781450351812
        DOI:10.1145/3122948

        Copyright © 2017 ACM

        Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

        Publisher

        Association for Computing Machinery

        New York, NY, United States

        Publication History

        • Published: 7 September 2017

        Permissions

        Request permissions about this article.

        Request Permissions

        Check for updates

        Qualifiers

        • research-article

        Acceptance Rates

        Overall Acceptance Rate18of25submissions,72%

        Upcoming Conference

        ICFP '24

      PDF Format

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader