Presentation is loading. Please wait.

Presentation is loading. Please wait.

In conclusion our tool: can be used with any operator overloading AD package replaces the manual process, which is slow and overestimates the number active.

Similar presentations


Presentation on theme: "In conclusion our tool: can be used with any operator overloading AD package replaces the manual process, which is slow and overestimates the number active."— Presentation transcript:

1 In conclusion our tool: can be used with any operator overloading AD package replaces the manual process, which is slow and overestimates the number active variables successfully identifies active variables can change the data type of active variables of most C data types In the future we would like to: Benchmark the tool Add support for C++ Identifying Active Variables to Improve the Performance of Operator Overloading Automatic Differentiation Drew Wicke Argonne National Laboratory INTRODUCTION Results Materials and Methods Discussion Automatic Differentiation (AD) is a means of computing the derivative of a function within a computer program. AD can be performed by using the operator overloading approach which uses features of the programming language to alter the meaning of mathematical operators to compute the derivative. Operator overloading as a means of performing AD allows for maintainable code; however, speed of computation is sacrificed. The goal of this research was to use activity analysis to improve the performance of the calculation of derivatives using Sacado. Sacado is a package in the Trilinos framework and is an implementation in C++ of the operator overloading method of AD. The tool created to accomplish this combines the activity analysis of the source code analysis toolkit, OpenAnalysis, with the source-to-source transformation tool ROSE. CONCLUSION/FUTURE STEPS We encountered challenges in type changing. For example, to change the type of typedef active variables we must extract base type and all other types such as pointers to set to the derivative type. DERIV_TYPE operator* (DERIV_TYPE other) { this->val = this->val() * other.val(); this->dx = this->val() * other.dx() + other- >val() * this->dx(); return *this; } int main(){ double val; val = 4.3; … return 0; } Convert 2. ROSE AST3. OpenAnalysis ICFG 4. Vary Analysis Useful Analysis Activity Analysis int main(){ DERIV_TYPE_double val; val = 4.3; … return 0; } 6. Output generated code Vary variables are those whose value is computed using an independent variable. Useful variables are used to compute the value of the dependent variable Active variables are both vary and useful. Activity Analysis Tool Flow typedef Sacado::Fad::DFad DERIV_TYPE_double; // Sacado derivative type void foo(DERIV_TYPE_double *x, DERIV_TYPE_double *f){ DERIV_TYPE_double squarePoly = (*x) * (*x); DERIV_TYPE_double theConst = 3.14 * 2; DERIV_TYPE_double div = ((*x) / 2); if (squarePoly >= 100) (*f) = div * theConst; else (*f) = div * theConst + 100; } 1. Input Code 5. Change the type of active variables to derivative type The above code illustrates how a Sacado function can be written. All the variables have the Sacado derivative type DERIV_TYPE_double. Both the function and the derivative of the function are computed using overloaded operators, such as the example on the left, when the variables have the Sacado derivative type. Since active variables need only have the derivative type, the code is inefficient due to unnecessary memory allocation and function calls. Above is an example of an overloaded multiplication operator. Not only must the product be computed, but also the value of the derivative after applying the product rule. typedef Sacado::Fad::DFad DERIV_TYPE_double; void foo(DERIV_TYPE_double *x, DERIV_TYPE_double *f){ # pragma $adic_indep,x // specify the independent # pragma $adic_dep,f // and dependent variables double squarePoly = ADValue((*x) * (*x)); double theConst = 3.14 * 2; DERIV_TYPE_double div = ((*x) / 2); if (squarePoly >= 100) (*f) = div * theConst; else (*f) = div * theConst + 100; } After applying the tool to code that has variables with double type variables we get the generated code below. This code is efficient because only the active variables have the Sacado derivative type, DERIV_TYPE_double. // after: typedef double* fir; typedef fir* sec; DERIV_TYPE_double **test; // before: typedef double* fir; typedef fir* sec; sec test; // active Above code shows that we gather double and pointer data types to change the type of test to DERIV_TYPE_double**. The above diagram demonstrates the process through which our tool takes in order to change the types of active variables. 1.Provide code that you want to run the tool on 2.The tool converts the code to an abstract syntax tree (AST) with ROSE 3.AST is converted to a interprocedural control flow graph (ICFG) for OpenAnalysis 4.Using OpenAnalysis perform vary, useful and activity analysis to make a list of active variables 5.Change the active variable’s type to the Sacado derivative type within the AST 6.Output the generated code based off of the AST The submitted manuscript has been created by UChicago Argonne, LLC, Operator of Argonne National Laboratory ("Argonne"). Argonne, a U.S. Department of Energy Office of Science laboratory, is operated under Contract No. DE-AC02-06CH11357. The U.S. Government retains for itself, and others acting on its behalf, a paid-up nonexclusive, irrevocable worldwide license in said article to reproduce, prepare derivative works, distribute copies to the public, and perform publicly and display publicly, by or on behalf of the Government References: Automatic Differentiation: http://www.autodiff.org/ OpenAnalysis: http://openanalysis.berlios.de/ ROSE: http://www.rosecompiler.org/ Sacado: http://trilinos.sandia.gov/


Download ppt "In conclusion our tool: can be used with any operator overloading AD package replaces the manual process, which is slow and overestimates the number active."

Similar presentations


Ads by Google