[CppAD] Preformance Issue during destruction of man ADFun objects
Brad Bell
bradbell at apl.washington.edu
Tue Jun 15 09:16:01 EDT 2010
In summary, when doing speed tests with CppAD, it is important to make
sure that the compiler flag NDEBUG is defined; see heading Speed at
http://www.coin-or.org/CppAD/Doc/faq.xml#Speed
On Tue, 15 Jun 2010, Dominik Skanda wrote:
> Yes I tried it out and it is much faster now!! Thank you very much for
> your help !!! Sure you can put this thread to the mailing list.
>
> regards
> Dominik
>
On Mon, 7 Jun 2010, Dominik Skanda wrote:
> Hello, the reason why I came to the conclusion that it is a problem with
> CppAD is that If I prevent the CppAD::ADFUN objects from being
> destructed I don't get any additional delay in the runtime. This is
> impossible to do with the smart pointer implementation because there the
> adfun objects get forced to be deleted. I had an implementation without
> a smartpointer list, but an ordinary pointer list to construct the adfun
> objects before. I putted the files in the assigned zip file (without
> atlas_enum.h but makefile is not modified.). If you look at the
> destructor in the File BDF_integrator.cpp at the lines 1536-1537 , 1619
> and 1550 this is the place where the CppAD::ADFun Objects gets deleted.
> By commenting them out the delay in the example vanishes.
>
> In the example I construct 3 BDF_integrator objects with the first
> having 586 ADFun objects after taping, the second has 1474 and the last
> 2732 Objects.
>
> The f.size_var() is 576 for each adfun object.
>
> Kind regards
>
> Dominik
>
I modified you example so that it could be built with or without deleting the
CppAD tape objects. Below are the results I obtained:
---------------------------------------------------------------------------
DELETE_CPPAD_TAPE = true
Running Time without destruction of integration objects in seconds: 4.75067
Running Time with destruction of integration objects: in seconds: 139.544
DELETE_CPPAD_TAPE = false
Running Time without destruction of integration objects in seconds: 6.72507
Running Time with destruction of integration objects: in seconds: 6.73154
----------------------------------------------------------------------------
This indicates that you are correct in your assessment above. Then I recalled
that CppAD uses its memory tracking allocator; see
http://www.coin-or.org/CppAD/Doc/tracknewdel.xml
and that this tracking can take a long time when a lot of different pieces of
memory are allocated. Note the discussion of NDEBUG in the documentation for
the tracking allocator.
I changed the compiler flags for you test case from
-g
to
-O2 -DNDEBUG
and got the following results:
---------------------------------------------------------------------------
DELETE_CPPAD_TAPE = false
Running Time without destruction of integration objects in seconds: 3.6148
Running Time with destruction of integration objects: in seconds: 3.61623
DELETE_CPPAD_TAPE = true
Running Time without destruction of integration objects in seconds: 4.4784
Running Time with destruction of integration objects: in seconds: 4.75017
----------------------------------------------------------------------------
More information about the CppAD
mailing list