EN FR
EN FR


Section: New Results

AD-adjoints and C dynamic memory management

Participants : Laurent Hascoët, Sri Hari Krishna Narayanan [Argonne National Lab. (Illinois, USA)] , Mathieu Morlighem [University of California at Irvine (USA)] .

One of the current frontiers of AD research is the definition of an adjoint AD model that can cope with dynamic memory management. This research is central to provide reliable adjoint differentiation of C, and for our distant goal of AD of C++. This research is conducted in collaboration with the MCS department of Argonne National Lab. Our partnership is formalized by joint participation in the Inria joint lab JLESC, and partly funded by the Partner University Fund (PUF) of the French embassy in the USA.

Adjoint AD must reproduce in reverse order the control decisions of the original code. In languages such as C, allocation of dynamic memory and pointer management form a significant part of these control decisions. Reproducing memory allocation in reverse means reallocating memory, possibly receiving a different memory chunk. Reproducing pointer addresses in reverse thus require to convert addresses in the former memory chunks into equivalent addresses in the new reallocated chunks. Together with Krishna Narayanan from Argonne, we experiment on real applications to find the most efficient solution to this address conversion problem. We jointly develop a library (called ADMM, ADjoint Memory Management) whose primitives are used in AD adjoint code to handle this address conversion. Both our AD tool Tapenade and Argonne's tool OpenAD use ADMM in the adjoint code they produce.

This year, the ADMM library has been improved, and its API has been redesigned to be called from both C and Fortran. The architecture of ADMM has also been simplified, removing circular dependencies with other parts of Tapenade. The latest release 3.13 of Tapenade automatically places calls to ADMM where needed, whether the application language is C or Fortran 95. Since ADMM is a C library, the differentiated code in the Fortran case uses the Fortran 2003 standardized interoperability primitives.

In parallel, we improved the Tapenade adjoint of the “ALIF” code. ALIF is developed by Mathieu Morlighem from UC Irvine, jointly with Eric Larour from JPL. This glaciology code is a C clone of the C++ “ISSM” code from JPL. One challenge is the intensive use of dynamic memory in ALIF, following the programming style of its model C++ code ISSM. Although sucessful, the usage of the ADMM library incurred some overhead. We developed a static data-flow analysis to reduce the number of calls to ADMM. This work is discussed in an article published in journal “Optimization Methods and Software”[14]