ROSE: a preprocessor generation tool for leveraging the semantics of parallel object-oriented frameworks to drive optimizations via source code transformations.

Dan Quinlan

ROSE is a programmable source-to-source transformation tool for the optimization of C++ object-oriented frameworks. In our work we target the OVERTURE Framework specifically (www.llnl.gov/casc/Overture), a parallel object-oriented C++ framework for solving partial differential equations associated with computational fluid dynamics applications within complex moving geometries. Work on the OVERTURE framework represents our research in the modeling of diesel engine combustion. While we have specific goals for this work within OVERTURE, ROSE applies equally well to any other object-oriented framework.

A common problem within object-oriented C++ scientific computing is that the high level semantics of abstractions introduced (e.g. parallel array objects) are ignored by the C++ compiler. Classes and overloaded operators are seen as unoptimizable structures and function calls. Such abstractions can provide for particularly simple development of large scale parallel scientific software, but the lack of optimization greatly effects performance and utility. Because C++ lacks a mechanism to interact with the compiler, elaborate mechanisms are often implemented within such parallel frameworks to introduce complex template-based and/or runtime optimizations (such as runtime dependence analysis, deferred evaluation, runtime code generation, etc.). These approaches are however not satisfactory since they either require long compile times (hours) or are not sufficiently robust.

ROSE represents a mechanism to build preprocessors that read the user's application source code and output highly optimized C++ code. The output from a preprocessor build from ROSE is itself C++ code (but transformed using the semantics of the object-oriented abstractions represented within the framework). ROSE helps the framework developer define framework specific (or application specific) grammars (more specifically a hierarchy of grammars), a transformation can be associated with each grammar. The transformations assume complete knowledge of the serial and parallel semantics of the object-oriented abstractions and are thus safe by definition. Multiple program trees are then built, one for each grammar. The traversal of the much simpler program trees represented by the higher level grammars (as opposed to that of the C++ program tree) permits the identification of locations where transformations are then applied to introduce specific optimizations. The final modified program tree is then unparsed to generate C++ source code. The source code transformations can readily exploit knowledge of the architecture, parallel communication characteristics, and cache architecture in the specification of the transformations. Within OVERTURE, a parallel framework, the serial and parallel semantics are known known and transformations can range from serial loop optimizations to parallel message passing optimizations, threading could alternatively be automated with such transformations (where identified using the framework's parallel semantics).

We have developed this work as an optional alternative (optional since the framework's semantics are in no way modified through the use of the preprocessors built with ROSE) to the definition of standardized parallel languages which are both harder to develop and more difficult to optimize and get accepted into scientific computing.

ROSE is designed using several other tools. We use the EDG C++ front-end and the SAGE source code restructuring tool. ROSE exists as a layer on top of SAGE (which represents an open interface to the C++ program tree provided though the EDG front-end), while SAGE exists as a layer on top of EDG. EDG is a commercial C++ front-end, providing us with an implementation of the full C++ language (as complete as is available today). By design, we leverage many low level optimizations provided within modern compiler while focusing on higher level optimizations largely out of reach because traditional approaches can not leverage the semantics of high level abstractions. In doing so we slightly blur the distinction between a library/framework and a language. Because we leverage several good quality tools the implementation is greatly simplified.

The approach is different from other open C++ compiler approaches because it provides a mechanism for defining high level grammars specific to an object-oriented framework and a relatively simple approach to the specification of large and complex serial and parallel transformations. Additionally, and unlike in a few other tools we know of, the complete program tree (represented in each grammar) is made available; this permits more sophisticated program analysis (when combined with the greater semantic knowledge of object-oriented abstractions) and more complex transformations. ROSE is a project with several parts still in development, if accepted for presentation we will present our most current research results, approach and technical problems for discussion.