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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
Similar content being viewed by others
References
GNU Octave, http://www.gnu.org/software/octave/index.html
McLab: An Extensible Compiler Framework for Matlab. Home page, http://www.sable.mcgill.ca/mclab/
Accelerating Matlab (2002), http://www.mathworks.com/company/newsletters/digest/sept02/accel_matlab.pdf
Aho, A.V., Sethi, R., Ullman, J.D.: Compilers: Principles, Techniques and Tools. Addison Wesley, Reading (1985)
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)
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)
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)
Banerjee, U.K.: Dependence Analysis for Supercomputing. Kluwer Academic Publishers, Norwell (1988)
Banerjee, U.K.: Loop Transformations for Restructuring Compilers: The Foundations. Kluwer Academic Publishers, Norwell (1993)
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)
Burke, M.G., Cytron, R.K.: Interprocedural Dependence Analysis and Parallelization. SIGPLAN Not. 39(4), 139–154 (2004)
Chevalier-Boisvert, M.: McVM: An Optimizing Virtual Machine for the MATLAB Programming Language. Master’s thesis, McGill University (August 2009)
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)
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)
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)
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)
Matlab. The Language Of Technical Computing. Home page, http://www.mathworks.com/products/matlab/
Sarkar, V.: Automatic Selection of High-Order Transformations in the IBM XL FORTRAN compilers. IBM J. Res. Dev. 41(3), 233–264 (1997)
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)
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)
Wolfe, M.J.: Optimizing Supercompilers for Supercomputers. MIT Press, Cambridge (1990)
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)
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights 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)