An Algebraic Framework for Parallelizing Recurrence in Functional Programming

  • Rodrigo C. O. Rocha
  • Luís F. W. Góes
  • Fernando M. Q. PereiraEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 9889)


The main challenge faced by automatic parallelization tools in functional languages is the fact that parallelism is often hidden under the syntax of complex recursive functions. In this paper, we propose an algebraic framework for parallelizing – automatically – two special classes of recursive functions. We show that these classes are comprehensive enough to include several well-known instances. We have used our ideas to implement a source-to-source compiler in Python to parallelize Haskell code. We have applied this prototype onto six different recursive functions, achieving, on a 4-core machine, speedups of up to 2.7x.


Recursive functions Parallel computing Functional programming Algebraic framework Abstract algebra 


  1. 1.
    Berthold, J., Marlow, S., Hammond, K., Al Zain, A.: Comparing and optimising parallel Haskell implementations for multicore machines. In: ADPNA. IEEE (2009)Google Scholar
  2. 2.
    Bondhugula, U., Baskaran, M., Krishnamoorthy, S., Ramanujam, J., Rountev, A., Sadayappan, P.: Automatic transformations for communication-minimized parallelization and locality optimization in the polyhedral model. In: Hendren, L. (ed.) CC 2008. LNCS, vol. 4959, pp. 132–146. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  3. 3.
    Bondhugula, U., Hartono, A., Ramanujam, J., Sadayappan, P.: A practical automatic polyhedral parallelizer and locality optimizer. In: PLDI. ACM (2008)Google Scholar
  4. 4.
    Brown, C., Danelutto, M., Hammond, K., Kilpatrick, P., Elliott, A.: Cost-directed refactoring for parallel erlang programs. Int. J. Parallel Programm. 42(4), 564–582 (2013)CrossRefGoogle Scholar
  5. 5.
    Cole, M.: Parallel programming with list homomorphisms. Parallel Process. Lett. 5(02), 191–203 (1995)CrossRefGoogle Scholar
  6. 6.
    Collins, A., Grewe, D., Grover, V., Lee, S., Susnea, A.: NOVA: a functional language for data parallelism. In: ARRAY. ACM (2014)Google Scholar
  7. 7.
    Feautrier, P.: Automatic parallelization in the polytope model. In: Perrin, G.-R., Darte, A. (eds.) The Data Parallel Programming Model. LNCS, vol. 1132, pp. 79–103. Springer, Heidelberg (1996)CrossRefGoogle Scholar
  8. 8.
    Fisher, A.L., Ghuloum, A.M.: Parallelizing complex scans and reductions. In: PLDI. ACM (1994)Google Scholar
  9. 9.
    Golan, J.S.: Power Algebras over Semirings: With Applications in Mathematics and Computer Science. Mathematics and Its Applications, vol. 488, 1st edn. Springer, Basel (1999)CrossRefzbMATHGoogle Scholar
  10. 10.
    Golan, J.S.: Semirings and their Applications, 1st edn. Springer, Heidelberg (1999)CrossRefzbMATHGoogle Scholar
  11. 11.
    Govindarajan, R., Anantpur, J.: Runtime dependence computation and execution of loops on heterogeneous systems. In: CGO. IEEE/ACM (2013)Google Scholar
  12. 12.
    Hammond, K., Berthold, J., Loogen, R.: Automatic skeletons in template haskell. Parallel Process. Lett. 13(03), 413–424 (2003)MathSciNetCrossRefGoogle Scholar
  13. 13.
    Hu, Z., Iwasaki, H., Takechi, M.: Formal derivation of efficient parallel programs by construction of list homomorphisms. Trans. Program. Lang. Syst. 19(3), 444–461 (1997)CrossRefGoogle Scholar
  14. 14.
    Kogge, P.M., Stone, H.S.: A parallel algorithm for the efficient solution of a general class of recurrence equations. Trans. Comput. 22(8), 786–793 (1973)MathSciNetCrossRefzbMATHGoogle Scholar
  15. 15.
    Liu, Y., Hu, Z., Matsuzaki, K.: Towards systematic parallel programming over MapReduce. In: Namyst, R., Roman, J., Jeannot, E. (eds.) Euro-Par 2011, Part II. LNCS, vol. 6853, pp. 39–50. Springer, Heidelberg (2011)CrossRefGoogle Scholar
  16. 16.
    Marlow, S., Maier, P., Loidl, H.W., Aswad, M.K., Trinder, P.W.: Seq no more: Better strategies for parallel Haskell. In: Haskell Symposium. ACM Press (2010)Google Scholar
  17. 17.
    Marlow, S., Peyton Jones, S., Singh, S.: Runtime support for multicore haskell. In: ICFP, pp. 65–78. ACM (2009)Google Scholar
  18. 18.
    Misailovic, S., Kim, D., Rinard, M.: Parallelizing sequential programs with statistical accuracy tests. Trans. Embed. Comput. Syst. 12(2), 88 (2013)Google Scholar
  19. 19.
    Morihata, A., Matsuzaki, K.: Automatic parallelization of recursive functions using quantifier elimination. In: Blume, M., Kobayashi, N., Vidal, G. (eds.) FLOPS 2010. LNCS, vol. 6009, pp. 321–336. Springer, Heidelberg (2010)CrossRefGoogle Scholar
  20. 20.
    Morita, K., Morihata, A., Matsuzaki, K., Hu, Z., Takeichi, M.: Automatic inversion generates divide-and-conquer parallel programs. In: PLDI. ACM (2007)Google Scholar
  21. 21.
    Rotman, J.J.: Advanced Modern Algebra, 2nd edn. Prentice Hall, Upper Saddle River (2003)zbMATHGoogle Scholar
  22. 22.
    Sato, S., Iwasaki, H.: Automatic parallelization via matrix multiplication. In: PLDI. ACM (2011)Google Scholar
  23. 23.
    Schlecht, S.J., Habets, E.A.P.: Connections between parallel and serial combinations of comb filters and feedback delay networks. In: IWAENC (2012)Google Scholar
  24. 24.
    Trifunovic, K., Nuzman, D., Cohen, A., Zaks, A., Rosen, I.: Polyhedral-model guided loop-nest auto-vectorization. In: PACT. IEEE (2009)Google Scholar
  25. 25.
    Wang, Z., Tournavitis, G., Franke, B., O’Boyle, M.F.P.: Integrating profile-driven parallelism detection and machine-learning-based mapping. Trans. Archit. Code Optim. 11(1), 2 (2014)Google Scholar
  26. 26.
    Zou, Y., Rajopadhye, S.: Scan detection and parallelization in “inherently sequential" nested loop programs. In: CGO. ACM (2012)Google Scholar

Copyright information

© Springer International Publishing Switzerland 2016

Authors and Affiliations

  • Rodrigo C. O. Rocha
    • 1
    • 2
  • Luís F. W. Góes
    • 1
  • Fernando M. Q. Pereira
    • 2
    Email author
  1. 1.Institute of Exact Sciences and InformaticsPUC MinasBelo HorizonteBrazil
  2. 2.Department of Computer ScienceUFMGBelo HorizonteBrazil

Personalised recommendations