International Journal of Parallel Programming

, Volume 42, Issue 4, pp 564–582 | Cite as

Cost-Directed Refactoring for Parallel Erlang Programs

  • Christopher BrownEmail author
  • Marco Danelutto
  • Kevin Hammond
  • Peter Kilpatrick
  • Archibald Elliott


This paper presents a new programming methodology for introducing and tuning parallelism in Erlang programs, using source-level code refactoring from sequential source programs to parallel programs written using our skeleton library, Skel. High-level cost models allow us to predict with reasonable accuracy the parallel performance of the refactored program, enabling programmers to make informed decisions about which refactorings to apply. Using our approach, we demonstrate easily obtainable, significant and scalable speedups of up to 21 on a 24-core machine over the sequential code.


Partition Function Cost Model Function Composition Chunk Size Input List 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.



This work has been supported by EU Framework 7 Grants IST-288570 “ParaPhrase” (, and IST-248828 “ADVANCE” (


  1. 1.
    Cesarini, F., Thompson, S.: ERLANG Programming, 1st edn. O’Reilly Media, Inc., Sebastopol, CA (2009)zbMATHGoogle Scholar
  2. 2.
    Cole, M.: Bringing skeletons out of the closet: a pragmatic manifesto for skeletal parallel programming. Parallel Comput. 30(3), 389–406 (2004)CrossRefGoogle Scholar
  3. 3.
    Li, H., Thompson, S.: A Comparative Study of Refactoring Haskell and Erlang Programs. SCAM 2006, pp. 197–206. IEEE (2006)Google Scholar
  4. 4.
    Aronis, S., Sagonas, K.: On using Erlang for parallelization: experience from parallelizing dialyzer. In: Loidl, H.-W. (ed.) Trends in Functional Programming 2012 (TFP 2012). Springer, St Andrews (2012)Google Scholar
  5. 5.
    Aronis, S., Papaspyrou, N., Roukounaki, K., Sagonas, K., Tsiouris, Y., Venetis, I.: A scalability benchmark suite for Erlang/OTP. In: Proceedings of 11th ACM SIGPLAN Workshop on Erlang Copenhagen, Denmark. pp. 33–42. ACM. NY, USA (2012)Google Scholar
  6. 6.
    Opdyke, W.: Refactoring object-oriented frameworks. PhD Thesis, Department of Computer Science, University of Illinois at Urbana-Champaign, Champaign, IL, USA (1992)Google Scholar
  7. 7.
    Burstall, R.M., Darlington, J.: A transformation system for developing recursive programs. J. ACM 24(1), 44–67 (1977)CrossRefzbMATHMathSciNetGoogle Scholar
  8. 8.
    Li, H., Thompson, S.: Let’s Make Refactoring Tools User Extensible! The Fifth ACM Workshop on Refactoring Tools. Rapperswill, Switzerland (2012)Google Scholar
  9. 9.
    Li, H., Thompson, S.: A domain-specific language for scripting refactorings in Erlang. In: Proceedings 15th International Conference on Fund. Approaches to Software Engineering, pp. 501–515. (2012)Google Scholar
  10. 10.
    Caromel, D., Leyton, M.: Fine tuning algorithmic skeletons. In: Kermarrec, A.-M., Bougé, L., Priol, T. (eds.) Euro-Par, vol. 4641. Lecture Notes in Computer Science. Springer, Rennes (2007)Google Scholar
  11. 11.
    Pelagatti, S.: Structured Development of Parallel Programs. Taylor and Francis, London (1999)Google Scholar
  12. 12.
    Aldinucci, M.: Automatic program transformation: the meta tool for skeleton-based languages. In: Gorlatch, S., Lengauer, C. (eds.) Constructive Methods for Parallel Programming, Advances in Computation: Theory and Practice, chap. 5, pp. 59–78. Nova Science, NY (2002)Google Scholar
  13. 13.
    Aldinucci, M., Coppola, M., Danelutto, M.: Rewriting Skeleton Programs: How to Evaluate the Data-Parallel Stream-Parallel Tradeoff, pp. 44–58. CMPP, Germany (1998)Google Scholar
  14. 14.
    Partsch, H., Steinbruggen, R.: Program transformation systems. ACM Comput. Surv. 15(3), 199–236 (1983)CrossRefMathSciNetGoogle Scholar
  15. 15.
    Mens, T., Tourwé, T.: A survey of software refactoring. IEEE Trans. Softw. Eng. 30(2), 126–139 (2004)CrossRefGoogle Scholar
  16. 16.
    Burstall, R.M., Darlington, J.: A transformation system for developing recursive programs. J. ACM 24(1), 44–67 (1977)CrossRefzbMATHMathSciNetGoogle Scholar
  17. 17.
    Hammond, K., Aldinucci, M., Brown, C., Cesarini, F., Danelutto, M., Gonzalez-Velez, H., Kilpatrick, P., Keller, R., Natschlager, T., Shainer, G.: The ParaPhrase Project: Parallel Patterns for Adaptive Heterogeneous Multicore Systems. FMCO, Turin (2012)Google Scholar
  18. 18.
    Hammond, K., Berthold, J., Loogen, R.: Automatic skeletons in template Haskell. Parallel Process. Lett. 13(3), 413–424 (2003)CrossRefMathSciNetGoogle Scholar
  19. 19.
    Sheard, T., Jones, S.P.: Template meta-programming for Haskell. SIGPLAN Not. 37, 60–75 (2002)CrossRefGoogle Scholar
  20. 20.
    Loogen, R., Ortega-Mallén, Y., Peña-Marí, R.: Parallel functional programming in Eden. J. Funct. Program. 15(3), 431–475 (2005)CrossRefzbMATHGoogle Scholar
  21. 21.
    Wloka, J., Sridharan, M., Tip, F.: Refactoring for Reentrancy. ESEC/FSE ’09, pp.. 173–182. ACM, Amsterdam (2009)Google Scholar
  22. 22.
    Dig, D.: A refactoring approach to parallelism. IEEE Softw. 28, 17–22 (2011)CrossRefGoogle Scholar
  23. 23.
    Brown, C., Li, H., Thompson, S.: An expression processor: a case study in refactoring Haskell programs. In: Eleventh Symposium on Trends in Functional Programming (2010)Google Scholar
  24. 24.
    Brown, C., Loidl, H., Hammond, K.: Paraforming: forming Haskell programs using novel refactoring rechniques. In: 12th Symposium on Trends in Functional Programming, Spain (2011)Google Scholar
  25. 25.
    Brown, C., Hammond, K., Danelutto, M., Kilpatrick, P.: A language-independent parallel refactoring framework. In: Proceedings of the Fifth Workshop on Refactoring Tools (WRT ’12), pp. 54–58. ACM, New York, USA (2012)Google Scholar
  26. 26.
    Matsuzaki, K., Iwasaki, H., Emoto, K., Hu, Z.: A Library of Constructive Skeletons for Sequential Style of Parallel Programming. InfoScale ’06. Article 13, Hong Kong. ACM, NY, USA (2006)Google Scholar
  27. 27.
    Bacci, B., Danelutto, M., Orlando, S., Pelagatti, S., Vanneschi, M.: \(\text{ P }^3\)L: a structured high level program language and its structured support. Concurr. Pract. Exp. 7(3), 225–255 (1995)CrossRefGoogle Scholar
  28. 28.
    Botorog, G.H., Kuchen, H.: Skil: An imperative language with algorithmic skeletons for efficient distributed programming. In: Proceedings of the 5th International Symposium on High Performance Distributed Computing (HPDC ’96), pp. 243–252. IEEE Computer Society Press, Syracuse, NY, USA (1996)Google Scholar
  29. 29.
    Cole, M.: Algorithmic skeletons: structured management of parallel computations. In: Research Monographs in Par. and Distrib. Computing. Pitman (1989)Google Scholar
  30. 30.
    Darlington, J., Guo, Y., Jing, Y., To, H.W.: Skeletons for Structured Parallel Composition. In: Proceedings of the 15th Symposium on Princ. and Prac. of Parallel Programming (1995)Google Scholar
  31. 31.
    Aldinucci, M., Danelutto, M.: Stream Parallel Skeleton Optimization. In: Proceedings of the International Conference on Parallel and Distributed Computing and Systems (PDCS), pp. 955–962. IASTED, ACTA Press, Cambridge, MA, USA (1999)Google Scholar
  32. 32.
    Aldinucci, M., Gorlatch, S., Lengauer, C., Pelagatti, S.: Towards parallel programming by transformation: the FAN skeleton framework. Parallel Algorithm Appl. 16(2–3), 87–121 (2001)CrossRefzbMATHMathSciNetGoogle Scholar
  33. 33.
    Gorlatch, S., Wedler, C., Lengauer, C.: Optimization rules for programming with collective operations. In: Proceedings of the 13th International Symposium on Par. Proceedings and the 10th Symposium on Par. and Dist. Proc., pp. 492–499, Washington, DC, USA (1999)Google Scholar
  34. 34.
    Skillicorn, D.B., Cai, W.: A cost calculus for parallel functional programming. J. Parallel Distrib. Comput. 28(1), 65–83 (1995)CrossRefzbMATHGoogle Scholar
  35. 35.
    Li, H., Thompson, S.: Formalisation of Haskell refactorings. Trends Funct. Program. (2005)Google Scholar

Copyright information

© Springer Science+Business Media New York 2013

Authors and Affiliations

  • Christopher Brown
    • 1
    Email author
  • Marco Danelutto
    • 2
  • Kevin Hammond
    • 1
  • Peter Kilpatrick
    • 3
  • Archibald Elliott
    • 1
  1. 1.School of Computer ScienceUniversity of St AndrewsSaint AndrewsScotland, UK
  2. 2.Department of Computer ScienceUniversity of PisaPisaItaly
  3. 3.School of Electronics, Electrical Engineering and Computer ScienceQueen’s UniversityBelfastUK

Personalised recommendations