Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[draft] Introduce the ADValue class for templated traceless forward mode #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 1, 2024

  1. 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.
    cgraeser committed Nov 1, 2024
    Configuration menu
    Copy the full SHA
    263ff71 View commit details
    Browse the repository at this point in the history