Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
10.1145/3520306.3534502acmconferencesArticle/Chapter ViewAbstractPublication PagespldiConference Proceedingsconference-collections
research-article

From functional to imperative: combining destination-passing style and views

Published: 13 June 2022 Publication History
  • Get Citation Alerts
  • Abstract

    Programming in low-level imperative languages provides good performance but is error-prone. On the other hand, functional programs are usually free from low-level errors but performance suffers from costly programming abstractions. Compiling high-level functional programs into high-performance imperative still remains an open challenge.
    This paper presents an approach to compiling a high-level array-based functional IR (Intermediate Representation) into high-performance imperative code. It combines the existing work on DPS (Destination-Passing Style) with the Lift views system by extending the notion of view to destinations. Destination views can be seen as lazy operations that work in reverse; the lazy operations affect how data is being produced into memory, rather than how data is being consumed.
    This approach produces imperative code that existing techniques are unable to produce. The code produced outperforms the existing DPS approach on real-world workloads when targeting CPU code. The paper also demonstrates how destination views can be used to generate high-performance stencil code on GPUs (Graphics Processing Units), by encoding the 2.5D tiling optimization in a functional style.

    References

    [1]
    Johan Ankner and Josef David Svenningsson. 2013. An EDSL Approach to High Performance Haskell Programming. ACM SIGPLAN Notices, 48, 12 (2013), 1–12.
    [2]
    Robert Atkey, Michel Steuwer, Sam Lindley, and Christophe Dubach. 2017. Strategy Preserving Compilation for Parallel Functional Code. arXiv preprint arXiv:1710.08332.
    [3]
    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 Implementation and Application of Functional Languages, Jurriaan Hage and Marco T. Morazán (Eds.). 6647, Springer Berlin Heidelberg, Berlin, Heidelberg. 121–136. isbn:978-3-642-24275-5 978-3-642-24276-2
    [4]
    L. Cardelli, S. Martini, J.C. Mitchell, and A. Scedrov. 1994. An Extension of System f with Subtyping. Information and Computation, 109, 1 (1994), issn:0890-5401
    [5]
    Duncan Coutts, Roman Leshchinskiy, and Don Stewart. 2007. Stream Fusion: From Lists to Streams to Nothing at All. ACM SIGPLAN Notices, 42, 9 (2007), 315–326.
    [6]
    Duncan Coutts, Don Stewart, and Roman Leshchinskiy. 2007. Rewriting Haskell Strings. In International Symposium on Practical Aspects of Declarative Languages. 50–64.
    [7]
    Conal Elliott, Sigbjrn Finne, and Oege De Moor. 2003. Compiling Embedded Languages. Journal of Functional Programming, 13, 3 (2003), issn:09567968, 14697653
    [8]
    Cormac Flanagan, Amr Sabry, Bruce F Duba, and Matthias Felleisen. 1993. The Essence of Compiling with Continuations. In Proceedings of the ACM SIGPLAN 1993 Conference on Programming Language Design and Implementation. 237–247.
    [9]
    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 ’93. ACM Press, Copenhagen, Denmark. 223–232. isbn:978-0-89791-595-3
    [10]
    Clemens Grelck and Sven-Bodo Scholz. 2006. SAC— A Functional Array Language for Efficient Multi-threaded Execution. International Journal of Parallel Programming, 34, 4 (2006), Aug., 383–427. issn:0885-7458, 1573-7640
    [11]
    Bastian Hagedorn, Larisa Stoltzfus, Michel Steuwer, Sergei Gorlatch, and Christophe Dubach. 2018. High Performance Stencil Code Generation with Lift. In Proceedings of the 2018 International Symposium on Code Generation and Optimization. ACM, Vienna Austria. 100–112. isbn:978-1-4503-5617-6
    [12]
    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. 16.
    [13]
    Gabriele Keller, Manuel M T Chakravarty, Roman Leshchinskiy, Simon Peyton Jones, and Ben Lippmeier. 2010. Regular, Shape-Polymorphic, Parallel Arrays in Haskell. 12.
    [14]
    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. ACM, Paris France. 285–299. isbn:978-1-4503-4660-3
    [15]
    James R Larus. 1989. Restructuring Symbolic Programs for Concurrent Execution on Multiprocessors. CALIFORNIA UNIV BERKELEY DEPT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCES.
    [16]
    Geoffrey Mainland and Greg Morrisett. 2010. Nikola: Embedding Compiled GPU Functions in Haskell. 11.
    [17]
    Yasuhiko Minamide. 1998. A Functional Representation of Data Structures with a Hole. In Proceedings of the 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages. 75–84.
    [18]
    Anthony Nguyen, Nadathur Satish, Jatin Chhugani, Changkyu Kim, and Pradeep Dubey. 2010. 3.5-D Blocking Optimization for Stencil Computations on Modern CPUs and GPUs. In 2010 ACM/IEEE International Conference for High Performance Computing, Networking, Storage and Analysis. IEEE, New Orleans, LA, USA. 1–13. isbn:978-1-4244-7557-5
    [19]
    Flemming Nielson and Hanne Riis Nielson. 1999. Type and Effect Systems. In Correct System Design, Recent Insight and Advances, (to Hans Langmaack on the Occasion of His Retirement from His Professorship at the University of Kiel). Springer-Verlag, Berlin, Heidelberg. 114–136. isbn:978-3-540-66624-0
    [20]
    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 Press, Oxford, UK. 12–23. isbn:978-1-4503-5181-2
    [21]
    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. 12–23.
    [22]
    Michel Steuwer, Christian Fensch, Sam Lindley, and Christophe Dubach. 2015. Generating Performance Portable Code Using Rewrite Rules: From High-Level Functional Expressions to High-Performance OpenCL Code. In Proceedings of the 20th ACM SIGPLAN International Conference on Functional Programming. ACM, Vancouver BC Canada. isbn:978-1-4503-3669-7
    [23]
    Michel Steuwer, Toomas Remmelg, and Christophe Dubach. 2017. Lift: A Functional Data-Parallel IR for High-Performance GPU Code Generation. In 2017 IEEE/ACM International Symposium on Code Generation and Optimization (CGO). 74–85.
    [24]
    Larisa Stoltzfus, Bastian Hagedorn, Michel Steuwer, Sergei Gorlatch, and Christophe Dubach. 2019. Tiling Optimizations for Stencil Computations Using Rewrite Rules in L Ift. ACM Transactions on Architecture and Code Optimization, 16, 4 (2019), Dec., 1–25. issn:1544-3566, 1544-3973
    [25]
    Josef Svenningsson. 2002. Shortcut Fusion for Accumulating Parameters & Zip-like Functions. ACM SIGPLAN Notices, 37, 9 (2002), 124–132.
    [26]
    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 Press, Gothenburg, Sweden. 43–52. isbn:978-1-4503-3040-4
    [27]
    Joel Svensson, Mary Sheeran, and Koen Claessen. 2008. Obsidian: A Domain Specific Embedded Language for Parallel Programming of Graphics Processors. In Symposium on Implementation and Application of Functional Languages. 156–173.
    [28]
    Philip Wadler. 1988. Deforestation: Transforming Programs to Eliminate Trees. In European Symposium on Programming.
    [29]
    Guangwei Zhang and Yinliang Zhao. 2016. Modeling the Performance of 2.5D Blocking of 3D Stencil Code on GPUs.

    Cited By

    View all
    • (2024)A Verified Compiler for a Functional Tensor LanguageProceedings of the ACM on Programming Languages10.1145/36563908:PLDI(320-342)Online publication date: 20-Jun-2024
    • (2024)Latent Idiom Recognition for a Minimalist Functional Array Language Using Equality Saturation2024 IEEE/ACM International Symposium on Code Generation and Optimization (CGO)10.1109/CGO57630.2024.10444879(270-282)Online publication date: 2-Mar-2024

    Index Terms

    1. From functional to imperative: combining destination-passing style and views

      Recommendations

      Comments

      Information & Contributors

      Information

      Published In

      cover image ACM Conferences
      ARRAY 2022: Proceedings of the 8th ACM SIGPLAN International Workshop on Libraries, Languages and Compilers for Array Programming
      June 2022
      57 pages
      ISBN:9781450392693
      DOI:10.1145/3520306
      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: 13 June 2022

      Permissions

      Request permissions for this article.

      Check for updates

      Author Tags

      1. Compiler design
      2. Destination-passing style

      Qualifiers

      • Research-article

      Conference

      ARRAY '22
      Sponsor:

      Acceptance Rates

      Overall Acceptance Rate 17 of 25 submissions, 68%

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • Downloads (Last 12 months)25
      • Downloads (Last 6 weeks)3

      Other Metrics

      Citations

      Cited By

      View all
      • (2024)A Verified Compiler for a Functional Tensor LanguageProceedings of the ACM on Programming Languages10.1145/36563908:PLDI(320-342)Online publication date: 20-Jun-2024
      • (2024)Latent Idiom Recognition for a Minimalist Functional Array Language Using Equality Saturation2024 IEEE/ACM International Symposium on Code Generation and Optimization (CGO)10.1109/CGO57630.2024.10444879(270-282)Online publication date: 2-Mar-2024

      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