Regular, shape-polymorphic, parallel arrays in Haskell

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.

[1]  G. Keller,et al.  GPU Kernels as Data-Parallel Array Computations in Haskell , 2009 .

[2]  Simon L. Peyton Jones,et al.  Associated type synonyms , 2005, ICFP '05.

[3]  Manuel M. T. Chakravarty,et al.  Low Level Virtual Machine for Glasgow Haskell Compiler , 2009 .

[4]  Simon L. Peyton Jones,et al.  Associated types with class , 2005, POPL '05.

[5]  George Lindfield,et al.  Numerical Methods Using MATLAB , 1998 .

[6]  John H. Mathews,et al.  Using MATLAB as a programming language for numerical analysis , 1994 .

[7]  John H. G. van Groningen The Implementation and Efficiency of Arrays in Clean 1.1 , 1996, Implementation of Functional Languages.

[8]  D. Walker,et al.  Patterns and Skeletons for Parallel and Distributed Computing , 2022 .

[9]  Steven G. Johnson,et al.  The Design and Implementation of FFTW3 , 2005, Proceedings of the IEEE.

[10]  Simon L. Peyton Jones,et al.  Lazy functional state threads , 1994, PLDI '94.

[11]  Todd L. Veldhuizen,et al.  Arrays in Blitz++ , 1998, ISCOPE.

[12]  Simon L. Peyton Jones,et al.  Harnessing the Multicores: Nested Data Parallelism in Haskell , 2008, FSTTCS.

[13]  Simon L. Peyton Jones Call-pattern specialisation for Haskell programs , 2007, ICFP '07.

[14]  Vikram S. Adve,et al.  LLVM: a compilation framework for lifelong program analysis & transformation , 2004, International Symposium on Code Generation and Optimization, 2004. CGO 2004..

[15]  Roman Leshchinskiy,et al.  Stream fusion: from lists to streams to nothing at all , 2007, ICFP '07.

[16]  Simon L. Peyton Jones,et al.  Data parallel Haskell: a status report , 2007, DAMP '07.

[17]  Jack Dongarra,et al.  Special Issue on Program Generation, Optimization, and Platform Adaptation , 2005, Proc. IEEE.

[18]  Simon L. Peyton Jones,et al.  Type checking with open type functions , 2008, ICFP.

[19]  Thorsten Altenkirch,et al.  Dependent Types for Distributed Arrays , 2008, Trends in Functional Programming.

[20]  Sven-Bodo Scholz,et al.  Single Assignment C: efficient support for high-level array operations in a functional setting , 2003, Journal of Functional Programming.

[21]  Hongwei Xi,et al.  Dependent ML An approach to practical programming with dependent types , 2007, Journal of Functional Programming.

[22]  X. Leroy The Objective Caml system release 3.09 Documentation and user''s manual , 2005 .

[23]  Roman Leshchinskiy,et al.  Rewriting Haskell Strings , 2007, PADL.