Skip to main content

Recycle Your Arrays!

  • Conference paper

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 5418))

Abstract

Purely functional arrays are notoriously difficult to implement and use efficiently due to the absence of destructive updates and the resultant frequent copying. Deforestation frameworks such as stream fusion achieve signficant improvements here but fail for a number of important operations which can nevertheless benefit from elimination of temporaries. To mitigate this problem, we extend stream fusion with support for in-place execution of array operations. This optimisation, which we call recycling, is easy to implement and can significantly reduce array allocation and copying in purely functional array algorithms.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. Wadler, P.: Deforestation: transforming programs to eliminate trees. Theoretical Computer Science (Special issue of selected papers from 2nd European Symposium on Programming) 73(2), 231–248 (1990)

    MathSciNet  MATH  Google Scholar 

  2. Gill, A., Launchbury, J., Peyton Jones, S.: A short cut to deforestation. In: Conference on Functional Programming Languages and Computer Architecture, pp. 223–232 (1993)

    Google Scholar 

  3. Johann, P.: Short cut fusion: Proved and improved. In: Taha, W. (ed.) SAIG 2001. LNCS, vol. 2196, pp. 47–71. Springer, Heidelberg (2001)

    Chapter  Google Scholar 

  4. Svenningsson, J.: Shortcut fusion for accumulating parameters & zip-like functions. In: Proceedings of the 7th ACM SIGPLAN International Conference on Functional programming, pp. 124–132. ACM Press, New York (2002)

    Google Scholar 

  5. Chakravarty, M.M.T., Keller, G.: Functional array fusion. In: Leroy, X. (ed.) Proceedings of the Sixth ACM SIGPLAN International Conference on Functional Programming, pp. 205–216. ACM Press, New York (2001)

    Chapter  Google Scholar 

  6. Chakravarty, M.M.T., Leshchinskiy, R., Peyton Jones, S., Keller, G., Marlow, S.: Data Parallel Haskell: a status report. In: DAMP 2007: Proceedings of the 2007 workshop on Declarative aspects of multicore programming, pp. 10–18. ACM, New York (2007)

    Google Scholar 

  7. Coutts, D., Leshchinskiy, R., Stewart, D.: Stream fusion: from lists to streams to nothing at all. In: Proceedings of the 2007 ACM SIGPLAN International Conference on Functional programming, pp. 315–326. ACM Press, New York (2007)

    Chapter  Google Scholar 

  8. Coutts, D., Stewart, D., Leshchinskiy, R.: Rewriting Haskell strings. In: Hanus, M. (ed.) PADL 2007. LNCS, vol. 4354, pp. 50–64. Springer, Heidelberg (2006)

    Chapter  Google Scholar 

  9. Bloss, A.: Update analysis and the efficient implementation of functional aggregates. In: Proceedings of the 4th international conference on Functional programming languages and computer architecture, pp. 26–38. ACM, New York (1989)

    Google Scholar 

  10. Odersky, M.: How to make destructive updates less destructive. In: Proc. 18th ACM Symp. on Principles of Programming Languages, pp. 25–36. ACM Press, New York (1991)

    Google Scholar 

  11. Sastry, A.V.S., Clinger, W., Ariola, Z.: Order-of-evaluation analysis for destructive updates in strict functional languages with flat aggregates. In: Conference on Functional Programming Languages and Computer Architecture, pp. 266–275. ACM Press, New York (1993)

    Chapter  Google Scholar 

  12. Wadler, P.: Linear types can change the world. In: Programming Concepts and Methods, North, 347–359 (1990)

    Google Scholar 

  13. Launchbury, J., Peyton Jones, S.L.: Lazy functional state threads. In: SIGPLAN Conference on Programming Language Design and Implementation, pp. 24–35 (1994)

    Google Scholar 

  14. Peyton Jones, S.: Call-pattern specialisation for Haskell programs. In: Proceedings of the 2007 ACM SIGPLAN International Conference on Functional programming, pp. 327–337. ACM, New York (2007)

    Chapter  Google Scholar 

  15. Peyton Jones, S., Santos, A.L.M.: A transformation-based optimiser for Haskell. Sci. Comput. Program. 32(1-3), 3–47 (1998)

    Article  MATH  Google Scholar 

  16. Peyton Jones, S., Tolmach, A., Hoare, T.: Playing by the rules: rewriting as a practical optimisation technique in GHC. In: Hinze, R. (ed.) 2001 Haskell Workshop. ACM, New York (2001)

    Google Scholar 

  17. Leiserson, C.E., Maggs, B.M.: Communication-efficient parallel algorithms for distributed random-access machines. Algorithmica 3, 53–77 (1988)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2008 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Leshchinskiy, R. (2008). Recycle Your Arrays! . In: Gill, A., Swift, T. (eds) Practical Aspects of Declarative Languages. PADL 2009. Lecture Notes in Computer Science, vol 5418. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-540-92995-6_15

Download citation

  • DOI: https://doi.org/10.1007/978-3-540-92995-6_15

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-540-92994-9

  • Online ISBN: 978-3-540-92995-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics