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.
Supplemental Material
- }}The Boost Multidimensional Array Library, April 20URL http://www.boost.org/doc/libs/1_42_0/libs/multi_array/doc/user.html.Google Scholar
- }}C. Burke. J and APL. Iverson Software Inc., 1996.Google Scholar
- }}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 Scholar
Digital Library
- }}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 Scholar
Digital Library
- }}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 Scholar
Digital Library
- }}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 Scholar
Digital Library
- }}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 Scholar
Digital Library
- }}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 Scholar
Cross Ref
- }}A. Gilat. MATLAB: An Introduction with Applications 2nd Edition. John Wiley & Sons, 2004. ISBN 978-0-471-69420-5.Google Scholar
- }}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 Scholar
Digital Library
- }}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 Scholar
Digital Library
- }}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 Scholar
- }}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 Scholar
- }}J. Mathews and K. Fink. Numerical Methods using MATLAB, 3rd edition. Prentice Hall, 1999. Google Scholar
Digital Library
- }}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 Scholar
Digital Library
- }}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 Scholar
- }}F. A. Rabhi and S. Gorlatch, editors. Patterns and Skeletons for Parallel and Distributed Computing. Springer-Verlag, 2003. Google Scholar
Digital Library
- }}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 Scholar
Digital Library
- }}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 Scholar
Digital Library
- }}W. Swierstra and T. Altenkirch. Dependent types for distributed arrays. In Trends in Functional Programming, volume 9, 2008.Google Scholar
- }}The International Standards Organisation. Programming Language APL. ISO standard 8485, 1989.Google Scholar
- }}The OpenMP Architecture Review Board. OpenMP Application Program Interface, 2008. URL http://www.openmp.org/specs.Google Scholar
- }}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 Scholar
Digital Library
- }}H. Xi. Dependent ML: an approach to practical programming with dependent types. Journal of Functional Programming, 17(2):215--286, 2007. Google Scholar
Digital Library
Index Terms
Regular, shape-polymorphic, parallel arrays in Haskell
Recommendations
Accelerating Haskell array codes with multicore GPUs
DAMP '11: Proceedings of the sixth workshop on Declarative aspects of multicore programmingCurrent GPUs are massively parallel multicore processors optimised for workloads with a large degree of SIMD parallelism. Good performance requires highly idiomatic programs, whose development is work intensive and requires expert knowledge.
To raise ...
Regular, shape-polymorphic, parallel arrays in Haskell
ICFP '10: Proceedings of the 15th ACM SIGPLAN international conference on Functional programmingWe 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 ...
Efficient parallel stencil convolution in Haskell
Haskell '11: Proceedings of the 4th ACM symposium on HaskellStencil convolution is a fundamental building block of many scientific and image processing algorithms. We present a declarative approach to writing such convolutions in Haskell that is both efficient at runtime and implicitly parallel. To achieve this ...









Comments