Parallel Processing Letters ❢ c World Scientific Publishing Company AUTOMATIC SKELETONS IN TEMPLATE HASKELL Kevin Hammond * School of Computer Science, University of St Andrews, North Haugh, St Andrews, UK Jost Berthold and Rita Loogen * Fachbereich Mathematik und Informatik, Philipps-Universit¨at Marburg, Germany Received April 2003 Revised July 2003 Communicated by Ga´etan Hains and Fr´ed´eric Loulergue ABSTRACT This paper uses Template Haskell to automatically select appropriate skeleton imple- mentations in the Eden parallel dialect of Haskell. The approach allows implementation parameters to be statically tuned according to architectural cost models based on source analyses. This permits us to target a range of parallel architecture classes from a sin- gle source specification. A major advantage of the approach is that cost models are user-definable and can be readily extended to new data or computation structures etc. 1. Introduction The notion of a skeleton or pattern capturing computational structure has now become widespread [1]. One common application is to parallel computing, where such patterns can reduce the cost and complexity of producing parallel code, by allowing algorithms to be specified as a conjunction of common patterns of paral- lel computation. In earlier papers, we have shown how algorithmic skeletons can be written both in the explicitly parallel Eden [2], and in the implicitly parallel GpH [3], developed new functional skeletons corresponding to branch-and-bound and heuristic search [4], and introduced implementation skeletons corresponding to implementation-specific instances of high-level skeletons [5]. Such implementation skeletons must, however, be selected by the programmer. This paper considers the problem of selecting appropriate implementations automatically at compile-time us- ing new Haskell meta-programming constructs driven by static cost models. The meta-programming approach has the advantage of eliminating dynamic overheads caused by introducing adaptors to match high-level specifications to specific imple- mentation skeletons, while still allowing a single source program to be targeted to multiple platforms and architectures. Moreover, implementation skeleton parame- ters can be automatically tuned at compile-time to suit a target architecture. * This work is generously supported by EPSRC grants GR/R 70545/01, GR/R 91298/01 and GR/S 15198/01 and by joint travel grants from the British Council/DAAD.