This is a beta release of AD DSL tool. Expect breaking changes, bugs, and errors.
For questions please contact max.sagebaum@rptu.de
AD DSL tool is a header only library. There is one source file which defines some global values. You also need CoDiPack since a few headers are used from there.
For the generation of the expression templates AD DSL generator is required. Running the tests also requires Eigen and numdiff. You cann run the bootstrap.sh <compilation jobs> script to setup everything. The script will create a folder subprojects, download, and install everything. It also creates a cmake_args file with the proper arguments.
cmake expects LLVM and clang cmake files in CMAKE_PREFIX_PATH. The command looks like:
mkdir build
cd build
CC=clang CXX=clang++ cmake .. \
-Dnumdiff_DIR=<path to bin dir> \
-DGenerator_DIR=<path to bin dir> \
-DEigen_DIR=<path to cmake dir> \
-DCoDiPack_DIR=<path to cmake dir>
#include <adTool.hpp>
#include <adTool_floating_point.hpp>
#include <adTool_complex.hpp>
#include <iostream>
using Real = adTool::ActiveValue<double, int>;
using Complex = std::complex<Real>; // Automatically uses the AD tool specialization.
int main() {
adTool::PrimalValueTape& tape = adTool::getPrimalValueTape();
tape.registerValueKind<double>();
tape.registerValueKind<std::complex<double>>();
tape.setActive();
Real a = 4.0;
tape.registerInput(a);
Real w = a * a;
Complex c = {a, w};
Real n = norm(c);
tape.registerOutput(n);
tape.setPassive();
w.setGradient(1.0);
tape.evaluate();
std::cout << "dw/da = " << a.getGradient() << std::endl;
return 0;
}
// Definition of the global tape.
#include "src/ad_tool.cpp"