Next Previous Contents

8. Usage

8.1 Modes and Toolchains

ADiMat defines several different modes of source code transformation, which are called toolchains. The most prominent are the transformation in forward mode and reverse mode of AD, but there are others. All can be accessed from within Matlab via the admTransform command, from the command line via the adimat-client program or via the web interface.

When you use the admTransform function, give it the name of handle of your function and an admOptions structure. In this structure the fields mode and toolchain allow you to choose the toolchain. The four AD transformations are set via the field mode:

The other toolchains are selected by specifying their name, as it is given in the list of toolchains (cf. List of toolchains). The toolchain name also appears on the web interface.

When using adimat-client, the four AD modes are selected by the short flags -F, -f, -r, and -t, with the same meaning as in the list above. The classic forward mode AD is the default, so the -F flag may be omitted. The other toolchains are selected by giving the name to the option -T.

On the web interface of the ADiMat transformation server you can choose the toolchain in the select field which is in the fieldset labeled "Select transformation". Selecting a toolchain will show a corresponding fieldset. These will automatically show fields for the mandatory parameters. Other parameters can be added by clicking on the button "Add a parameter".

8.2 List of toolchains

This is a provisional list of the most important parameters. For more information please refer to the web server interface.

classic-forward-ad

This is used by admDiffFor.
Parameters:

gradprefix=<PREFIX>

This prefix is added to each active variable. The prefix is used for variables, when ADiMat is in forward mode (<PREFIX>='g_').

hessprefix=<PREFIX>

If the 2ndorderfwd ( 2ndorderfwd) flag is set, then this prefix is used to preceed the variables that store Hessians (<PREFIX>='h_').

funcprefix=<PREFIX>

The prefix is added to each function that is augemented in forward mode. There is no distinction between functions that are differentiated once or twice. (<PREFIX>='g_')

forward-ad

This is used by admDiffVFor.

Parameters:

prefix=<d_>

This prefix is added to each active variable. The prefix is used for variables and functions.

forward-deriv-variable-prefix=<PREFIX>

The prefix used for differentiated variables (default: <PREFIX>=$prefix).

forward-deriv-function-prefix=<PREFIX>

The prefix used for differentiated functions (default: <PREFIX>=$prefix).

use-subsref=<1|0>

Set to one to wrap index operations on RHS in calls to the adimat_opdiff_subsref function (default: 0). Try to turn this on when you get errors regarding dimension mismatches or wrong sizes. However, code with this option on is much slower. See How can I avoid having to use subsref and subsasgn.

use-subsasgn=<1|0>

Set to one to wrap assignments to index expressions in calls to the adimat_opdiff_subsasgn function (default: 0). Try to turn this on when you get errors regarding dimension mismatches or wrong sizes. However, code with this option on is much slower. See How can I avoid having to use use-subsref and use-subsasgn.

reverse-ad

This is used by admDiffRev.

Parameters:

rev-prefix=<a_>

Set the prefix of adjoint functions and variables.

rec-prefix=<a_>

Set the prefix of recording (forward sweep) functions.

ret-prefix=<a_>

Set the prefix of returning (reverse sweep) functions.

brackets-to-hvcat

Translate instances of brackets [] to calls to the functions horzcat and/or vertcat.

hvcat-to-brackets

Rewrite calls of functions horzcat and/or vertcat with brackets [].

ind-to-subs

Translate index expression to calls to the functions subsref (RHSs) and subsasgn (LHSs).

for-insert-iteration-indexvar

Canonicalize for loops to the for i=first:last.

null

Returns the raw XML output of the parser in the adimat tool. Results of activity analysis for each variable and the function call graph are also included.

rename

Renames all identifiers given by parameter "from" to the value of parameter "to".

8.3 Transformation parameters

ADiMat uses several parameters that can be used to influence certain aspects of the source code transformation. The set of parameters is different for each transformation toolchain.

Transformation parameters are set using the sub struct parameters of the admOptions structure. This is contructed by the function admTransformParameters.

adopts = admOptions;
adopts.parameters.useSubsref = '1';

Transformation parameters can also be set on the command line of adimat-client, by passing a string of the form name=value to the option -s, for example like this:

adimat-client -f -o- -s use-subsref=1 f.m

Parameter names are slightly different in both cases: in the structure, the parameter names are written in camel-style, e.g. "useSubsref", or "printStackInfo". On the command-line, dashed style is used instead: "use-subsref", or "print-stack-info". Parameter name are translated automatically when the command-line is constructed by admTransform.

8.4 List of transformation parameters

This is a provisional list of the most important parameters. For more information please refer to the web server interface. For any toolchain you select on the web server, when you hit the button "Add a parameter", you will see only the parameters that are relevant for that toolchain.


Next Previous Contents