COMPILER TECHNIQUES FOR MATLAB PROGRAMS ... - CiteSeerX
COMPILER TECHNIQUES FOR MATLAB PROGRAMS ... - CiteSeerX
COMPILER TECHNIQUES FOR MATLAB PROGRAMS ... - CiteSeerX
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
A structural inference mechanism was designed to improve code performance by enhancing<br />
library selection by the code generator.<br />
Suppose for example, that in a matrix<br />
multiplication, both variables are known to be matrices, but one of them can be inferred<br />
to be a triangular matrix. In this case, instead of using a library function to perform a<br />
general matrix multiplication operation, an optimized function that takes into consideration<br />
the triangular structure of the variable could be used. This structural inference mechanism<br />
has not been implemented in the current version of the compiler.<br />
Sources of Information for the Static Inference<br />
The static inference mechanism extracts information from four main sources: input les<br />
program constants operators and functions. If the program reads data from an external<br />
le, the system requires a sample le to be present during the compilation.<br />
From this<br />
le, the compiler extracts the initial intrinsic type and rank 2 of the variables being loaded 3 .<br />
Variable shapes are not extracted from the input les because they are much more likely than<br />
intrinsic type and rank to dier between runs. However, with the rank information from the<br />
loaded variables, the compiler can propagate partial (or even complete) shape information<br />
represented in terms of values obtained when vectors (and scalars) are loaded.<br />
The second source of information is program constants, from which intrinsic type, rank,<br />
and shape can be inferred and propagated.<br />
<strong>MATLAB</strong> operators are the third source of<br />
information. From them, we can extract type information in the case of logical operators,<br />
and rank, shape, and structural information by taking into consideration the conformability<br />
requirements imposed by the<strong>MATLAB</strong> operators.<br />
Finally, the fourth source of information is the high-level summary information from the<br />
<strong>MATLAB</strong> intrinsic functions. Built-in functions can provide information for both forward<br />
and backward inference.<br />
An example of this is the function rcond, for the conditional<br />
2 The use of this initial rank information can be turned o by a compiler ag. In this case, all loaded<br />
variables are assumed to be two-dimensional allocatable arrays.<br />
3 For clarity of presentation, a <strong>MATLAB</strong> comment (%) is used to indicate which variables are being loaded<br />
in the pseudo-code examples using the load function. This comment is not required by the compiler.<br />
23