Skip to main content

McFLAT: A Profile-Based Framework for MATLAB Loop Analysis and Transformations

  • Conference paper
Languages and Compilers for Parallel Computing (LCPC 2010)

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 6548))

Abstract

Parallelization and optimization of the Matlab programming language presents several challenges due to the dynamic nature of Matlab. Since Matlab does not have static type declarations, neither the shape and size of arrays, nor the loop bounds are known at compile-time. This means that many standard array dependence tests and associated transformations cannot be applied straight-forwardly. On the other hand, many Matlab programs operate on arrays using loops and thus are ideal candidates for loop transformations and possibly loop vectorization/parallelization.

This paper presents a new framework, McFlat, which uses profile-based training runs to determine likely loop-bounds ranges for which specialized versions of the loops may be generated. The main idea is to collect information about observed loop bounds and hot loops using training data which is then used to heuristically decide upon which loops and which ranges are worth specializing using a variety of loop transformations.

Our McFlat framework has been implemented as part of the McLab extensible compiler toolkit. Currently, McFlat, is used to automatically transform ordinary Matlab code into specialized Matlab code with transformations applied to it. This specialized code can be executed on any Matlab system, and we report results for four execution engines, Mathwork’s proprietary Matlab system, the GNU Octave open-source interpreter, McLab’s McVM interpreter and the McVM JIT. For several benchmarks, we observed significant speedups for the specialized versions, and noted that loop transformations had different impacts depending on the loop range and execution engine.

This work was supported, in part, by NSERC.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. GNU Octave, http://www.gnu.org/software/octave/index.html

  2. McLab: An Extensible Compiler Framework for Matlab. Home page, http://www.sable.mcgill.ca/mclab/

  3. Accelerating Matlab (2002), http://www.mathworks.com/company/newsletters/digest/sept02/accel_matlab.pdf

  4. Aho, A.V., Sethi, R., Ullman, J.D.: Compilers: Principles, Techniques and Tools. Addison Wesley, Reading (1985)

    MATH  Google Scholar 

  5. Almasi, G., Padua, D.A.: MaJIC: A MATLAB Just-In-Time Compiler. In: Midkiff, S.P., Moreira, J.E., Gupta, M., Chatterjee, S., Ferrante, J., Prins, J.F., Pugh, B., Tseng, C.-W. (eds.) LCPC 2000. LNCS, vol. 2017, p. 68. Springer, Heidelberg (2001)

    Google Scholar 

  6. Arnold, M., Fink, S., Grove, D., Hind, M., Sweeney, P.F.: Adaptive Optimization in the Jalapeño JVM. In: OOPSLA 2000: Proceedings of the 15th ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications, pp. 47–65. ACM, New York (2000)

    Chapter  Google Scholar 

  7. Aslam, T., Doherty, J., Dubrau, A., Hendren, L.: AspectMatlab: An Aspect-Oriented Scientific Programming Language. In: Proceedings of 9th International Conference on Aspect-Oriented Software Development, pp. 181–192 (March 2010)

    Google Scholar 

  8. Banerjee, U.K.: Dependence Analysis for Supercomputing. Kluwer Academic Publishers, Norwell (1988)

    Book  Google Scholar 

  9. Banerjee, U.K.: Loop Transformations for Restructuring Compilers: The Foundations. Kluwer Academic Publishers, Norwell (1993)

    Book  MATH  Google Scholar 

  10. Birkbeck, N., Levesque, J., Amaral, J.N.: A Dimension Abstraction Approach to Vectorization in Matlab. In: CGO 2007: Proceedings of the International Symposium on Code Generation and Optimization, Washington, DC, USA, 2007, pp. 115–130. IEEE Computer Society, Los Alamitos (2007)

    Google Scholar 

  11. Burke, M.G., Cytron, R.K.: Interprocedural Dependence Analysis and Parallelization. SIGPLAN Not. 39(4), 139–154 (2004)

    Article  Google Scholar 

  12. Chevalier-Boisvert, M.: McVM: An Optimizing Virtual Machine for the MATLAB Programming Language. Master’s thesis, McGill University (August 2009)

    Google Scholar 

  13. Chevalier-Boisvert, M., Hendren, L., Verbrugge, C.: Optimizing MATLAB through Just-In-Time Specialization. In: International Conference on Compiler Construction, pp. 46–65 (March 2010)

    Google Scholar 

  14. Cooper, K.D., Schielke, P.J., Subramanian, D.: Optimizing for Reduced Code Space using Genetic Algorithms. In: LCTES 1999: Proceedings of the ACM SIGPLAN 1999 Workshop on Languages, Compilers, and Tools for Embedded Systems, pp. 1–9. ACM, New York (1999)

    Chapter  Google Scholar 

  15. Lam, M.S., Wolf, M.E.: A Data Locality Optimizing Algorithm. In: PLDI 1991: Programming Language Design and Implementation, vol. 39, pp. 442–459. ACM, New York (2004)

    Google Scholar 

  16. Lim, A.W., Lam, M.S.: Maximizing Parallelism and Minimizing Synchronization with Affine Transforms. In: POPL 1997: Proceedings of the 24th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, pp. 201–214. ACM, New York (1997)

    Google Scholar 

  17. Matlab. The Language Of Technical Computing. Home page, http://www.mathworks.com/products/matlab/

  18. Sarkar, V.: Automatic Selection of High-Order Transformations in the IBM XL FORTRAN compilers. IBM J. Res. Dev. 41(3), 233–264 (1997)

    Article  Google Scholar 

  19. Tournavitis, G., Wang, Z., Franke, B., O’Boyle, M.F.: Towards a Holistic Approach to Auto-Parallelization: Integrating Profile-Priven Parallelism Detection and Machine-Learning based Mapping. In: PLDI 2009: Programming Languages Design and Implementation, vol. 44, pp. 177–187. ACM, New York (2009)

    Google Scholar 

  20. Wolf, M.E., Lam, M.S.: A Loop Transformation Theory and an Algorithm to Maximize Parallelism. IEEE Trans. Parallel Distrib. Syst. 2(4), 452–471 (1991)

    Article  Google Scholar 

  21. Wolfe, M.J.: Optimizing Supercompilers for Supercomputers. MIT Press, Cambridge (1990)

    MATH  Google Scholar 

  22. Zhao, M., Childers, B., Soffa, M.L.: Predicting the Impact of Optimizations for Embedded Systems. In: Proceedings of the 2003 ACM SIGPLAN Conference on Language, Compiler, and Tool Support for Embedded Systems, San Diego, CA, USA, vol. 38, pp. 1–11. ACM, New York (2003)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2011 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Aslam, A., Hendren, L. (2011). McFLAT: A Profile-Based Framework for MATLAB Loop Analysis and Transformations. In: Cooper, K., Mellor-Crummey, J., Sarkar, V. (eds) Languages and Compilers for Parallel Computing. LCPC 2010. Lecture Notes in Computer Science, vol 6548. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-19595-2_1

Download citation

  • DOI: https://doi.org/10.1007/978-3-642-19595-2_1

  • Publisher Name: Springer, Berlin, Heidelberg

  • Print ISBN: 978-3-642-19594-5

  • Online ISBN: 978-3-642-19595-2

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics