A MATLAB subset to C compiler targeting embedded systems

This paper describes MATISSE, a compiler able to translate a MATLAB subset to C targeting embedded systems. MATISSE uses LARA, an aspect‐oriented programming language, to specify additional information and transformations to the input MATLAB code, for example, insertion of code for initialization of variables, and specification of types and shapes of variables. The compiler is being developed bearing in mind flexibility, multitarget and multitoolchain support, allowing for the generation of several implementations in C from the same reference code in MATLAB. In this paper, we also present a number of techniques being employed in MATLAB to C compilation, such as element‐wise mapping operations, matrix views, weak types, and intrinsics. We validate these techniques using MATISSE and a set of representative benchmarks. More specifically, we evaluate the compiler with a set of 31 benchmarks using an embedded system board and a desktop computer. The results show speedups up to 1.8× by employing information provided by LARA aspects, when compared with C code generated without additional user information. When compared with the execution time of the original code running on MATLAB, the execution time of the generated C code achieved a geometric mean speedup of 13×. Copyright © 2016 John Wiley & Sons, Ltd.

[1]  Eelco Visser,et al.  Turning dynamic typing into static typing by program specialization in a compiler front-end for Octave , 2003, Proceedings Third IEEE International Workshop on Source Code Analysis and Manipulation.

[2]  Wayne Luk,et al.  Performance‐driven instrumentation and mapping strategies using the LARA aspect‐oriented programming approach , 2016, Softw. Pract. Exp..

[3]  Prithviraj Banerjee,et al.  Automatic conversion of floating point MATLAB programs into fixed point FPGA based hardware design , 2003, 11th Annual IEEE Symposium on Field-Programmable Custom Computing Machines, 2003. FCCM 2003..

[4]  Prithviraj Banerjee,et al.  A translator system for the MATLAB language , 2007, Softw. Pract. Exp..

[5]  R. Govindarajan,et al.  Automatic compilation of MATLAB programs for synergistic execution on heterogeneous processors , 2011, PLDI '11.

[6]  David A. Padua,et al.  Techniques for the translation of MATLAB programs into Fortran 90 , 1999, TOPL.

[7]  Pedro C. Diniz,et al.  Compilation and Synthesis for Embedded Reconfigurable Systems , 2013 .

[8]  Laurie J. Hendren,et al.  MIX10: compiling MATLAB to X10 for high performance , 2014, OOPSLA.

[9]  João Saraiva,et al.  Program and Aspect Metrics for MATLAB , 2012, ICCSA.

[10]  Alok N. Choudhary,et al.  Parallelization of MATLAB Applications for a Multi-FPGA System , 2001, The 9th Annual IEEE Symposium on Field-Programmable Custom Computing Machines (FCCM'01).

[11]  David A. Padua,et al.  MaJIC: A Matlab Just-In-time Compiler , 2000, LCPC.

[12]  João Saraiva,et al.  A domain-specific aspect language for transforming MATLAB programs , 2010 .

[13]  Miguel P. Monteiro,et al.  Adding aspect-oriented features to MATLAB , 2006 .

[14]  J. Demmel,et al.  Sun Microsystems , 1996 .

[15]  Laurie J. Hendren,et al.  AspectMatlab++: annotations, types, and aspects for scientists , 2015, MODULARITY.

[16]  Laurie J. Hendren,et al.  AspectMatlab: an aspect-oriented scientific programming language , 2010, AOSD.

[17]  João M. P. Cardoso,et al.  Techniques for efficient MATLAB-to-C compilation , 2015, ARRAY@PLDI.

[18]  Dimitrios Kritharidis,et al.  From Scilab to High Performance Embedded Multicore Systems: The ALMA Approach , 2012, 2012 15th Euromicro Conference on Digital System Design.

[19]  Luiz A. DeRose,et al.  Compiler techniques for MATLAB programs , 1996 .

[20]  Jun Li,et al.  MCFOR: A MATLAB TO FORTRAN 95 COMPILER , 2010 .

[21]  Prithviraj Banerjee,et al.  Static array storage optimization in MATLAB , 2003, PLDI '03.

[22]  Laurie J. Hendren,et al.  First steps to compiling Matlab to X10 , 2013, X10 '13.

[23]  Luis Paulo Reis,et al.  OpenCL Generation from MATLAB , 2014 .

[24]  Prithviraj Banerjee,et al.  A translator system for the MATLAB language: Research Articles , 2007 .

[25]  Wayne Luk,et al.  LARA: an aspect-oriented programming language for embedded systems , 2012, AOSD '12.

[26]  Jun Li,et al.  McLab: an extensible compiler toolkit for MATLAB and related languages , 2010, C3S2E '10.

[27]  Laurie J. Hendren,et al.  Kind analysis for MATLAB , 2011, OOPSLA '11.

[28]  João M. P. Cardoso,et al.  C and OpenCL generation from MATLAB , 2015, SAC.

[29]  Matlab Matlab (the language of technical computing): using matlab graphics ver.5 , 2014 .

[30]  João M. P. Cardoso,et al.  Multi-Target C Code Generation from MATLAB , 2014, ARRAY@PLDI.

[31]  Nurudeen Abiodun Lameed,et al.  DYNAMIC COMPILER OPTIMIZATION TECHNIQUES FOR MATLAB , 2013 .

[32]  Pedro Pinto,et al.  The MATISSE MATLAB compiler , 2013, 2013 11th IEEE International Conference on Industrial Informatics (INDIN).

[33]  Alfred V. Aho,et al.  Compilers: Principles, Techniques, and Tools , 1986, Addison-Wesley series in computer science / World student series edition.

[34]  Gregor Kiczales,et al.  Aspect-oriented programming , 2001, ESEC/FSE-9.

[35]  Arun Chauhan,et al.  MATLAB Parallelization through Scalarization , 2011, 2011 15th Workshop on Interaction between Compilers and Computer Architectures.

[36]  David A. Padua,et al.  A MATLAB to Fortran 90 translator and its effectiveness , 1996, ICS '96.

[37]  Best Practices for a MATLAB to C Workflow Using Real-Time Workshop , 2009 .

[38]  José Nelson Amaral,et al.  A Dimension Abstraction Approach to Vectorization in Matlab , 2007, International Symposium on Code Generation and Optimization (CGO'07).

[39]  Prithviraj Banerjee,et al.  An algebraic array shape inference system for MATLAB® , 2006, TOPL.

[40]  Laurie J. Hendren,et al.  Taming MATLAB , 2012, OOPSLA '12.

[41]  Gaurav Sharma,et al.  MATLAB®: A Language for Parallel Computing , 2009, International Journal of Parallel Programming.

[42]  David A. Padua,et al.  FALCON: A MATLAB Interactive Restructuring Compiler , 1995, LCPC.

[43]  Zheng Wang,et al.  Compilers for Parallel Computing (CPC’15) , 2015 .

[44]  Joseph D. Gradecki,et al.  Mastering AspectJ: Aspect-Oriented Programming in Java , 2003 .

[45]  Laurie J. Hendren,et al.  Optimizing Matlab through Just-In-Time Specialization , 2010, CC.