Changeset 339
 Timestamp:
 Aug 15, 2012 11:43:21 PM (8 years ago)
 Location:
 trunk/ADOLC/doc
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

trunk/ADOLC/doc/adolcmanual.tex
r320 r339 2594 2594 %++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2595 2595 % 2596 \section{Advance algorithmic differentiation in ADOLC}2596 \section{Advanced algorithmic differentiation in ADOLC} 2597 2597 \label{adv_ad} 2598 2598 % 2599 \subsection{External differentiated functions} 2600 % 2601 Ideally, AD is applied to a given function as a whole. 2599 \subsection{Differentiating external functions} 2600 % 2601 Ideally, AD is applied to a given computation as a whole. 2602 This is not always possible because parts of the computation may 2603 be coded in a different programming language or may a call to 2604 an external library. 2605 In the former case one may want to differentiate the parts in 2606 question with a different AD tool or provide hand written derivatives. 2607 To integrate these 2602 2608 In practice, however, sophisticated projects usually evolve over a long period of time. 2603 2609 Within this process, a heterogeneous code base for the project … … 2607 2613 Hence, different \mbox{ADtools} may be combined with handderived 2608 2614 codes based on the same or different programming languages. 2609 ADOLC support such settings by the concept of external2610 differentiated functions . Hence, a external differentiatedfunction2611 itself is not differentiated by ADOLC. The required derivative 2612 informationhave to be provided by the user.2613 2614 For this purpose, it is assumed that the externaldifferentiated2615 function has the signature2615 ADOLC supports such settings by the concept of externally 2616 differentiated functions, that is, a function 2617 not differentiated by ADOLC itself. The required derivatives 2618 have to be provided by the user. 2619 2620 For this purpose, it is required that the externally differentiated 2621 function (for example named {\sf\em euler\_step} ) has the following signature. 2616 2622 \smallskip 2617 2623 2618 2624 \noindent 2619 \hspace*{2cm}{\sf int e xt\_func(int n, double *yin, int m, double *yout);}2625 \hspace*{2cm}{\sf int euler\_step(int n, double *x, int m, double *y);} 2620 2626 \medskip 2621 2627 2622 2628 \noindent 2623 where the function names can be chosen by the user as long as the names are 2624 unique. This {\sf double} version of the external differentiated function has to 2625 be {\em registered} using the \mbox{ADOLC} function 2629 Note that the formal paraemters in the signature have {\sf double} type, that is, 2630 they are not active as in the original program before the ADOLC type change. 2631 The externally differentiated function has to 2632 be {\em registered}\footnote{we record the function pointer} using an \mbox{ADOLC} method as follows. 2626 2633 \smallskip 2627 2634 2628 2635 \noindent 2629 \hspace*{2cm}{\sf e df = reg\_ext\_fct(ext\_func);}.2636 \hspace*{2cm}{\sf ext\_diff\_fct *edf = reg\_ext\_fct(euler\_step);}. 2630 2637 \smallskip 2631 2638 2632 2639 \noindent 2633 This function initializes the structure {\sf edf}. Then, 2634 the user has to provide the remaining information 2635 by the following commands: 2636 \begin{tabbing} 2637 \hspace*{2cm}\= {\sf edf$>$zos\_forward = zos\_for\_ext\_func;}\\ 2640 This returns a pointer to an {\sf ext\_diff\_fct} instance specific to the registered function. 2641 Then, the user has to supply the function pointers for the call back methods (for example here 2642 {\sf zos\_for\_euler\_step} and {\sf fos\_rev\_euler\_step}) the user implemented 2643 to compute the derivatives as follows. 2644 \begin{tabbing} 2645 \hspace*{2cm}\= {\sf edf$>$zos\_forward = {\em zos\_for\_euler\_step};}\\ 2638 2646 \> {\sf // function pointer for computing 2639 2647 ZeroOrderScalar (=zos)}\\ 2640 2648 \> {\sf // forward information}\\ 2641 \> {\sf edf$>$dp\_x = xp;}\\2642 \> {\sf edf$>$dp\_y = yp;}\\2643 \> {\sf // double arrays for arguments and results}\\2644 \> {\sf edf$>$fos\_reverse = fos\_rev\_e xt\_func;} \\2649 % \> {\sf edf$>$dp\_x = xp;}\\ 2650 % \> {\sf edf$>$dp\_y = yp;}\\ 2651 % \> {\sf // double arrays for arguments and results}\\ 2652 \> {\sf edf$>$fos\_reverse = fos\_rev\_euler\_step;} \\ 2645 2653 \> {\sf // function pointer for computing 2646 2654 FirstOrderScalar (=fos)}\\ 2647 2655 \> {\sf reverse information} 2648 2656 \end{tabbing} 2649 Subsequently, the call to the external differentiated function in the function evaluation can be 2650 substituted by the call of 2657 To facilitate the switch between active and passive versions of the parameters {\sf x} and {\sf y} 2658 one has to provide (allocate) both variants. I.e. if the call to {\sf euler\_step} was originally 2659 \noindent 2660 \hspace*{2cm}{\sf rc=euler\_step(n, sOld, m, sNew);} 2651 2661 \medskip 2662 then the ADOLC typechange for the calling context will turn {\sf sOld} and {\sf sNew} in {\sf adouble} pointers. 2663 To trigger the appropriate action for the derivative computation (i.e. creating an external differentiation entry on the trace) 2664 the original call to the externally differentiated function 2665 must be substituted by 2666 \medskip 2652 2667 2653 2668 \noindent 2654 \hspace*{2cm}{\sf int call\_ext\_fct(edf, n, xp, x, m, yp, y);}2669 \hspace*{2cm}{\sf rc=call\_ext\_fct(edf, n, sOldPassive, sOld, m, sNewPassive, sNew);} 2655 2670 \medskip 2656 2671 2657 2672 \noindent 2673 Here, {\sf sOldPassive} and {\sf sNewPassive} are the passive counterparts ({\sf double} pointers allocated to length {\sf n} and {\sf m}, respectively) 2674 to the active arguments {\sf sNew} in {\sf adouble}. 2658 2675 The usage of the external function facility is illustrated by the 2659 2676 example \verb=ext_diff_func= contained in 2660 2677 \verb=examples/additional_examples/ext_diff_func=. 2661 Here,the external differentiated function is also a C code, but the2678 There,the external differentiated function is also a C code, but the 2662 2679 handling as external differentiated functions also a decrease of the 2663 2680 overall required tape size. 2664 2681 2665 2682 % 2666 \subsection{Advance algorithmic differentiation of time integration processes}2683 \subsection{Advanced algorithmic differentiation of time integration processes} 2667 2684 % 2668 2685 For many timedependent applications, the corresponding simulations … … 2800 2817 % 2801 2818 % 2802 \subsection{Advance algorithmic differentiation of fixed point iterations}2819 \subsection{Advanced algorithmic differentiation of fixed point iterations} 2803 2820 % 2804 2821 Quite often, the state of the considered system denoted by $x\in\R^n$ … … 2897 2914 expected signature of the function pointers is contained in the directory \verb=examples/additional_examples/fixpoint_exam=. 2898 2915 % 2899 \subsection{Advance algorithmic differentiation of OpenMP parallel programs}2916 \subsection{Advanced algorithmic differentiation of OpenMP parallel programs} 2900 2917 % 2901 2918 ADOLC allows to compute derivatives in parallel for functions
Note: See TracChangeset
for help on using the changeset viewer.