[CppAD] cppad creating a very large tape

Brad Bell bradbell at seanet.com
Sat Aug 8 09:06:34 EDT 2009


There is now a hash check to see if a CppAD parameter already exists. 
This reduces the number of copies of the same parameter in the tape. In 
addition, there is a function that reports how many parameters are in an 
AD function's tape; see f.size_par() in
    http://www.coin-or.org/CppAD/Doc/seqproperty.xml

For the ordinary differential equation speed test
    http://www.coin-or.org/CppAD/Doc/cppad_ode.cpp.xml
the number of parameters before the hash table check was
    841
and with the hash table check it is
    35

Before the hash table check, the CppAD ode speed test results on a 
cygwin system were
    $ ./cppad ode 123 true
    cppad_ode_ok =  true
    cppad_ode_size = [ 1, 3, 5, 7, 9 ]
    cppad_ode_rate = [ 1285, 580, 381, 280, 224 ]
With the hash table check, the ode speed test results are
    $ ./cppad ode 123 true
    cppad_ode_ok =  true
    cppad_ode_size = [ 1, 3, 5, 7, 9 ]
    cppad_ode_rate = [ 1310, 591, 381, 283, 228 ]
Where rate is the number of times per second that the test completed.

Thus, the parameter hash table check appears to reduce the amount of 
memory with out adversely affecting the speed.


Brad Bell wrote:
> 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
>>
>>   
>>     
>
> _______________________________________________
> CppAD mailing list
> CppAD at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cppad
>
>   



More information about the CppAD mailing list