Skip to content

Commit

Permalink
Introduce the ADValue class for templated traceless forward mode
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cgraeser committed Nov 15, 2024
1 parent 15e49d7 commit dab51e4
Show file tree
Hide file tree
Showing 2 changed files with 1,104 additions and 0 deletions.
1 change: 1 addition & 0 deletions ADOL-C/include/adolc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ install(FILES
adtl_indo.h
adutilsc.h
adutils.h
advalue.h
advector.h
checkpointing.h
convolut.h
Expand Down
Loading

0 comments on commit dab51e4

Please sign in to comment.