AspectMatlab | McIR and analysis and transformation engine | mcVM and McJIT | Matlab to Fortran | Domain-Specific Scientific Languages

Example Aspects and Base Programs

In general, we consider two possible use cases: (1) profiling programs, and (2) annotating data to variables in a running program to extend functionality. Profiling programs is particulary interesting for scientific programs, which are usually computationaly intensive. Having knowledge about what exactly is going on during execution can help increase efficiency. Some information is hard to get by "traditional" means, i.e. by extending the program to include profiling code. Adding an aspect represents a much cleaner solution, with the additional advantage that they allow to profile different programs without much modification. With regards to annotating functionality, aspects are a quick way to prototype further possible language extensions without much work.

Tracking Array Size-Growing Operations

MATLAB semantics force the array to be handled in a different way as compared to other objects. Each time the array size increases, MATLAB has to allocate new space to the array. We present a simple example aspect, that is used to track the growing size of the arrays. The purpose of this application is to monitor all the operations which may potentially alter the shape or the size of an array, and in the end we should be able to point to the operations in the source program at which the arrays attain the biggest size. (Example)

Tracking Array Sparsity

The sparsity benchmark is an aspect which helps to profile how sparse matrices are. The sparsity of a matrix is the number of zero elements compared to the number of non-zero elements. If a matrix is sufficiently sparse, it can be stored as a sparse matrix, which is a special data type supported by Matlab. It stores only the non-zero elements and their location. All arithmetic is supported both on sparse data types and between a mixture of sparse and dense matrices. (Example)

Measuring Floating Point Operations

In numerical computing it is common to count computational complexity in terms of floating point operations, because they tend to make up most of the operations and were traditionally more expensive than other operations. Knowing exactly how many floating point operations each part of a program performs can be more useful than knowing how time the computations take, because the number of flops may be more consistent, and is not subject to compiler optimizations. (Example)

Adding Units to Computations

The units aspect adds the functionality by allowing matrices to have SI units associated with them, while not requiring any special treatment of these variables. The aspect turns all variables that are encountered at calls into structures containing both a unit and the original value. All basic operations are overriden as well. In order to create a matrix with an associated unit, one merely has to multiply the matrix with the name of the unit. (Example)

Interpreting Loop Iteration Space

This aspect extracts the for loop iteration space and then interprets this space within the loop body. It can be useful in many applications, for example, for iterative solvers that get called a lot to see how many iterations are performed, or for loop dependency analyses where we need to know the lower bound, upper bound and the increment factor for the for loops. This benchmark can also be used to track how long loops run throughout the program. (Example)
Projects Publications Software People FAQs