An Approach to Fast Arrays in Haskell

  • Manuel M. T. Chakravarty
  • Gabriele Keller
Part of the Lecture Notes in Computer Science book series (LNCS, volume 2638)

Abstract

Many array-centric algorithms from computational science and engineering, especially those based on dynamic and irregular data structures, can be coded rather elegantly in a purely functional style. The challenge, when compared to imperative array languages, is performance.

These lecture notes discuss the shortcomings of Haskell’s standard arrays in this context and present an alternative approach that decouples array from list processing and is based on program transformation and generic programming. In particular, we will present (1) an array library that uses type analysis to achieve unboxing and flattening of data structures as well as (2) equational array fusion based on array combinators and compiler-driven rewrite rules. We will make use of a range of advanced language extensions to Haskell, such as multi-parameter type classes, functional dependencies, rewrite rules, unboxed values, and locally state-based computations.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. [BS90]
    Blelloch, G.E., Sabot, G.W.: Compiling collection-oriented languages onto massively parallel computers. Journal of Parallel and Distributed Computing 8, 119–134 (1990)CrossRefGoogle Scholar
  2. [CH02]
    Cheney, J., Hinze, R.: Poor man’s dynamics and generics. In: Chakravarty, M.M.T. (ed.) Proceedings of the ACM SIGPLAN 2002 Haskell Workshop, pp. 90–104. ACM Press, New York (2002)CrossRefGoogle Scholar
  3. [CK00]
    Chakravarty, M.M.T., Keller, G.: More types for nested data parallel programming. In: Wadler, P. (ed.) Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming (ICFP 2000), pp. 94–105. ACM Press, New York (2000)CrossRefGoogle Scholar
  4. [CK01]
    Chakravarty, M.M.T., Keller, G.: Functional array fusion. In: Leroy, X. (ed.) Proceedings of the Sixth ACM SIGPLAN International Conference on Functional Programming (ICFP 2001), pp. 205–216. ACM Press, New York (2001)CrossRefGoogle Scholar
  5. [CL02]
    Clarke, D., Löh, A.: Generic haskell, specifically. In: Proceedings of the IFIP WG2.1 Working Conference on Generic Programming (2002)Google Scholar
  6. [CPS98]
    Chatterjee, S., Prins, J.F., Simons, M.: Expressing irregular computations in modern Fortran dialects. In: Fourth Workshop on Languages, Compilers, and Run-Time Systems for Scalable Computers. LNCS. Springer, Heidelberg (1998)Google Scholar
  7. [DER86]
    Duff, I.S., Erisman, A.M., Reid, J.K.: Direct Methods for Sparse Matrices. Oxford Science Publications (1986)Google Scholar
  8. [GLP93]
    Gill, A.J., Launchbury, J., Jones, S.L.P.: A short cut to deforestation. In: Arvind (ed.) Functional Programming and Computer Architecture, pp. 223–232. ACM, New York (1993)Google Scholar
  9. [HCL02]
    Haskell core libraries, base package (2002), http://haskell.org/ghc/docs/latest/html/base/index.html
  10. [Hin00]
    Hinze, R.: Generalizing generalized tries. Journal of Functional Programming 10(4), 327–351 (2000)MATHCrossRefMathSciNetGoogle Scholar
  11. [HJL02]
    Hinze, R., Jeuring, J., Löh, A.: Type-indexed datatypes. In: Proceedings of the 6th Mathematics of Program Construction Conference. Springer, Heidelberg (2002)Google Scholar
  12. [HM95]
    Harper, R., Morrisett, G.: Compiling polymorphism using intensional type analysis. In: 22nd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 130–141. ACM Press, New York (1995)CrossRefGoogle Scholar
  13. [HP01]
    Hinze, R., Jones, S.P.: Derivable type classes. In: Hutton, G. (ed.) Proceedings of the 2000 ACM SIGPLAN Haskell Workshop. Electronic Notes in Theoretical Computer Science, vol. 41.1. Elsevier Science, Amsterdam (2001)Google Scholar
  14. [Jon00]
    Jones, M.: Type classes with functional dependencies. In: Smolka, G. (ed.) ESOP 2000. LNCS, vol. 1782, p. 230. Springer, Heidelberg (2000)CrossRefGoogle Scholar
  15. [PHT01]
    Jones, S.P., Hoare, T., Tolmach, A.: Playing by the rules: rewriting as a practical optimisation technique. In: Proceedings of the ACM SIGPLAN 2001 Haskell Workshop (2001)Google Scholar
  16. [PL95]
    Jones, S.P., Launchbury, J.: State in Haskell. Lisp and Symbolic Computation 8(4), 293–341 (1995)CrossRefGoogle Scholar
  17. [PP93]
    Prins, J., Palmer, D.: Transforming high-level data-parallel programs into vector operations. In: Proceedings of the Fourth ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, San Diego, CA, May 19-22, pp. 119–128. ACM Press, New York (1993)CrossRefGoogle Scholar
  18. [TMC+96]
    Tarditi, D., Morrisett, G., Cheng, P., Stone, C., Harper, R., Lee, P.: TIL: A type-directed optimizing compiler for ML. In: SIGPLAN Conference on Programming Language Design and Implementation (1996)Google Scholar
  19. [Wad88]
    Wadler, P.: Deforestation. In: Ganzinger, H. (ed.) ESOP 1988. LNCS, vol. 300. Springer, Heidelberg (1988)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2003

Authors and Affiliations

  • Manuel M. T. Chakravarty
    • 1
  • Gabriele Keller
    • 1
  1. 1.School of Computer Science & EngineeringThe University of New South WalesSydneyAustralia

Personalised recommendations