One way to address the continuing performance problem of high-level domain-specific languages, such as Octave or MATLAB, is to compile them to a relatively lower level language for which good compilers are available. As a first step in this direction, specializing the high-level operations in the source, based on operand types, leads to significant gains. However, simple translation of the high-level operations to the underlying libraries can often miss important opportunities to improve performance. This paper presents a global algorithm to select functions from a target library, utilizing the semantics of the operations as well as the platform-specific performance characteristics of the library. Making use of the library properties, the simple and easy-to-implement selection algorithm is able to achieve as much as three times performance improvement for certain linear algebra kernels, over a straight mapping of operations, which are compiled to the vendor-tuned BLAS.
MotivationThe ease of programming offered by High-level Domainspecific Languages, also called scripting languages, has resulted in their growing popularity in the recent years. Examples of such languages include MATLAB ® (and its open-source version, Octave), Perl, Python, S-Plus (and its open-source version, R), and PHP.One way to address the performance problem that continues to hinder large scale application development in these languages is to compile these languages to a relatively lower-level language for which there are known good compilers [7,11,3]. Usually, the first step in this translation process is inferring types of the variables from their definitions and uses so that the individual high-level operations in the original program * The work in this paper was supported in part by the National Science could be mapped to their more precise equivalent operations. For example, in a hypothetical high-level language, an operation such as "+" could refer to string concatenation or arithmetic addition, depending on the context. Static resolution of the operation, leading to type-based specialization, can result in impressive performance gains [3].However, these gains can be limited by the actual mapping of the high-level source operations to those available in the underlying target language. For some contexts the mapping is obvious-if the operands to a source operation are proved to be numerical scalar values there may be a simple equivalent scalar operation in the target language that can perform that operation. On the other hand, if the source operation has no equivalent primitive in the target language then the compiler must either explicitly generate code to implement the highlevel source operation or seek an appropriate library routine that implements that operation. For example, this is the case when an operation in Octave, or MATLAB ® , is found to involve arrays and the target language, such as C, does not support array operations primitively. This paper develops an algorithm to map the high-level operations in Octave to a give...