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)] .

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 requires 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, trying to prove correctness of our current address conversion, we discovered some limitations that indeed made the proof impossible. To solve these issues, it seems necessary to assign at run-time a unique identifier to each chunk of memory used by the code, and to carry this identifier along with every pointer. This results in a code transformation which, although more complex than expected, can still be described by a small set of rewrite rules. Moreover, this alternative method should reduce the run-time overhead that we observed previously. Implementation and measurements are still under way. We presented this recent research in the form of a catalogue of alternatives for Data-Flow reversal of memory addresses, at the 21st EuroAD workshop (Jena, Germany, November 19-20).