Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/3564719.3568698acmconferencesArticle/Chapter ViewAbstractPublication PagesConference Proceedingsacm-pubtype
research-article

Deep Fusion for Efficient Nested Recursive Computations

Published: 01 December 2022 Publication History
  • Get Citation Alerts
  • Abstract

    One of the performance bottlenecks of nested recursive computations is the intermediate collections created at different levels of recursion. The existing techniques such as vertical and horizontal loop fusion do not remove such intermediate allocations. This paper proposes deep fusion, a technique for the efficient compilation of nested recursive computation over collections. The input to our compilation framework is a high-level functional program that can represent computations on flat and nested collections such as lists, sets, bags, and maps. The intermediate collections are removed in three levels. First, the immutable collections are translated into mutable ones by leveraging in-place updates using the destination-passing style technique. Second, deep fusion enables the inner level of recursion to reuse the destinations of the outer levels for in-place updates. Third, deep fusion removes the need to allocate tiny intermediate collections at different depths of recursion. Our experiments show that deep fusion can improve the performance of nested recursion over nested lists and maps.

    References

    [1]
    Johan Anker and Josef Svenningsson. 2013. An EDSL approach to high performance Haskell programming. In ACM Haskell Symposium. ACM, New York, NY, USA. 1–12.
    [2]
    Emil Axelsson, Koen Claessen, Mary Sheeran, Josef Svenningsson, David Engdal, and Anders Persson. 2011. The Design and Implementation of Feldspar an Embedded Language for Digital Signal Processing. In Proceedings of the 22Nd International Conference on Implementation and Application of Functional Languages (IFL’10). Springer-Verlag, Berlin, Heidelberg. 121–136. isbn:978-3-642-24275-5
    [3]
    Richard S Bird. 1987. An introduction to the theory of lists. In Logic of programming and calculi of discrete design. Springer, 5–42.
    [4]
    Frédéric Bour, Basile Clément, and Gabriel Scherer. 2021. Tail Modulo Cons. arXiv preprint arXiv:2102.09823.
    [5]
    Val Breazu-Tannen, Peter Buneman, and Limsoon Wong. 1992. Naturally embedded query languages. Springer.
    [6]
    Val Breazu-Tannen and Ramesh Subrahmanyam. 1991. Logical and computational aspects of programming with sets/bags/lists. Springer.
    [7]
    Peter Buneman, Shamim Naqvi, Val Tannen, and Limsoon Wong. 1995. Principles of Programming with Complex Objects and Collection Types. Theor. Comput. Sci., 149, 1 (1995), Sept., 3–48. issn:0304-3975
    [8]
    Alexander Bunkenburg. 1994. The boom hierarchy. In Functional Programming, Glasgow 1993. Springer, 1–8.
    [9]
    Koen Claessen, Mary Sheeran, and Bo Joel Svensson. 2012. Expressive Array Constructs in an Embedded GPU Kernel Programming Language. In Proceedings of the 7th Workshop on Declarative Aspects and Applications of Multicore Programming (DAMP ’12). ACM, NY, USA. 21–30.
    [10]
    Duncan Coutts, Roman Leshchinskiy, and Don Stewart. 2007. Stream Fusion. From Lists to Streams to Nothing at All. In ICFP ’07.
    [11]
    Saumya K. Debray. 1985. Optimizing almost-tail-recursive prolog programs. In Functional Programming Languages and Computer Architecture, Jean-Pierre Jouannaud (Ed.). Springer Berlin Heidelberg, Berlin, Heidelberg. 204–219. isbn:978-3-540-39677-2
    [12]
    Andrew Farmer, Christian Höner zu Siederdissen, and Andy Gill. 2014. The HERMIT in the stream: fusing stream fusion’s concatMap. In Proceedings of the ACM SIGPLAN 2014 workshop on Partial evaluation and program manipulation, PEPM 2014, January 20-21, 2014, San Diego, California, USA, Wei-Ngan Chin and Jurriaan Hage (Eds.). ACM, 97–108. https://doi.org/10.1145/2543728.2543736
    [13]
    Leonidas Fegaras. 2017. An algebra for distributed Big Data analytics. J. Funct. Program., 27 (2017), e27. https://doi.org/10.1017/S0956796817000193
    [14]
    Leonidas Fegaras and David Maier. 2000. Optimizing Object Queries Using an Effective Calculus. ACM Trans. Database Syst., 25, 4 (2000), Dec., 457–516. issn:0362-5915
    [15]
    Andrew Gill, John Launchbury, and Simon L Peyton Jones. 1993. A short cut to deforestation. In Proceedings of the conference on Functional programming languages and computer architecture (FPCA). 223–232.
    [16]
    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. issn:1573-7640
    [17]
    Torsten Grust and MarcH. Scholl. 1999. How to Comprehend Queries Functionally. Journal of Intelligent Information Systems, 12, 2-3 (1999), 191–218. issn:0925-9902
    [18]
    Troels Henriksen, Niels GW Serup, Martin Elsman, Fritz Henglein, and Cosmin E Oancea. 2017. Futhark: purely functional GPU-programming with nested parallelism and in-place array updates. In Proceedings of the 38th ACM SIGPLAN Conference on Programming Language Design and Implementation. 556–571.
    [19]
    Paul Hudak. 1996. Building domain-specific embedded languages. ACM Computing Surveys (CSUR), 28, 4es (1996), 196.
    [20]
    Kenneth E Iverson. 1962. A Programming Language. In Proceedings of the May 1-3, 1962, spring joint computer conference. 345–351.
    [21]
    Oleg Kiselyov. 2018. Reconciling Abstraction with High Performance: A MetaOCaml approach. Foundations and Trends in Programming Languages, 5, 1 (2018), 1–101.
    [22]
    Oleg Kiselyov, Aggelos Biboudis, Nick Palladinos, and Yannis Smaragdakis. 2017. Stream Fusion, to Completeness. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages (POPL 2017). ACM, New York, NY, USA. 285–299. isbn:978-1-4503-4660-3
    [23]
    Leonid Libkin and Limsoon Wong. 1997. Query languages for bags and aggregate functions. Journal of Computer and System sciences, 55, 2 (1997), 241–272.
    [24]
    LGLT Meertens. 1986. Algorithmics: Towards programming as a mathematical activity.
    [25]
    Erik Meijer, Brian Beckman, and Gavin Bierman. 2006. LINQ: Reconciling Object, Relations and XML in the .NET Framework. In Proceedings of the 2006 ACM SIGMOD International Conference on Management of Data (SIGMOD ’06). ACM, 706–706. isbn:1-59593-434-0
    [26]
    Thomas Neumann. 2011. Efficiently Compiling Efficient Query Plans for Modern Hardware. PVLDB, 4, 9 (2011), 539–550.
    [27]
    Lionel Parreaux. 2021. Comprehending Monoids with Class. In DBPL ’21: The 18th International Symposium on Database Programming Languages, Copenhagen, Denmark, 16 August 2021, Amir Shaikhha and Norman May (Eds.). ACM, 17–22. https://doi.org/10.1145/3475726.3475728
    [28]
    Lionel Parreaux, Amir Shaikhha, and Christoph E. Koch. 2017. Quoted Staged Rewriting: A Practical Approach to Library-defined Optimizations. In Proceedings of the 16th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences (GPCE 2017). ACM, New York, NY, USA. 131–145. isbn:978-1-4503-5524-7
    [29]
    Lionel Parreaux, Antoine Voizard, Amir Shaikhha, and Christoph E. Koch. 2017. Unifying Analytic and Statically-typed Quasiquotes. Proc. ACM Program. Lang., 2, POPL (2017), Article 13, Dec., 33 pages. issn:2475-1421
    [30]
    Tore Risch. 1973. REMREC, a program for automatic recursion removal in LISP. Univ.
    [31]
    Mark A Roth, Herry F Korth, and Abraham Silberschatz. 1988. Extended algebra and calculus for nested relational databases. ACM Transactions on Database Systems (TODS), 13, 4 (1988), 389–417.
    [32]
    Amir Shaikhha, Mohammad Dashti, and Christoph Koch. 2018. Push versus Pull-Based Loop Fusion in Query Engines. Journal of Functional Programming, 28 (2018), e10.
    [33]
    Amir Shaikhha, Andrew Fitzgibbon, Simon Peyton Jones, and Dimitrios Vytiniotis. 2017. Destination-passing Style for Efficient Memory Management. In Proceedings of the 6th ACM SIGPLAN International Workshop on Functional High-Performance Computing (FHPC 2017). ACM, New York, NY, USA. 12–23. isbn:978-1-4503-5181-2
    [34]
    Amir Shaikhha, Andrew W. Fitzgibbon, Dimitrios Vytiniotis, and Simon Peyton Jones. 2019. Efficient differentiable programming in a functional array-processing language. Proc. ACM Program. Lang., 3, ICFP (2019), 97:1–97:30. https://doi.org/10.1145/3341701
    [35]
    Amir Shaikhha, Mahdi Ghorbani, and Hesam Shahrokhi. 2022. Hinted Dictionaries: Efficient Functional Ordered Sets and Maps (Extended Abstract). In 36th European Conference on Object-Oriented Programming, ECOOP 2022, June 6-10, 2022, Berlin, Germany, Karim Ali and Jan Vitek (Eds.) (LIPIcs, Vol. 222). Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 33:1–33:3. https://doi.org/10.4230/LIPIcs.ECOOP.2022.33
    [36]
    Amir Shaikhha, Mathieu Huot, Jaclyn Smith, and Dan Olteanu. 2022. Functional collection programming with semi-ring dictionaries. PACMPL, 6, OOPSLA1 (2022), 1–33.
    [37]
    Amir Shaikhha, Yannis Klonatos, Lionel Parreaux, Lewis Brown, Mohammad Dashti, and Christoph Koch. 2016. How to Architect a Query Compiler. In Proceedings of the 2016 International Conference on Management of Data (SIGMOD’16). ACM, New York, NY, USA. 1907–1922. isbn:978-1-4503-3531-7
    [38]
    Nicolas Stucki, Jonathan Immanuel Brachthäuser, and Martin Odersky. 2021. Multi-stage programming with generative and analytical macros. In Proceedings of the 20th ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences. 110–122.
    [39]
    Josef Svenningsson. 2002. Shortcut Fusion for Accumulating Parameters & Zip-like Functions. In Proceedings of the Seventh ACM SIGPLAN International Conference on Functional Programming (ICFP ’02). ACM, 124–132. isbn:1-58113-487-8
    [40]
    Bo Joel Svensson and Josef Svenningsson. 2014. Defunctionalizing Push Arrays. In Proceedings of the 3rd ACM SIGPLAN Workshop on Functional High-performance Computing (FHPC ’14). ACM, NY, USA. 43–52. isbn:978-1-4503-3040-4
    [41]
    Akihiko Takano and Erik Meijer. 1995. Shortcut Deforestation in Calculational Form. In Proceedings of the Seventh International Conference on Functional Programming Languages and Computer Architecture (FPCA ’95). Association for Computing Machinery, New York, NY, USA. 306–313.
    [42]
    Phil Trinder. 1992. Comprehensions, a Query Notation for DBPLs. In Proc. of the 3rd DBPL workshop (DBPL3). Morgan Kaufmann Publishers Inc., San Francisco, CA, USA. 55–68. isbn:1-55860-242-9
    [43]
    Philip Wadler. 1988. Deforestation: Transforming programs to eliminate trees. In ESOP’88. 344–358.
    [44]
    Philip Wadler. 1990. Comprehending Monads. In Proceedings of the 1990 ACM Conference on LISP and Functional Programming (LFP ’90). ACM, New York, NY, USA. 61–78. isbn:0-89791-368-X
    [45]
    Fei Wang, Daniel Zheng, James Decker, Xilun Wu, Grégory M. Essertel, and Tiark Rompf. 2019. Demystifying Differentiable Programming: Shift/Reset the Penultimate Backpropagator. Proc. ACM Program. Lang., 3, ICFP (2019), Article 96, July, 31 pages.
    [46]
    Limsoon Wong. 2000. Kleisli, a functional query system. Journal of Functional Programming, 10, 1 (2000), 19–56.
    [47]
    Matei Zaharia, Mosharaf Chowdhury, Tathagata Das, Ankur Dave, Justin Ma, Murphy McCauley, Michael J. Franklin, Scott Shenker, and Ion Stoica. 2012. Resilient Distributed Datasets: A Fault-tolerant Abstraction for In-memory Cluster Computing. NSDI’12. USENIX Association, 1 pages.

    Cited By

    View all
    • (2024)A Tensor Algebra Compiler for Sparse Differentiation2024 IEEE/ACM International Symposium on Code Generation and Optimization (CGO)10.1109/CGO57630.2024.10444787(1-12)Online publication date: 2-Mar-2024
    • (2023)Fine-Tuning Data Structures for Query ProcessingProceedings of the 21st ACM/IEEE International Symposium on Code Generation and Optimization10.1145/3579990.3580016(149-161)Online publication date: 17-Feb-2023

    Recommendations

    Comments

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    GPCE 2022: Proceedings of the 21st ACM SIGPLAN International Conference on Generative Programming: Concepts and Experiences
    November 2022
    186 pages
    ISBN:9781450399203
    DOI:10.1145/3564719
    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 the author(s) 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].

    Sponsors

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 01 December 2022

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Collection Programming
    2. Deep Fusion
    3. Destination-Passing Style
    4. In-Place Update
    5. Loop Fusion
    6. Monoid

    Qualifiers

    • Research-article

    Conference

    GPCE '22
    Sponsor:

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)44
    • Downloads (Last 6 weeks)5

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)A Tensor Algebra Compiler for Sparse Differentiation2024 IEEE/ACM International Symposium on Code Generation and Optimization (CGO)10.1109/CGO57630.2024.10444787(1-12)Online publication date: 2-Mar-2024
    • (2023)Fine-Tuning Data Structures for Query ProcessingProceedings of the 21st ACM/IEEE International Symposium on Code Generation and Optimization10.1145/3579990.3580016(149-161)Online publication date: 17-Feb-2023

    View Options

    Get Access

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media