Prev Next

@(@\newcommand{\W}[1]{ \; #1 \; } \newcommand{\R}[1]{ {\rm #1} } \newcommand{\B}[1]{ {\bf #1} } \newcommand{\D}[2]{ \frac{\partial #1}{\partial #2} } \newcommand{\DD}[3]{ \frac{\partial^2 #1}{\partial #2 \partial #3} } \newcommand{\Dpow}[2]{ \frac{\partial^{#1}}{\partial {#2}^{#1}} } \newcommand{\dpow}[2]{ \frac{ {\rm d}^{#1}}{{\rm d}\, {#2}^{#1}} }@)@
Running the Speed Test Program

Syntax
speed/package/speed_package test seed option_list

Purpose
A version of this program runs the correctness tests or the speed tests for one AD package identified by package .

package

AD Package
The command line argument package specifies one of the AD package. The CppAD distribution comes with support for the following packages: adolc , cppad , fadbad , sacado . You can extend this program to include other package. Such an extension need not include all the tests. For example, link_sparse_hessian just returns false for the fadbad and sacado packages.

double
The value package can be double in which case the function values (instead of derivatives) are computed using double precision operations. This enables one to compare the speed of computing function values in double to the speed of the derivative computations. (It is often useful to divide the speed of the derivative computation by the speed of the function evaluation in double.)

profile
In the special case where package is profile, the CppAD package is compiled and run with profiling to aid in determining where it is spending most of its time.

test
It the argument test specifies which test to run and has the following possible values: correct , speed , det_minor , det_lu , mat_mul , ode , poly , sparse_hessian , sparse_jacobian . You can experiment with changing the implementation of a particular test for a particular package.

correct
If test is equal to correct, all of the correctness tests are run.

speed
If test is equal to speed, all of the speed tests are run.

seed
The command line argument seed is an unsigned integer (all its characters are between 0 and 9). The random number simulator uniform_01 is initialized with the call
     uniform_01(
seed)
before any of the testing routines (listed above) are called.

Global Options
This global variable has prototype

     extern std::map<std::string, bool> global_option;
The syntax
     global_option["
option"]
has the value true, if option is present, and false otherwise. This is true for each option that follows seed . The order of the options does not matter and the list can be empty. Each option, is be a separate command line argument to the main program. The documentation below specifics how speed_cppad uses these options, see the examples in speed_adolc for how another package might uses these options.

onetape
If this option is present, speed_cppad will use one taping of the operation sequence for all the repetitions of that speed test. Otherwise, the operation sequence will be retaped for each test repetition.

All of the tests, except det_lu , have the same operation sequence for each repetition. The operation sequence for det_lu may be different because it depends on the matrix for which the determinant is being calculated. For this reason, cppad_det_lu.cpp returns false, to indicate that the test not implemented, when global_onetape is true.

memory
This option is special because individual CppAD speed tests need not do anything different if this option is true or false. If the memory option is present, the CppAD hold_memory routine will be called by the speed test main program before any of the tests are executed This should make the CppAD thread_alloc allocator faster. If it is not present, CppAD will used standard memory allocation. Another package might use this option for a different memory allocation method.

optimize
If this option is present, CppAD will optimize the operation sequence before doing computations. If it is false, this optimization will not be done. Note that this option is usually slower unless it is combined with the onetape option.

atomic
If this option is present, CppAD will use a user defined atomic operation is used for the test. So far, CppAD has only implemented the mat_mul test as an atomic operation.

hes2jac
If this option is present, speed_cppad will compute hessians as the Jacobian of the gradient. This is accomplished using multiple levels of AD. So far, CppAD has only implemented the sparse_hessian test in this manner.

subgraph
If this option is present, speed_cppad will compute sparse Jacobians using subgraphs. The CppAD sparse_jacobian test is implemented for this option. In addition, the CppAD sparse_hessian test is implemented for this option when hes2jac is present.

Sparsity Options
The following options only apply to the sparse_jacobian and sparse_hessian tests. The other tests return false when any of these options are present.

boolsparsity
If this option is present, CppAD will use a vectors of bool to compute sparsity patterns. Otherwise CppAD will use vectors of sets .

revsparsity
If this option is present, CppAD will use reverse mode for to compute sparsity patterns. Otherwise CppAD will use forward mode.

subsparsity
If this option is present, CppAD will use subgraphs to compute sparsity patterns. If either the boolsparsity or revsparsity is also present, the CppAD speed tests will return false; i.e., these options are not supported by subgraph_sparsity .

colpack
If this option is present, CppAD will use colpack to do the coloring. Otherwise, it will use it's own coloring algorithm.

Correctness Results
One, but not both, of the following two output lines
     
package_test_optionlist_available = false
     
package_test_optionlist_ok = flag
is generated for each correctness test where package and test are as above, optionlist are the options (in option_list ) separated by the underbar _ character (whereas they are separated by spaces in option_list ), and flag is true or false.

Speed Results
For each speed test, corresponds to three lines of the following form are generated:
     
package_test_optionlist_ok   = flag
     
package_test_size = [ size_1...size_n ]
     
package_test_rate = [ rate_1...rate_n ]
The values package , test , optionlist , and flag are as in the correctness results above. The values size_1 , ..., size_n are the size arguments used for the corresponding tests. The values rate_1 , ..., rate_n are the number of times per second that the corresponding size problem executed.

n_sweep
The sparse_jacobian and sparse_hessian tests has an extra output line with the following form
     
package_sparse_test_n_sweep = [ n_sweep_1...n_sweep_n ]
were test is jacobian (hessian). The values n_sweep_1 , ..., n_sweep_n are the number of sweeps (colors) used for each sparse Jacobian (Hessian) calculation; see n_sweep for sparse_jacobian and sparse_hessian .

Link Functions
Each package defines it's own version of one of the link functions listed below. Each of these functions links this main program to the corresponding test:
link_det_lu Speed Testing Gradient of Determinant Using Lu Factorization
link_det_minor Speed Testing Gradient of Determinant by Minor Expansion
link_mat_mul Speed Testing Derivative of Matrix Multiply
link_ode Speed Testing the Jacobian of Ode Solution
link_poly Speed Testing Second Derivative of a Polynomial
link_sparse_hessian Speed Testing Sparse Hessian
link_sparse_jacobian Speed Testing Sparse Jacobian

Input File: speed/main.cpp