\(\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}} }\)
speed_xpackage¶
Speed Test Example and Template for a New Package¶
Purpose¶
CppAD has a set of speed tests that are used to compare AD packages. This section can be used as a starting point for linking a new package to he CppAD speed tests.
Files¶
Use the following command, in the
Distribution Directory ,
to see which files link the example package xpackage
to the speed tests:
git grep -l xpackage
Template¶
Suppose your_package is the name of a package you
want to add to the speed tests.
If you are using a Unix system,
executing the following commands in the distribution directory
will use xpackage as a template for your package:
cp -r speed/xpackage speed/ your_packagefor file in ` ls speed/ your_package `dosed -i speed/ your_package / $file \-e ‘ s/xpackage/ your_package /’ \-e ‘ s/Xpackage/ Your_package /’ \-e ‘ s/CPPAD_XPACKAGE_SPEED/ YOUR_PACKGE /’donegit checkout speed/CMakeLists.txtsed -i speed/CMakeLists.txt \-e ‘ s/^. * ( xpackage )/ ADD_SUBDIRECTORY ( your_package )\ n&/ ‘git checkout speed/main.cppline1 =’# ifdef CPPAD_ YOUR_PACKAGE _ SPEED ‘line2 =’# define AD_PACKAGE ” your_package “’line3 =’# endif ‘sed -i speed/main.cpp \-e “/ CPPAD_XPACKAGE_SPEED/s/^/$line1\n$line2\n$line3\n/ “where your_package has been replaced by the name of the new package Your_package is a capitalized version of the name, and YOUR_PACKAGE is an all caps version of the name.
Running Tests¶
Starting in the distribution directory, the following commands will build the new package version of the tests:
bin/run_cmake.sh --no_optionalcd build/speed/ your_packagemake check_speed_ your_package VERBOSE =1This should result in the following output:
det_lu_available = falsedet_minor_available = falsemat_mul_available = falseode_available = falsepoly_available = falsesparse_hessian_available = falsesparse_jacobian_available = falseAll 0 correctness tests passed.No memory leak detectedspeed main: OKBuilt target check_speed_ your_packageYou can not edit one or more of the * . cpp files in the
your_package directory so that the corresponding speed test
is available and then run the corresponding test using the
speed_main instructions.
See speed_cppad for examples of how to do this for each
of the speed tests.