Add Initial Integration of Clad with Enzyme

What Interested me to apply for this Project?

Ever since as I was introduced to compiler design as a part of my university course work, I have been fascinated by this subject and was always eager to explore more about it. Naturally I came across the LLVM compiler Infrastructure and was interested in learning more about it. I found the Compiler-Research group while looking out for some exciting projects related to the Clang and LLVM. As soon as the GSoC Organizations were announced, I got in touch with the Group members hoping to contribute in their work. This project was suggested to me by my mentor Vassil, as its a nice fit for a beginners in the field of compiler design and implementation.

Here is my Project Proposal.

GSoC Community Bonding Period

As the Community Bonding period started, I got into fixing a few bugs in the Clad repository, just to get to know the codebase better. I was successful in fixing some, but was not successful in fixing a few others. Meanwhile I also presented my project proposal to the rest of the Compiler Research community(Slides) and got their feedback on how I intend to take the project forward. I started participating in the weekly meetings of the Community and learnt (and still learning) about the various projects that the community members are doing.

During my community bonding period, I also explored more about the core algorithms and concepts behind my project. The primary class of algorithms that concern my project is Automatic Differentiation(AD). AD algorithms are primarily used for finding derivatives of functions that are expressed as computer programs(code), and they are mainly of two types- forward mode and reverse mode. Often AD algorithms are implemented in 2 ways, either by source code transformation or by operator overloading. Both Enzyme and Clad use source code transformation along with compiler parsing technologies to correctly differentiate computer programs.

Coding Period 1

Once the coding period started, I got into implementing what vision I had for proceeding in the project. With help from my mentors and a few other community members I achieved my first milestone, that is summarised in the pull request “Detecting Request For Enzyme by Clad”. This first PR primarily sets the stage for the integration of clad with enzyme, by correctly detecting when a user wants to use Enzyme as a backend in clad.

Now the next step would be to actually use Enzyme to differentiate a function using the Clad API. My second Pull Request “Generate code for Enzyme autodiff for functions with Pointer/array arguments” deals with this, for a very specific function prototype. This PR not only generates Clad code that Enzyme can work on, but also integrates the Enzyme Source code and the build files into the clad workflow.