Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
skip to main content
research-article

Finding parallel functional pearls

Published: 01 February 2018 Publication History

Abstract

This paper describes a new technique for identifying potentially parallelisable code structures in functional programs. Higher-order functions enable simple and easily understood abstractions that can be used to implement a variety of common recursion schemes, such as maps and folds over traversable data structures. Many of these recursion schemes have natural parallel implementations in the form of algorithmic skeletons. This paper presents a technique that detects instances of potentially parallelisable recursion schemes in Haskell98 functions. Unusually, we exploit anti-unification to expose these recursion schemes from source-level definitions whose structures match a recursion scheme, but which are not necessarily written directly in terms of maps, folds, etc. This allows us to automatically introduce parallelism, without requiring the programmer to structure their code a priori in terms of specific higher-order functions. We have implemented our approach in the Haskell refactoring tool, HaRe, and demonstrated its use on a range of common benchmarking examples. Using our technique, we show that recursion schemes can be easily detected, that parallel implementations can be easily introduced, and that we can achieve real parallel speedups (up to 23.79 the sequential performance on 28 physical cores, or 32.93 the sequential performance with hyper-threading enabled). We present a technique using anti-unification to discover recursion schemes in Haskell functions.We present a new, specialised anti-unification algorithm.We have implemented our approach using the Haskell refactoring tool HaRe.We have demonstrated our approach on a range of standard examples.Our technique is in principle completely general, able to discover arbitrary patterns in code.

References

[1]
H. Gonzlez-Vlez, M. Leyton, A Survey of Algorithmic Skeleton Frameworks: High-level Structured Parallel Programming Enablers, Softw. Pract. Exp, Vol. 40, in:, John Wiley & Sons, Inc., New York, NY, USA, 2010, pp. 1135-1160.
[2]
A. Barwell, C. Brown, K. Hammond, W. Turek, A. Byrski, Using Program Shaping to Parallelise an Evolutionary Multi-Agent System in Erlang, J. Comput. Inform. (2017).
[3]
M. Cole, MIT Press, Cambridge, MA, USA, 1991.
[4]
D. Castro, S. Sarkar, K. Hammond, Farms, Pipes, Streams and Reforestation: Reasoning about Structured Parallel Processes using Types and Hylomorphisms, in: Proc. ICFP16, 2016, pp. 417.
[5]
V. Janjic, C. Brown, K. Hammond, Lapedo: Hybrid Skeletons for Programming Heterogeneous Multicore Machines in Erlang, in: Parallel Computing: On the Road To Exascale, Vol. 27, 2016, pp. 185.
[6]
M. Coppola, M. Vanneschi, High-performance data mining with skeleton-based structured parallel programming, Parallel Comput., 28 (2002) 793-813.
[7]
V. Kannan, G. Hamilton, Program Transformation to Identify Parallel Skeletons, in: Int. Conf. on Parallel, Distributed, and Network-Based Processing, IEEE, 2016, pp. 486-494.
[8]
I. Boz, V. Fords, Z. Horvath, M. Tth, D. Horpcsi, T. Kozsik, J. Kszegi, A. Barwell, C. Brown, K. Hammond, Discovering Parallel Pattern Candidates in Erlang, in: Proc. 2014 ACM Erlang Workshop, 2014, pp. 1323, ISBN 978-1-4503-3038-1.
[9]
W. Partain, The nofib Benchmark suite of haskell programs, in: Functional Programming, Glasgow 1992: Proceedings of the 1992 Glasgow Workshop on Functional Programming, Ayr, Scotland, 68 July 1992, Springer London, London, 1993, pp. 195-202.
[10]
G.D. Plotkin, A note on inductive generalization, Mach. Intell., 5 (1970) 153-163.
[11]
S. Breitinger, R. Loogen, Y.O. Mallen, R. Pena, The Eden Coordination Model for Distributed Memory Systems, in: Proceedings of the 1997 Workshop on High-Level Programming Models and Supportive Environments, HIPS97, HIPS97, 1997, pp. 120124, ISBN 0-8186-7882-8.
[12]
S. Marlow, R. Newton, S. Peyton Jones, A Monad for Deterministic Parallelism, in: Proceedings of the 4th ACM Symposium on Haskell, Haskell11, 2011, pp. 7182, ISBN 978-1-4503-0860-1.
[13]
M.M. Chakravarty, G. Keller, S. Lee, T.L. McDonell, V. Grover, Accelerating Haskell Array Codes with Multicore GPUs, in: Proceedings of the Sixth Workshop on Declarative Aspects of Multicore Programming, DAMP11, 2011, pp. 314, ISBN 978-1-4503-0486-3.
[14]
N. Scaife, S. Horiguchi, G. Michaelson, P. Bristow, A Parallel SML Compiler Based on Algorithmic Skeletons, J. Funct. Programming, 15 (2005) 615-650.
[15]
J.C. Reynolds, Transformational Systems and the Algebraic Structure of Atomic Formulas, Mach. Intell., 5 (1970) 135-151.
[16]
C. Brown, University of Kent, 2009.
[17]
P.E. Bulychev, E.V. Kostylev, V.A. Zakharov, Anti-unification Algorithms and their Applications in Program Analysis, in: Proceedings of the 7th International Andrei Ershov Memorial Conference on Perspectives of Systems Informatics, PSI09, 2010, pp. 413423, ISBN 3-642-11485-7, 978-3-642-11485-4.
[18]
P. Bulychev, M. Minea, An Evaluation of Duplicate Code Detection using Anti-Unification, in: Proc. 3rd International Workshop on Software Clones, 2009.
[19]
C. Brown, H.-W. Loidl, K. Hammond, ParaForming: Forming Parallel Haskell Programs using Novel Refactoring Techniques, in: Proceedings of the 12th International Conference on Trends in Functional Programming, TFP11, 2012, pp. 8297, ISBN 978-3-642-32036-1.
[20]
K. Hammond, M. Aldinucci, C. Brown, F. Cesarini, M. Danelutto, H. Gonzlez-Vlez, P. Kilpatrick, R. Keller, M. Rossbory, G. Shainer, The Paraphrase Project: Parallel Patterns for Adaptive Heterogeneous Multicore Systems, in: Lecture Notes in Computer Science, vol. 7542, Springer, Berlin Heidelberg, 2013, pp. 218-236.
[21]
E. Horowitz, A. Zorat, Divide-and-Conquer for Parallel Processing, IEEE Trans. Comput., C-32 (1983) 582-585.
[22]
V. Janjic, C. Brown, K. MacKenzie, K. Hammond, M. Danelutto, M. Aldinucci, J.D. Garcia, RPL: A domain-specific language for designing and implementing parallel C++ applications, in: Proc. PDP16: Intl. Conf. on Parallel, Distrib. and Network-Based Proc, 2016, pp. 288295.
[23]
S. Marlow, P. Maier, H.-W. Loidl, M.K. Aswad, P. Trinder, Seq no more: Better Strategies for Parallel Haskell, in: Proceedings of the Third ACM Haskell Symposium on Haskell, Haskell10, 2010, pp. 91102, ISBN 978-1-4503-0252-4.
[24]
L. Bergstrom, J. Reppy, Nested data-parallelism on the Gpu, in: Proceedings of the 17th ACM SIGPLAN International Conference on Functional Programming, ICFP12, 2012, pp. 247258, ISBN 978-1-4503-1054-3.
[25]
C. Brown, M. Danelutto, K. Hammond, P. Kilpatrick, A. Elliott, Cost-directed Refactoring for Parallel Erlang Programs, Int. J. Parallel Program. (2013) 1-19.
[26]
Programatica: Integrating Programming, Properties and Validation, URL http://programatica.cs.pdx.edu.
[27]
D.A. Plaisted, Equational Reasoning and Term Rewriting Systems, in: Handbook of Logic in Artificial Intelligence and Logic Programming, Vol. 1, 1993, pp. 274-364.
[28]
R. Hinze, N. Wu, J. Gibbons, Unifying structured recursion schemes, SIGPLAN Not., 48 (2013) 209-220.
[29]
T. Kutsia, J. Levy, M. Villaret, Anti-unification for unranked terms and hedges, J. Automat. Reason., 52 (2014) 155-190.
[30]
H. Gust, K.-U. Khnberger, U. Schmid, Metaphors and anti-unification, in: Proc. Twenty-First Workshop on Language Technology: Algebraic Methods in Language Processing, Verona, Italy, 2003, pp. 111123.
[31]
J.W. Lloyd, An Algorithm of Generalization in Positive Supercompilation, in: Logic Programming: The 1995 International Symposium, MIT Press, 1995, pp. 465-479.
[32]
C. Oancea, C. So, S.M. Watt, Generalisation in Maple, pp. 277328.
[33]
C. Brown, S. Thompson, Clone Detection and Elimination for Haskell, in: Proceedings of the 2010 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, PEPM10, 2010, pp. 111120, ISBN 978-1-60558-727-1.
[34]
G. Huet, B. Lang, Proving and Applying Program Transformations Expressed with Second-order Patterns, Acta Inf., 11 (1978) 31-55.
[35]
R. Statman, Completeness, invariance and -definability, J. Symbolic Logic, 47 (1982) 1726.
[36]
O. de Moor, G. Sittampalam, Higher Order Matching for Program Transformation, in: A. Middeldorp, T. Sato (Eds.), Functional and Logic Programming: 4th Fuji International Symposium, FLOPS99 Tsukuba, Japan, November 1113, 1999 Proceedings, 1999, pp. 209224.
[37]
L. Gesbert, F. Gava, F. Loulergue, F. Dabrowski, Bulk synchronous parallel ML with exceptions, Future Gener. Comput. Syst., 26 (2010) 486-490.
[38]
F. Gava, F. Loulergue, A static analysis for bulk synchronous parallel ML to avoid parallel nesting, Future Gener. Comput. Syst., 21 (2005) 665-671.
[39]
C. Hammacher, K. Streit, S. Hack, A. Zeller, Profiling Java Programs for Parallelism, in: Proceedings of the 2009 ICSE Workshop on Multicore Software Engineering, IWMSE09, 2009, pp. 4955, ISBN 978-1-4244-3718-4.
[40]
R. Ferenc, A. Beszedes, L. Fulop, J. Lele, Design pattern mining enhanced by machine learning, in: 21st IEEE International Conference on Software Maintenance, ICSM05, 2005, pp. 295304, ISSN 1063-6773.
[41]
J. Ahn, T. Han, An Analytical Method for Parallelization of Recursive Functions, Parallel Process. Lett., 10 (2000) 87-98.
[42]
A. Geser, S. Gorlatch, Parallelizing Functional Programs by Generalization, J. Funct. Programming, 9 (1999) 649-673.
[43]
S. Gorlatch, Extracting and Implementing List Homomorphisms in Parallel Program Development, Sci. Comput. Programming, 33 (1999) 1-27.
[44]
M. Dever, G.W. Hamilton, AutoPar: Automatic Parallelization of Functional Programs, in: 2014 Fourth International Valentin Turchin Workshop on Metacomputation, META 2014, 2014, pp. 1125.
[45]
J. Gibbons, The Third Homomorphism Theorem, J. Funct. Programming (JFP), 6 (1996) 657-665.
[46]
Z. Hu, H. Iwasaki, M. Takeichi, Deriving Structural Hylomorphisms from Recursive Definitions, SIGPLAN Not., 31 (1996) 73-82.
[47]
J. Gibbons, G. Jones, The Under-appreciated Unfold, SIGPLAN Not., 34 (1998) 273-279.

Cited By

View all

Recommendations

Comments

Information & Contributors

Information

Published In

cover image Future Generation Computer Systems
Future Generation Computer Systems  Volume 79, Issue P2
February 2018
310 pages

Publisher

Elsevier Science Publishers B. V.

Netherlands

Publication History

Published: 01 February 2018

Qualifiers

  • Research-article

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)0
  • Downloads (Last 6 weeks)0
Reflects downloads up to 11 Feb 2025

Other Metrics

Citations

Cited By

View all
  • (2024)One or Nothing: Anti-unification over the Simply-Typed Lambda CalculusACM Transactions on Computational Logic10.1145/365479825:3(1-12)Online publication date: 28-Mar-2024
  • (2023)Anti-unification and generalizationProceedings of the Thirty-Second International Joint Conference on Artificial Intelligence10.24963/ijcai.2023/736(6563-6573)Online publication date: 19-Aug-2023
  • (2022)A Framework for Approximate Generalization in Quantitative TheoriesAutomated Reasoning10.1007/978-3-031-10769-6_34(578-596)Online publication date: 8-Aug-2022
  • (2018)An Architecture for Translating Sequential Code to ParallelProceedings of the 2nd International Conference on Information System and Data Mining10.1145/3206098.3206104(88-92)Online publication date: 9-Apr-2018

View Options

View options

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media