You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Introduce the ADValue class for templated traceless forward mode
This was initially developed within the Dune module
dune-fufem (https://gitlab.dune-project.org/fufem/dune-fufem).
The class `adolc::ADValue<T, maxOrder,dim>` implementes a traceless
forward mode templated with respect to the underlying type `T`,
the maximal tracked derivative order `maxOrder` and the domain
dimension `dim`. Currently only `maxOrder<=2` is implemented.
Using the special value `dynamicDim` allows to use a runtime dimension.
In the latter case the default is to use `std::vector` as storage.
If support for `boost::pool` is activated, this is used instead.
Notable differences to `adtl::adouble` are:
* Being able to use other types that `T=double` e.g. allows for
low/high precision or interval arithmetics.
* Support for second order derivatives. The interface is also
flexible for later implementation of higher order.
* Fixing the dimension at compile time allows the compiler to
do better optimization and generate faster code. Furthermore
this guarantees thread-safety (x) by construction and allows
to use different dimensions at the same time within a single
program.
* In the dynamic dimension case, the dimension is set per variable,
which allows to have different dimensions at the same time. This
is implemented by using one `boost:pool`s per dimension instead
of a single one for a globally fixed dimension. This also avoids
the memory leaks of `adtl::adouble` when changing the global
dimension. Since the pools are `thread_local` instead of global,
this again provides thread-safety (X).
The last point could probably also be implemented for `adtl::adouble`.
(x) "Thread-safety" hear does _not_ mean that concurrent access
to a single `ADValue` object is safe. Instead if means that concurrent
accesss to different objects in different threads is safe and not
prone to race-conditions due to internally used global variables.
0 commit comments