-
Notifications
You must be signed in to change notification settings - Fork 33
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
Threadsafe traceless forward mode with 2nd order derivatives #62
Comments
Unfortunately I cannot attach a source file. So I'll link to the current version: |
I just noticed that nesting Since this is just a lucky coincidence, it there may be cases where this fails. I will also be less efficient, since one computes several derivatives multiple times. But it's probably worth to be investigated. |
Hi Carsten, that is indeed very interesting. Thanks a lot for the opportunity to discuss the integration into ADOL-C! There is actually a variant of the traceless mode that allows the calculation of higher order derivatives. So maybe these two approaches could be merged to some extend. Should we coordinate via email how to proceed? Best Andrea |
I also noticed
|
See #64 for a Dune-free implementation. |
We have bindings for AdolC in dune. Unfortunately the lack of thread-safety of the tape-based mode prohibits its use in thread-parallel assembly. On the other hand traceless forward mode with
adtl::adouble
has several drawbacks that cannot easily be fixed by patching it. As a remedy I implemented my own forward mode class. If there is interest, I'd happily propose it for inclusion in AdolC.Here's a rough sketch on the approach:
ADValue<T, maxOrder, dim>
for storing a AD-aware value.T
is the raw type (fixed to double inadtl::adouble
),maxOrder
is the order of computed derivatives,dim
is the domain dimension.maxOrder<=2
is supported (adtl::adouble
supports a single derivative only), but the interface is allows for later extension.dynamicDim
as template parameter (i.e.ADValue<T, maxOrder, dynamicDim>
), one can switch to a dynamic mode as used inadtl::adouble
. As far the latter this supports simple allocation (viastd::vector
) andboost::pool
to manage the storage.ADValue
is threadsafe, but it allows to do evaluations (with local variables) in concurrent threads without race conditions due to global variables.In
adtl::adouble
is roughly equivalent toADValue<double,1,dynamicDim>
.In my tests (with complicated nested function but small dimension), using a compile time dimension is about twice as fast as
adtl::adouble
withboost::pool
. In another test I used this to compute the 1st and 2nd order derivatives for a Newton step of a quasilinear PDE (minimal surface). Here the performance is exactly the same as if the derivatives are handwritten.Notice that the above obviously cannot be achieved by patching
adtl::adouble
. Hence adding this would mean to add a new templated class.The text was updated successfully, but these errors were encountered: