Abstract
This paper argues for a new methodology for writing high performance Haskell programs by using Embedded Domain Specific Languages.
We exemplify the methodology by describing a complete library, meta-repa, which is a reimplementation of parts of the repa library. The paper describes the implementation of meta-repa and contrasts it with the standard approach to writing high performance libraries. We conclude that even though the embedded language approach has an initial cost of defining the language and some syntactic overhead it gives a more tailored programming model, stronger performance guarantees, better control over optimizations, simpler implementation of fusion and inlining and allows for moving type level programming down to value level programming in some cases. We also provide benchmarks showing that meta-repa is as fast, or faster, than repa.
Furthermore, meta-repa also includes push arrays and we demonstrate their usefulness for writing certain high performance kernels such as FFT.
- E. Axelsson, K. Claessen, M. Sheeran, J. Svenningsson, D. Engdal, and A. Persson. The design and implementation of feldspar. In Implementation and Application of Functional Languages, pages 121--136. Springer, 2011. Google Scholar
Digital Library
- J. Bentley. Programming pearls: little languages. Commun. ACM, 29 (8): 711--721, Aug. 1986. ISSN 0001-0782. 10.1145/6424.315691. URL http://doi.acm.org/10.1145/6424.315691. Google Scholar
Digital Library
- P. Bjesse, K. Claessen, M. Sheeran, and S. Singh. Lava: Hardware design in haskell. In ACM SIGPLAN Notices, volume 34, pages 174--184. ACM, 1998. Google Scholar
Digital Library
- K. Claessen and D. Sands. Observable sharing for functional circuit description. In Advances in Computing Science--ASIAN'99, pages 62--73. Springer, 1999. Google Scholar
Digital Library
- K. Claessen, M. Sheeran, and B. J. Svensson. Expressive array constructs in an embedded gpu kernel programming language. In Proceedings of the 7th workshop on Declarative aspects and applications of multicore programming, pages 21--30. ACM, 2012. Google Scholar
Digital Library
- C. Elliott, S. Finne, and O. De Moor. Compiling embedded languages. Journal of Functional Programming, 13 (3): 455--481, 2003. Google Scholar
Digital Library
- P. Hudak. Domain-specific languages. Handbook of Programming Languages, 3: 39--60, 1997.Google Scholar
- S. P. Jones, A. Tolmach, and T. Hoare. Playing by the rules: Rewriting as a practical optimisation technique in ghc. In Haskell Workshop, volume 1, pages 203--233, 2001.Google Scholar
- G. Keller, M. M. Chakravarty, R. Leshchinskiy, S. Peyton Jones, and B. Lippmeier. Regular, shape-polymorphic, parallel arrays in haskell. ACM Sigplan Notices, 45 (9): 261--272, 2010. Google Scholar
Digital Library
- J. Launchbury and S. L. Peyton Jones. Lazy functional state threads. In ACM SIGPLAN Notices, volume 29, pages 24--35. ACM, 1994. Google Scholar
Digital Library
- B. Lippmeier and G. Keller. Efficient parallel stencil convolution in haskell. In ACM SIGPLAN Notices, volume 46, pages 59--70. ACM, 2011. Google Scholar
Digital Library
- G. Mainland. nikola. http://github.com/mainland/nikola.Google Scholar
- G. Mainland and G. Morrisett. Nikola: Embedding compiled gpu functions in haskell. In ACM Sigplan Notices, volume 45, pages 67--78. ACM, 2010. Google Scholar
Digital Library
- D. A. Orchard, M. Bolingbroke, and A. Mycroft. Ypnos: Declarative, parallel structured grid programming. In Proceedings of the 5th ACM SIGPLAN workshop on Declarative aspects of multicore programming, pages 15--24. ACM, 2010. Google Scholar
Digital Library
- B. O'Sullivan. criterion. http://hackage.haskell.org/package/criterion.Google Scholar
- A. Persson, E. Axelsson, and J. Svenningsson. Generic monadic constructs for embedded languages. In Implementation and Application of Functional Languages, pages 85--99. Springer, 2012. Google Scholar
Digital Library
- A. Reid, J. Peterson, G. Hager, and P. Hudak. Prototyping real-time vision systems: An experiment in dsl design. In Proceedings of the 21st international conference on Software engineering, pages 484--493. ACM, 1999. Google Scholar
Digital Library
- S. Seefried, M. Chakravarty, and G. Keller. Optimising embedded dsls using template haskell. In Generative Programming and Component Engineering, pages 186--205. Springer, 2004.Google Scholar
Cross Ref
- J. Svenningsson and E. Axelsson. Combining deep and shallow embedding for edsl. In Trends in Functional Programming, LLNCS. Springer, 2012.Google Scholar
- J. Svensson, M. Sheeran, and K. Claessen. Obsidian: A domain specific embedded language for parallel programming of graphics processors. In Implementation and Application of Functional Languages, pages 156--173. Springer, 2011. Google Scholar
Digital Library
- H. Thielemann. synthesizer. http://www.haskell.org/haskellwiki/Synthesizer,.Google Scholar
- H. Thielemann. synthesizer-llvm. http://hackage.haskell.org/package/synthesizer-llvm,.Google Scholar
Index Terms
An EDSL approach to high performance Haskell programming
Recommendations
An EDSL approach to high performance Haskell programming
Haskell '13: Proceedings of the 2013 ACM SIGPLAN symposium on HaskellThis paper argues for a new methodology for writing high performance Haskell programs by using Embedded Domain Specific Languages.
We exemplify the methodology by describing a complete library, meta-repa, which is a reimplementation of parts of the repa ...
Template meta-programming for Haskell
We propose a new extension to the purely functional programming language Haskell that supports compile-time meta-programming. The purpose of the system is to support the algorithmic construction of programs at compile-time.The ability to generate code ...
Template meta-programming for Haskell
Haskell '02: Proceedings of the 2002 ACM SIGPLAN workshop on HaskellWe propose a new extension to the purely functional programming language Haskell that supports compile-time meta-programming. The purpose of the system is to support the algorithmic construction of programs at compile-time.The ability to generate code ...







Comments