skip to main content
research-article

Regular, shape-polymorphic, parallel arrays in Haskell

Published:27 September 2010Publication History
Skip Abstract Section

Abstract

We present a novel approach to regular, multi-dimensional arrays in Haskell. The main highlights of our approach are that it (1) is purely functional, (2) supports reuse through shape polymorphism, (3) avoids unnecessary intermediate structures rather than relying on subsequent loop fusion, and (4) supports transparent parallelisation.

We show how to embed two forms of shape polymorphism into Haskell's type system using type classes and type families. In particular, we discuss the generalisation of regular array transformations to arrays of higher rank, and introduce a type-safe specification of array slices.

We discuss the runtime performance of our approach for three standard array algorithms. We achieve absolute performance comparable to handwritten C code. At the same time, our implementation scales well up to 8 processor cores.

Skip Supplemental Material Section

Supplemental Material

icfp-weds-1055-lippmeier.mov

References

  1. }}The Boost Multidimensional Array Library, April 20URL http://www.boost.org/doc/libs/1_42_0/libs/multi_array/doc/user.html.Google ScholarGoogle Scholar
  2. }}C. Burke. J and APL. Iverson Software Inc., 1996.Google ScholarGoogle Scholar
  3. }}M. M. T.Chakravarty, G. Keller,and S. Peyton Jones. Associated type synonyms. In ICFP '05: Proceedings of the Tenth ACM SIGPLAN International Conference on Functional Programming, pages 241--253, New York, NY, USA, 2005. ACM Press. ISBN 1-59593-064-7. doi: http://doi.acm.org/10.1145/1086365.1086397. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. }}M. M. T. Chakravarty, G. Keller, S. Peyton Jones, and S. Marlow. Associated types with class. In POPL '05: Proceedings of the 32nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pages 1--13. ACM Press, 2005. ISBN 1-58113-830-X. doi: http://doi.acm.org/10.1145/1040305.1040306. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. }}M. M. T. Chakravarty, R. Leshchinskiy, S. Peyton Jones, G. Keller, and S. Marlow. Data Parallel Haskell: a status report. In DAMP 2007: Workshop on Declarative Aspects of Multicore Programming. ACM Press, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. }}D. Coutts, R. Leshchinskiy, and D. Stewart. Stream fusion: From lists to streams to nothing at all. In Proceedings of the ACM SIGPLAN International Conference on Functional Programming (ICFP 2007). ACM Press, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. }}D. Coutts, D. Stewart, and R. Leshchinskiy. Rewriting Haskell strings. In Practical Aspects of Declarative Languages 8th International Symposium, PADL 2007, pages 50--64. Springer-Verlag, Jan. 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. }}M. Frigo and S. G. Johnson. The design and implementation of FFTW3. Proceedings of the IEEE, 93(2):216--231, 2005. Special issue on Program Generation, Optimization, and Platform Adaptation.Google ScholarGoogle ScholarCross RefCross Ref
  9. }}A. Gilat. MATLAB: An Introduction with Applications 2nd Edition. John Wiley & Sons, 2004. ISBN 978-0-471-69420-5.Google ScholarGoogle Scholar
  10. }}J. H. v.Groningen. The implementation and efficiency of arrays in Clean 1.1. In W. Kluge, editor, Proceedings of Implementation of Functional Languages, 8th International Workshop, IFL '96, Selected Papers, number 1268 in LNCS, pages 105--124. Springer-Verlag, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. }}J. Launchbury and S. Peyton Jones. Lazy functional state threads. In Proceedings of Programming Language Design and Implementation (PLDI 1994), pages 24--35, New York, NY, USA, 1994. ACM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. }}S. Lee, M. M. T. Chakravarty, V. Grover, and G. Keller. GPU kernels as data-parallel array computations in haskell. In EPAHM 2009: Workshop on Exploiting Parallelism using GPUs and other Hardware-Assisted Methods, 2009.Google ScholarGoogle Scholar
  13. }}X. Leroy, D. Doligez, J. Garrigue, D. Rémy, and J. Vouillon. The Objective Caml system, release 3.11, documentation and user's manual. Technical report, INRIA, 2008.Google ScholarGoogle Scholar
  14. }}J. Mathews and K. Fink. Numerical Methods using MATLAB, 3rd edition. Prentice Hall, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. }}S. Peyton Jones. Call-pattern specialisation for Haskell programs. In Proceedings of the International Conference on Functional Programming (ICFP 2007), pages 327--337, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  16. }}S. Peyton Jones, R. Leshchinskiy, G. Keller, and M. M. T. Chakravarty. Harnessing the multicores: Nested data parallelism in Haskell. In R. Hariharan, M. Mukund, and V. Vinay, editors, IARCS Annual Conference on Foundations of Software Technology and Theoretical Computer Science (FSTTCS 2008), Dagstuhl, Germany, 2008. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, Germany. URL http://drops.dagstuhl.de/opus/volltexte/2008/1769.Google ScholarGoogle Scholar
  17. }}F. A. Rabhi and S. Gorlatch, editors. Patterns and Skeletons for Parallel and Distributed Computing. Springer-Verlag, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. }}S.-B. Scholz. Single assignment C - efficient support for high-level array operations in a functional setting. Journal of Functional Programming, 13(6):1005--1059, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. }}T. Schrijvers, S. Peyton-Jones, M. M. T. Chakravarty, and M. Sulzmann. Type checking with open type functions. In Proceedings of ICFP 2008 : The 13th ACM SIGPLAN International Conference on Functional Programming, pages 51--62. ACM Press, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. }}W. Swierstra and T. Altenkirch. Dependent types for distributed arrays. In Trends in Functional Programming, volume 9, 2008.Google ScholarGoogle Scholar
  21. }}The International Standards Organisation. Programming Language APL. ISO standard 8485, 1989.Google ScholarGoogle Scholar
  22. }}The OpenMP Architecture Review Board. OpenMP Application Program Interface, 2008. URL http://www.openmp.org/specs.Google ScholarGoogle Scholar
  23. }}T. L. Veldhuizen. Arrays in Blitz++. In Proceedings of the 2nd International Scientific Computing in Object Oriented Parallel Environments (ISCOPE'98). Springer-Verlag, 1998. ISBN 978-3-540-65387-5. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. }}H. Xi. Dependent ML: an approach to practical programming with dependent types. Journal of Functional Programming, 17(2):215--286, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Regular, shape-polymorphic, parallel arrays in Haskell

          Recommendations

          Reviews

          Rafael Corchuelo

          Algorithms that work on arrays are very common in science and engineering, and range from finding connected components in a graph to complex atmospheric simulations. Supporters of purely functional languages claim that these algorithms are often easier to understand and more conceptually elegant than their imperative counterparts. Detractors, however, tend to claim that the functional versions are often too inefficient for practical purposes. Keller et al. report on a technique, and an accompanying library, that supports multidimensional functional arrays and parallel optimization, and also provides a high degree of reuse by supporting shape parallelism and polymorphism. Their technique seems very efficient in practice since it can perform similarly to native C code in some cases. Following the introductory section 1, the paper is organized into two logical parts. First, sections 2 and 3 present the authors' approach to representing arrays and implementing array algorithms. Then, the remaining sections (4 to 9) discuss their proposal to support constrained shape polymorphism, their functional application programming interface (API), parallel optimization, and an empirical evaluation using three well-known benchmarks. The paper is well written. The authors clearly address what the problem is, why it is actually a problem, what their solution is, and why it advances the state of the art. I definitely recommend it to researchers who are interested in parallel array algorithms. Online Computing Reviews Service

          Access critical reviews of Computing literature here

          Become a reviewer for Computing Reviews.

          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 45, Issue 9
            ICFP '10
            September 2010
            382 pages
            ISSN:0362-1340
            EISSN:1558-1160
            DOI:10.1145/1932681
            Issue’s Table of Contents
            • cover image ACM Conferences
              ICFP '10: Proceedings of the 15th ACM SIGPLAN international conference on Functional programming
              September 2010
              398 pages
              ISBN:9781605587943
              DOI:10.1145/1863543

            Copyright © 2010 ACM

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 27 September 2010

            Check for updates

            Qualifiers

            • research-article

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader

          ePub

          View this article in ePub.

          View ePub
          About Cookies On This Site

          We use cookies to ensure that we give you the best experience on our website.

          Learn more

          Got it!