Getting Started

What's New ] Overview ] Registration ] Download ADIC ] [ Getting Started ] Troubleshooting ] FAQ ] Suggestions ] Discussion ] People ]

Table of Contents

Unpacking the distribution
Environmnent settings
Running ADIC
Writing a driver
Compiling and linking generated code

Unpacking the distribution

All archives are gzipped tar files. To install ADIC, simply unpack the archive in the desired location, for example,

% gunzip -c adic1.2.3-linux.tar.gz | tar xf -

This will create an 'adic' subdirectory of the current directory, containing all required binaries and include files for using ADIC.

Environment settings

Set the environment variable ADIC to the full path of the ADIC installation directory, and the ADIC_ARCH variable to the appropriate architecture among the following options:

For example, in csh/tcsh:

setenv ADIC $HOME/adic-1.2.3
setenv ADIC_ARCH linux

After setting the ADIC variable, add the path to the ADIC executable to your environment, for example, in csh

% set path=($ADIC/bin/$ADIC_ARCH $path)

A simple example program is available in the $ADIC/demo directory.

Running ADIC

To apply ADIC to a source file, invoke the adiC command (note the capitalized last letter).  If you get a "command not found" message, check whether the path has been updated correctly as described above. To see a summary of all command line option, invoke adiC with no arguments. Some commonly used command line options are '-d' followed by the module name and '-v' for verbose output. For example, the following command applies adiC to the file func.c using the gradient module to compute first order derivatives:

% adiC -vd gradient func.c

Optionally, a control script can be created instead of specifying the file name for the source to be differentiated. Please refer to the Users' Guide for more details on writing control scripts. An example of using adiC with the control script func.init follows.

% adiC -vd gradient -i func.init

Note that if the source file to which adiC is being applyied includes header files not on the default include path, the '-I' directive must be used, with the same syntax as that used in compiler invocation.

Writing a driver

In order to compute derivatives using ADIC-generated code, the user must write a driver routine, which sets up the independent variables, invokes derivative code, and extracts the derivative values. There are two options for creating a driver: writing one from scratch without using ADIC, or using ADIC with a slightly modified version of the original function that calls the routines which were differentiated. For more details on writing a driver, please refer to the Users' Guide.

Compiling and linking

To compile the ADIC-generated code, make sure the include path contains $ADIC/include. The user can also define the ad_GRAD_MAX macro in the code or at compile time, to specify the maximum number of independent variables (the default is 5).

All required libraries reside in ${ADIC}/lib/${ADIC_ARCH}. Depending on the module used, you would need to link libaif_grad.a (for the Gradient module) or libhessian.a (for the Hessian module). The intrinsics library, libADIntrinsics-C.a, should be linked as well.

In the following example, we compile and link to files, and driver.c. We set the maximum gradient size to 5 (which is also the default if omitted).

% gcc -I${ADIC}/include -Dad_GRAD_MAX=10 -c driver.c
% gcc -o program driver.o -L${ADIC}/lib/${ADIC_ARCH} -laif_grad -lADIntrinsics-C -lm