Nothing Special   »   [go: up one dir, main page]

skip to main content
research-article

Fast Reverse-Mode Automatic Differentiation using Expression Templates in C++

Published: 08 July 2014 Publication History

Abstract

Gradient-based optimization problems are encountered in many fields, but the associated task of differentiating large computer algorithms can be formidable. The operator-overloading approach to performing reverse-mode automatic differentiation is the most convenient for the user but current implementations are typically 10-35 times slower than the original algorithm. In this paper a fast new operator-overloading method is presented that uses the expression template programming technique in C++ to provide a compile-time representation of each mathematical expression as a computational graph that can be efficiently traversed in either direction. Benchmarking with four different numerical algorithms shows this approach to be 2.6--9 times faster than current operator-overloading libraries, and 1.3--7.7 times more efficient in memory usage. It is typically less than 4 times the computational cost of the original algorithm, although poorer performance is found for all libraries in the case of simple loops containing no mathematical functions. An implementation is freely available in the Adept C++ software library.

References

[1]
P. Aubert, N. Di Césaré, and O. Pironneau. Automatic differentiation in C++ using expression templates and application to a flow control problem. Comput. Vis. Sci. 3, 197--208.
[2]
R. Bartlett, D. Gay, and E. Phipps. Automatic differentiation of C++ codes for large-scale scientific computing. In Proceedings of the International Conference on Computational Science (ICCS'06). Lecture Notes in Computer Science, vol. 3994, 525--532.
[3]
B. Bell. CppAD: A package for C++ algorithmic differentiation. http://www.coin-or.org/CppAD.
[4]
C. Bendtsen and O. Stauning. FADBAD, a flexible C++ package for automatic differentiation.Tech. Rep. IMM-REP-1996-17, Technical University of Denmark.
[5]
D. M. Gay. Semiautomatic differentiation for efficient gradient computations. In Automatic Differentiation: Applications, Theory, and Implementations, H. M. Bücker, G. F. Corliss, P. Hovland, U. Naumann, and B. Norris, Eds., Springer, 147--158.
[6]
A. H. Gebremedhin, F. Manne, and A. Pothen. What color is your Jacobian? Graph coloring for computing derivatives. SIAM Rev. 47, 629--705.
[7]
R. Giering and T. Kaminski. Recipes for adjoint code construction. ACM Trans. Math. Softw. 24, 437--474.
[8]
A. Griewank and A. Walther. Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation 2nd Ed. SIAM.
[9]
A. Griewank, D. Juedes, and J. Utke. Algorithm 755: ADOL-C: A package for the automatic differentiation of algorithms written in C/C++. ACM Trans. Math. Softw. 22, 131--167.
[10]
R. J. Hogan. Fast lidar and radar multiple-scattering models -- 1. Small-angle scattering using the photon variance-covariance method. J. Atmos. Sci. 65, 3621--3635.
[11]
R. J. Hogan and A. Battaglia. Fast lidar and radar multiple-scattering models -- 2. Wide-angle scattering using the time-dependent two-stream approximation. J. Atmos. Sci. 65, 3636--3651.
[12]
P. D. Lax and B. Wendroff. Systems of conservation laws. Commun. Pure Appl. Math. 13, 217--237.
[13]
D. C. Liu and J. Nocedal. On the limited memory method for large scale optimization. Math. Programming B 45, 503--528.
[14]
U. Naumann. Optimal accumulation of Jacobian matrices by elimination methods on the dual computational graph. Math. Program. 99, 399--421.
[15]
E. Phipps and R. Pawlowski. Efficient expression templates for operator overloading-based automatic differentiation. In Recent Advances in Algorithmic Differentiation, Lecture Notes in Computational Science and Engineering, vol. 87, Springer.
[16]
O. B. Toon, R. P. Turco, D. Westphal, R. Malone, and M. S. Liu. A multidimensional model for aerosols: Description of computational analogues. J. Atmos. Sci. 45, 2123--2143.
[17]
T. Veldhuizen. Expression templates. C++ Report 7, 26--31.
[18]
M. Voßbeck, R. Giering, and T. Kaminski. Development and first applications of TAC++. In Advances in Automatic Differentiation, Lecture Notes in Computational Science and Engineering, vol. 64, Springer, 187--197.
[19]
J. Willkomm and M. Bücker. AD tools from a user's perspective. In Proceedings of the 6th European AD Workshop. http://www.sc.rwth-aachen.de/willkomm/pdf/6th-euro-ad-willkomm.pdf.

Cited By

View all
  • (2024)Efficiency Investigation of Langevin Monte Carlo Ray TracingMathematics10.3390/math1221343712:21(3437)Online publication date: 3-Nov-2024
  • (2024)Determination of the Thermal Conductivity and Volumetric Heat Capacity of Substance from Heat FluxŽurnal vyčislitelʹnoj matematiki i matematičeskoj fiziki10.31857/S004446692404006764:4(658-670)Online publication date: 15-Nov-2024
  • (2024)Electrothermal Coupling Methodologies and Their Influence on the Optimization of Aircraft Electric MotorsAIAA Journal10.2514/1.J06362762:7(2659-2677)Online publication date: Jul-2024
  • Show More Cited By

Index Terms

  1. Fast Reverse-Mode Automatic Differentiation using Expression Templates in C++

    Recommendations

    Comments

    Please enable JavaScript to view thecomments powered by Disqus.

    Information & Contributors

    Information

    Published In

    cover image ACM Transactions on Mathematical Software
    ACM Transactions on Mathematical Software  Volume 40, Issue 4
    June 2014
    154 pages
    ISSN:0098-3500
    EISSN:1557-7295
    DOI:10.1145/2639949
    Issue’s Table of Contents
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 08 July 2014
    Accepted: 01 December 2013
    Revised: 01 September 2013
    Received: 01 September 2012
    Published in TOMS Volume 40, Issue 4

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Adjoint code
    2. Jacobian matrix
    3. quasi-Newton
    4. template metaprogramming

    Qualifiers

    • Research-article
    • Research
    • Refereed

    Funding Sources

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)37
    • Downloads (Last 6 weeks)1
    Reflects downloads up to 20 Nov 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2024)Efficiency Investigation of Langevin Monte Carlo Ray TracingMathematics10.3390/math1221343712:21(3437)Online publication date: 3-Nov-2024
    • (2024)Determination of the Thermal Conductivity and Volumetric Heat Capacity of Substance from Heat FluxŽurnal vyčislitelʹnoj matematiki i matematičeskoj fiziki10.31857/S004446692404006764:4(658-670)Online publication date: 15-Nov-2024
    • (2024)Electrothermal Coupling Methodologies and Their Influence on the Optimization of Aircraft Electric MotorsAIAA Journal10.2514/1.J06362762:7(2659-2677)Online publication date: Jul-2024
    • (2024)AD-HOC: A C Expression Template Package for High-Order Derivatives BackpropagationSSRN Electronic Journal10.2139/ssrn.4832329Online publication date: 2024
    • (2024)A Matrix-Free Exact Newton MethodSIAM Journal on Scientific Computing10.1137/23M157017X46:3(A1423-A1440)Online publication date: 2-May-2024
    • (2024)Determination of the Thermal Conductivity and Volumetric Heat Capacity of Substance from Heat FluxComputational Mathematics and Mathematical Physics10.1134/S096554252470003964:4(833-847)Online publication date: 7-Jun-2024
    • (2024)A Tensor Algebra Compiler for Sparse DifferentiationProceedings of the 2024 IEEE/ACM International Symposium on Code Generation and Optimization10.1109/CGO57630.2024.10444787(1-12)Online publication date: 2-Mar-2024
    • (2024)Quantitative comparison of variational and sequential data assimilation techniques for one-dimensional initial-value problems of ideal MHDComputers & Fluids10.1016/j.compfluid.2024.106373(106373)Online publication date: Jul-2024
    • (2023)Bayesian parameter inference in hydrological modelling using a Hamiltonian Monte Carlo approach with a stochastic rain modelHydrology and Earth System Sciences10.5194/hess-27-2935-202327:15(2935-2950)Online publication date: 9-Aug-2023
    • (2023)A unified synergistic retrieval of clouds, aerosols, and precipitation from EarthCARE: the ACM-CAP productAtmospheric Measurement Techniques10.5194/amt-16-3459-202316:13(3459-3486)Online publication date: 12-Jul-2023
    • Show More Cited By

    View Options

    Login options

    Full Access

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media