Skip to content

Commit 65eb5d2

Browse files
vaithakvgvassilev
authored andcommitted
Add new open project for consteval support in clad
1 parent c87e7a2 commit 65eb5d2

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

_data/openprojectlist.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,61 @@
838838
* Solve any general-purpose issues that come up with Clad during the process.
839839
* Prepare demos and carry out development needed for lossy compression.
840840
841+
- name: "Add support for consteval and constexpr functions in clad"
842+
description: |
843+
In mathematics and computer algebra, automatic differentiation (AD) is
844+
a set of techniques to numerically evaluate the derivative of a function
845+
specified by a computer program. Automatic differentiation is an alternative
846+
technique to Symbolic differentiation and Numerical differentiation (the
847+
method of finite differences). Clad is based on Clang which provides the
848+
necessary facilities for code transformation. The AD library can differentiate
849+
non-trivial functions, to find a partial derivative for trivial cases and has
850+
good unit test coverage.
851+
852+
C++ provides the specifiers consteval and constexpr to allow compile time evaluation
853+
of functions. `constexpr` declares a possibility, i.e the function will be
854+
evaluated at compile time if possible, else at runtime; whereas `consteval` makes it
855+
mandatory, i.e every call to the function must produce a compile-time constant.
856+
857+
The aim of this project is to ensure that same semantics are followed by the generated
858+
derivative function, i.e if the primal function is evaluated at compile time
859+
(because of constexpr or consteval specifier), then the generated derivative code
860+
should also have the same specifier to be evaluatable at compile time.
861+
862+
This will enable clad to demonstrate the benefits of doing automatic differentiation
863+
directly on C++ frontend to utilize the benefits of clang's infrastructure.
864+
865+
After successful completion of the project the code snippet should work
866+
as expected:
867+
```cpp
868+
#include <cstdio>
869+
#include "clad/Differentiator/Differentiator.h"
870+
871+
constexpr double sq(double x) { return x*x; }
872+
873+
consteval double fn(double x, double y, double z) {
874+
double res = sq(x) + sq(y) + sq(z);
875+
return res;
876+
}
877+
878+
int main() {
879+
auto d_fn = clad::gradient(fn);
880+
double dx = 0, dy = 0, dz = 0;
881+
d_fn.execute(3, 4, 5, &dx, &dy, &dz);
882+
printf("Gradient vector: [%.2f, %.2f, %.2f]", dx, dy, dz);
883+
return 0;
884+
}
885+
```
886+
tasks: |
887+
The project consists of the following tasks:
888+
* Add support for differentiation with respect to consteval and constexpr
889+
functions in the forward mode.
890+
* Add support for differentiation with respect to consteval and constexpr
891+
functions in the reverse mode.
892+
* Extend the unit test coverage.
893+
* Develop tutorials and documentation.
894+
* Present the work at the relevant meetings and conferences.
895+
841896
- name: "Improve robustness of dictionary to module lookups in ROOT"
842897
description: |
843898
The LHC smashes groups of protons together at close to the speed of light:

0 commit comments

Comments
 (0)