Computing Array Shapes in MATLAB
- 326 Downloads
This paper deals with the problem of statically inferring the shape of an array in languages such as MATLAB. Inferring an array’s shape is desirable because it empowers better compilation and interpretation; specifically, knowing an array’s shape could permit reductions in the number of run-time array conformability checks, enable memory preallocation optimizations, and facilitate the in-lining of “scalarized” code. This paper describes how the shape of a MATLAB expression can be determined statically, based on a methodology of systematic matrix formulations. The approach capitalizes on the algebraic properties that underlie MATLAB’s shape semantics and exactly captures the shape that the MATLAB expression assumes at run time. Some of the highlights of the approach are its applicability to a large class of MATLAB functions and its uniformity. Our methods are compared with the previous shadow variable scheme, and we show how the algebraic view allows inferences not deduced by the traditional approach.
KeywordsCode Fragment Substitution Property Conformability Check Scalar Shape Matrix Arithmetic
Unable to display preview. Download preview PDF.
- P. Drakenberg, P. Jacobson, and B. Kågström. “A CONLAB Compiler for a Distributed-Memory Multicomputer”. In the Proceedings of the 6th SIAM Conference on Parallel Processing for Scientific Computing, pages 814–821, Norfolk, VA, USA, March 1993.Google Scholar
- L. A. De Rose. “Compiler Techniques for MATLAB Programs”. Ph.D. dissertation, University of Illinois at Urbana-Champaign, Department of Computer Science, May 1996.Google Scholar
- P. G. Joisha, U. N. Shenoy, and P. Banerjee. “An Approach to Array Shape Determination in MATLAB”. Technical Report CPDC-TR-2000-10-010, Center for Parallel and Distributed Computing, Department of Electrical and Computer Engineering, Northwestern University, Evanston, IL 60208-3118, USA, October 2000.Google Scholar
- The MAJIC Project, at http://polaris.cs.uiuc.edu/majic/majic.html.
- The Math Works, Inc., 24 Prime Park Way, Natick, MA 01760-1500, USA. MATLAB—The Language of Technical Computing, January 1997. Using MATLAB (Version 5).Google Scholar
- MATLAB Compiler and C/C++ Math Library 2.0.2, at http://www.mathworks.com/products/compilerlibrary/.
- V. Menon and K. Pingali. “A Case for Source-Level Transformations in MATLAB”. In the Proceedings of the 2nd Conference on Domain-Specific Languages, pages 53–65, Austin, TX, USA, October 1999.Google Scholar
- M. J. Quinn, A. Malishevsky, N. Seelam, and Y. Zhao. “Preliminary Results from a Parallel MATLAB Compiler”. In the Proceedings of the 12th International Parallel Processing Symposium, pages 81–87, Orlando, FL, USA, April 1998.Google Scholar