This repository shares the benchmarks and the AD implementations presented in this article
Along with the reverse.h and forward.h headers, two examples and one
benchmark are provided.
examples/hello_worldis a program that differentiates the function(a, b, c, d) -> (sqrt(a / (b + c*a) + exp(1/d)))^dexamples/polynomial_approximationis an example of an application to automatic differentiation that I used as benchmarking task to test the performances ofreverse.handforward.h. It's a program that performs a gradient descent on polynomial coefficients in order to find a polynomial that approximates the functiont -> exp(1/t^2)
To build either of those two examples, make sure that you have clang and
make installed and run the command make into the corresponding example
directory.
benchmarks/polynomial_approximation contains multiple .cpp files that measure
the runtime of 1 iteration of the gradient descent algorithm described earlier.
Alongside those .cpp files are some bash scripts that gather those measurements
as functions of some parameter.
benchmark.shcompares the different AD implementations relative to gradient size.benchmark_gradlen.shcompares the runtime of chunked forward AD with different values for the parametter α.benchmark_workers.shcompares the runtime of parallelized chunked forward AD with different workers count.benchmark_parallel.shandbenchmark_reverse.share quick measruements of the performances of parallelized chunked forward AD and reverse AD to avoid having to runbenchmark.shwhich is slow.
If you happen to interrupt one of those benchmarks, you will be left with a
series of executables that would have been deleted at the end of the benchmark.
To get rid of those run make clean.