Functional array fusion

  • Authors:
  • Manuel M. T. Chakravarty;Gabriele Keller

  • Affiliations:
  • Univ. of New South Wales, Sydney, Australia;Univ. of New South Wales, Sydney, Australia

  • Venue:
  • Proceedings of the sixth ACM SIGPLAN international conference on Functional programming
  • Year:
  • 2001

Quantified Score

Hi-index 0.00

Visualization

Abstract

This paper introduces a new approach to optimizing array algorithms in functional languages. We are specifically aiming at an efficient implementation of irregular array algorithms that are hard to implement in conventional array languages such as Fortran. We optimize the storage layout of arrays containing complex data structures and reduce the running time of functions operating on these arrays by means of equational program transformations. In particular, this paper discusses a novel form of combinator loop fusion, which by removing intermediate structures optimizes the use of the memory hierarchy. We identify a combinator named loop P that provides a general scheme for iterating over an array and that in conjunction with an array constructor replicate P is sufficient to express a wide range of array algorithms. On this basis, we define equational transformation rules that combine traversals of loop P and replicate P as well as sequences of applications of loop P into a single loop P traversal. Our approach naturally generalizes to a parallel implementation and includes facilities for optimizing load balancing and communication. A prototype implementation based on the rewrite rule pragma of the Glasgow Haskell Compiler is significantly faster than standard Haskell arrays and approaches the speed of hand coded C for simple examples.