Nothing Special   »   [go: up one dir, main page]

skip to main content
article

Functional array fusion

Published: 01 October 2001 Publication History

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.

References

[1]
W. Abu-Sufah. Improving the Performance of Virtual Memory Computers. PhD thesis, Dept. of Computer Science, University of Illinois, 1979.]]
[2]
S. Anderson and P. Hudak. Compilation of Haskell array comprehensions for scientific computing. In Proceedings of the ACM SIGPLAN'OO Conference on Programming Language Design and Implementation, pages 137-149, 1990.]]
[3]
J. Barnes and P. Hut. A hierarchical O(n log n) force calculation algorithm. Nature, 324, December 1986.]]
[4]
G. Blelloch, H. Burch, K. Crary, R. Harper, G. Miller, and N. Walkington. Persistent triangulations. Journal of Functional Programming, 2001. http: //www. Cs. cmu.edu/rwh/papers/triangulations/jfp.ps. To appear.]]
[5]
G. E. Blelloch. Prefix sums and their applications. Technical Report CMU-CS-90-190, School of Computer Science, Carnegie Mellon University, Nov. 1990.]]
[6]
G. E. Blelloch. Programming parallel algorithms. Communications of the ACM, 39(3):8597, 1996.]]
[7]
G. E. Blelloch, M. A. Heroux, and M. Zagha. Segmented operations for sparse matrix computation on vector multiprocessors. Technical Report CMU-CS-93-173, School of Computer Science, Carnegie Mellon University, Aug. 1993.]]
[8]
G. E. Blelloch and G. W. Sabot. Compiling collection-oriented languages onto massively parallel computers. Journal of Parallel and Distributed Computing, 8:119-134, 1990.]]
[9]
D. Cann. Retire fortran? A debate rekindled. Communications of the ACM, 35(8):81, Aug. 1992.]]
[10]
M. M. T. Chakravarty and G. Keller. How portable is nested data parallelism? In Proc. of 6th Annual Australasian Conf. on Parallel And Real-Time Systems, pages 284-299. Springer-Verlag, 1999.]]
[11]
M. M. T. Chakravarty and G. Keller. More types for nested data parallel programming. In P. Wadler, editor, Proceedings of the Fifth ACM SIGPLAN International Conference on Functional Programming (ICFP'OO), pages 94-105. ACM Press, 2000.]]
[12]
T. Chuang. A functional perspective of array primitives. In 2nd Fuji Int. Workshop on Functional and Logic Programming, pages 71-90, 1996.]]
[13]
I. S. Duff, A. M. Erisman, and J. K. Reid. Direct Methods for Sparse Matrices. Oxford Science Publications, 1986.]]
[14]
N. Ellmenreich, C. Lengauer, and M. Griebl. Application of the polytope model to functional programs. In 3. Ferrante, editor, Proc. 12th Int. Workshop on Languages and Compilers for Parallel Computing Coniputer Science and Engineering Department, TJC San Diego, 1999.]]
[15]
A. J. Gill, J. Launchbury, and S. L. Peyton Jones, A short cut to deforestation. In Arvind, editor. Functional Programming and Computer Architecture. pages 223-232. ACM, 1993.]]
[16]
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.]]
[17]
R. Harper and G. Morrisett. Compiling polymorphism using intensional type analysis. In Proceedings of the 22nd Annual Symposium on Principles of Programming Languages, pages 130-141. ACM Press, 1995.]]
[18]
C. B. Jay. Partial evaluation of shaped programs: experience with FISh. In 0. Danvey, editor, ACM SIGPLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation (PEPM '99). 1999.]]
[19]
G. Keller and M. M. T. Chakravarty. Flattening trees. In D. Pritchard and J. Reeve, editors, Euro-Par'98. Parallel Processing, number 1470 in Lecture Notes in Computer Science, pages 709-719, Berlin, 1998. Springer-Verlag.]]
[20]
G. Keller and M. M. T. Chakravarty. On the distributed implementation of aggregate data structures by program transformation. In J. Rolim et al., editors, Parallel and Distributed Processing, Fourth International Workshop on High-Level Parallel Programming Models and Supportive Environments (HIPS'gY), number 1586 in Lecture Notes in Computer Science, pages 108-122, Berlin, Germany, 1999. Springer-Verlag.]]
[21]
K. Kennedy and K. S. McKinley. Maximizing loop parallelism and improving data locality via loop fusion and distribution. In 1993 Workshop on Languages and Compilers for Parallel Computing, number 768, pages 301-320. Springer Verlag, 1993.]]
[22]
N. Manjikian. Combining loop fusion with prefetching on shared-memory multiprocessors. In Proceedings of the 1997 International Conference on Parallel Processing (ICPP '97). IEEE Computer Society Press, 1997.]]
[23]
M. E. O'Neill and F. W. Burton. A new method for functional arrays. Journal of Functional Programming, 7(5):487-513, 1997.]]
[24]
Y. Onoue, Z. Hu, H. Iwasaki, and M. Takeichi. The calculational fusion system HYLO. In IFIP TC 2 Working Conference on Algorithmic Languages and Calculi, pages 76-106. Chapman & Hall, 1997.]]
[25]
S. Peyton Jones, T. Hoare, and A. Tolmach. Playing by the rules: rewriting as a practical optimisation technique. 2001. Microsoft Research Cambridge. http://research.microsoft.com/Users/simonpj/ papers/rules Ps. gZ.]]
[26]
S. Peyton Jones and J. Launchbury. State in Haskell. Lisp and Symbolic Computation, 8(4):293-341, 1995.]]
[27]
S. Peyton Jones and S. Marlow. Secrets of the Glasgow Haskell Compiler mImer. In International Workshop on Implementation of Declarative Languages, 1999. http://research.microsoft.com/ Users/simonpj/papers/inline.ps.gz.]]
[28]
S. L. Peyton Jones. Compiling Haskell by program transformation: a report from the trenches. In H. R. Nielson, editor, Proceedings of the European Symposium on Programming, volume 1058 of Lecture Notes in Computer Science, pages 18-44, Berlin, 1996. Springer-Verlag.]]
[29]
S. L. Peyton Jones and J. Launchbury. Unboxed values as first class citizens in a non-strict functional language. In 3. Hughes, editor, Proceedings of the International Conference on Functional Programming and Computer Architecture, 1991.]]
[30]
S. L. Peyton Jones, W. Partain, and A. Santos. Let-floating: Moving bindings to give faster programs. In Proceedings of the International Conference on Functional Programming, 1996.]]
[31]
G. Roth and K. Kennedy. Loop fusion in High Performance Fortran. In Conference Proceedings of the 1998 International Conference on Supercomputing, pages 125-132. ACM Press, 1998.]]
[32]
S.-B. Scholz. On defining application-specific high-level array operations by means of shape-invariant programming facilities. In Proceedings of APL '98, pages 40-45. ACM Press, 1998.]]
[33]
P. Serrarens. Implementing the conjugate gradient algorithm in a functional language. In W. Kluge, editor, Proceedings of Implementation of Functional Languages, 8th International Workshop, IFL '96, Selected Papers, number 1268 in LNCS, pages 125-140, 1997.]]
[34]
A. Takano and E. Meijer. Shortcut deforestation in calculational form. In Conf. Record 7th ACM SIGPLAN/SICARCH Intl. Conf. on Functional Programming Languages and Computer Architecture, pages 306-316. ACM Press, New York, 1995.]]
[35]
The GHC Team. Glasgow Haskell Compiler. http: //haskell. org/ghc/, 2001.]]
[36]
The GHC Team. Haskell Libraries: Language support. http ://haskell.Cs.yale . edu/ghc/docs/latest/ set/soc-lang.html, 2001.]]
[37]
P. Wadler. Deforestation: Transforming programs to eliminate trees. Theoretical Computer Science, 73:231-248, 1990.]]
[38]
S. Weirich. Type-safe cast: Functional pearl. In Proceedings of the Fifth ACM SICPLAN International Conference on Functional Programming (ICPP '00). ACM Press, 2000.]]
[39]
M. Wolf and M. Lam. An algorithmic approach to compound loop transformations. In T. C. A. Nicolau, D. Celernter and D. Padua, editors, Advances in Languages and Compilers for Parallel Computing, pages 243-259. The MIT Press, 1991.]]

Cited By

View all

Recommendations

Comments

Please enable JavaScript to view thecomments powered by Disqus.

Information & Contributors

Information

Published In

cover image ACM SIGPLAN Notices
ACM SIGPLAN Notices  Volume 36, Issue 10
October 2001
276 pages
ISSN:0362-1340
EISSN:1558-1160
DOI:10.1145/507669
Issue’s Table of Contents
  • cover image ACM Conferences
    ICFP '01: Proceedings of the sixth ACM SIGPLAN international conference on Functional programming
    October 2001
    277 pages
    ISBN:1581134150
    DOI:10.1145/507635
Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 01 October 2001
Published in SIGPLAN Volume 36, Issue 10

Check for updates

Qualifiers

  • Article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)0
  • Downloads (Last 6 weeks)0
Reflects downloads up to 13 Nov 2024

Other Metrics

Citations

Cited By

View all
  • (2018)Towards scalable pattern‐based optimization for dense linear algebraConcurrency and Computation: Practice and Experience10.1002/cpe.469630:22Online publication date: 6-Sep-2018
  • (2014)TrioletACM SIGPLAN Notices10.1145/2692916.255526849:8(247-258)Online publication date: 6-Feb-2014
  • (2014)TrioletACM SIGPLAN Notices10.1145/2692916.255526849:8(247-258)Online publication date: 6-Feb-2014
  • (2014)TrioletProceedings of the 19th ACM SIGPLAN symposium on Principles and practice of parallel programming10.1145/2555243.2555268(247-258)Online publication date: 6-Feb-2014
  • (2013)Data flow fusion with series expressions in HaskellACM SIGPLAN Notices10.1145/2578854.250378248:12(93-104)Online publication date: 23-Sep-2013
  • (2013)Data flow fusion with series expressions in HaskellProceedings of the 2013 ACM SIGPLAN symposium on Haskell10.1145/2503778.2503782(93-104)Online publication date: 23-Sep-2013
  • (2012)Vectorisation avoidanceACM SIGPLAN Notices10.1145/2430532.236451247:12(37-48)Online publication date: 13-Sep-2012
  • (2012)Vectorisation avoidanceProceedings of the 2012 Haskell Symposium10.1145/2364506.2364512(37-48)Online publication date: 13-Sep-2012
  • (2009)Recycle Your Arrays!Proceedings of the 11th International Symposium on Practical Aspects of Declarative Languages10.1007/978-3-540-92995-6_15(209-223)Online publication date: 10-Jan-2009
  • (2007)Data parallel HaskellProceedings of the 2007 workshop on Declarative aspects of multicore programming10.1145/1248648.1248652(10-18)Online publication date: 16-Jan-2007
  • Show More Cited By

View Options

Get Access

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Media

Figures

Other

Tables

Share

Share

Share this Publication link

Share on social media