[CppAD] cppad creating a very large tape

Brad Bell bradbell at seanet.com
Thu Jun 11 08:17:53 EDT 2009


In order to make the recording fast, CppAD is not yet very smart about 
reusing parameter values. It tends to make multiple copies of parameters 
instead of reusing them. See the routine:
    template <class Base>
    inline size_t recorder<Base>::PutPar(const Base &par)
in the file
    
https://projects.coin-or.org/CppAD/browser/trunk/cppad/local/recorder.hpp
This converts a parameter value to an index in a table of parameters 
(and adds the parameter to the table if necessary).


It is possible that one could do some hash coding of parameter values to 
keep the size of this table smaller. Perhaps you would like to try this. 
I would be interested in the results. On the other hand, CppAD adds at 
most one parameter per operation. Since there is usually at least one 
variable per operation that is recorded, I am not sure what percentage 
of the entire memory would be saved. The total number of variables is 
currently called TotalNumberVar_ in the file
        
https://projects.coin-or.org/CppAD/browser/trunk/cppad/local/recorder.hpp




Piers Dunstan wrote:
> Hi,
>     I'm using CPPAD to obtain derivatives of a likelihood function  used 
> to optimise the function.  The likelihood function is complex and has 
> many operations. I have the code working properly and the derivatives 
> are correct. However, when I try to use the code for large data problems 
> the tape size grows very large (ie 20GB) which tends to cause problems 
> on most machines.
>
> I'm fairly certain that the problem occurs during tape creation since it 
> occurs between calls to  Independent and Dependent. I'm also sure its 
> not a memory leak.
>
> Much of the data I'm using is constant and used repeatedly (ie  I have a 
> double matrix with dimensions 1100 x 20 that is used 6000 times).  I 
> think the problem comes from the number of operations I have to preform 
> on this matrix. It is multiplied by an AD variable. I think the tape is 
> making multiple copies of the elements in this matrix.
>
> Is there a way to designate that the matrix is constant and all 
> operations occur on only 1 copy (if this is the problem?)
>
> Any ideas gratefully accepted.
>
> Thanks  piers
>
>   



More information about the CppAD mailing list