The automatic generation of an adjoint of a given Fortran code involves a sequence of transformations guided by various syntactic and semantic rules. We use the Fortran 90 front-end of the open-source Open64 compiler collection to transform a given code into Open64's abstract intermediate representation called 'WHIRL'. The language-independent numerical kernel [ Hovland2002AXB, Utke2004SLD ] is extracted in the form of XAIF code that is syntactically defined by an XML schema. XAIF separates the numerical from the programming-language-specific features of the given code.
The semantic transformations that define the transition from the original code to its adjoint are performed by the software tool xaifBooster. It builds a C++ object image of the XAIF code and provides a convenient interface for programmers of AD algorithms [ Utke2003STI, Utke2004OAI, Naumann2004AIt ]. The tangent-linear and adjoint codes that are generated by xaifBooster use preaccumulation of local Jacobians [ Naumann2003CTL, Utke2005FBB ] followed by the propagation of directional derivatives or adjoints. The Jacobian accumulation code is based on a representation of relevant sections of the code (statements, basic blocks) as a directed acyclic computational graph with expressions for computing local partial derivatives attached to its edges. Vertex, edge, and face elimination techniques are applied to obtain an efficient derivative code. Moreover, linearities are eliminated at compile time [ Naumann2005OPE ]. The flow of control is reversed explicitly in the adjoint code [ Naumann2004CFR ]. Various reversal modes can be used at the call graph level allowing for the implementation of different checkpointing schemes as trade offs between storing vs. recomputing values required by the adjoint code.
The quality of the adjoint code generated by xaifBooster depends on semantic analyses of the code that can be performed at compile time. AD-specific static data-flow analyses [ Hascoet2005TAi ] are implemented in a programming-language-independent manner in the OpenAnalysis tool.
The semantically transformed XAIF code is translated back into WHIRL [ Fagan2003DaI ]. The unparser of Open64 is used in conjunction with various support tools to write out the final adjoint code in Fortran 90.
The tools and the vocabulary used in this extremely brief description are explained in the "Technical Details" section (see left frame). Further references to related publications on AD issues can be found in the OpenAD Bibliography. Feel free to contact us to learn more about the general approach as well as the algorithmic details and interesting open theoretical problems in the field.