skip to main content
research-article

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

Published:08 July 2014Publication History
Skip Abstract Section

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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. B. Bell. CppAD: A package for C++ algorithmic differentiation. http://www.coin-or.org/CppAD.Google ScholarGoogle Scholar
  4. C. Bendtsen and O. Stauning. FADBAD, a flexible C++ package for automatic differentiation.Tech. Rep. IMM-REP-1996-17, Technical University of Denmark.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar
  6. A. H. Gebremedhin, F. Manne, and A. Pothen. What color is your Jacobian? Graph coloring for computing derivatives. SIAM Rev. 47, 629--705. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. R. Giering and T. Kaminski. Recipes for adjoint code construction. ACM Trans. Math. Softw. 24, 437--474. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. A. Griewank and A. Walther. Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation 2nd Ed. SIAM. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. P. D. Lax and B. Wendroff. Systems of conservation laws. Commun. Pure Appl. Math. 13, 217--237. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. D. C. Liu and J. Nocedal. On the limited memory method for large scale optimization. Math. Programming B 45, 503--528. Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. U. Naumann. Optimal accumulation of Jacobian matrices by elimination methods on the dual computational graph. Math. Program. 99, 399--421. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle ScholarCross RefCross Ref
  17. T. Veldhuizen. Expression templates. C++ Report 7, 26--31. Google ScholarGoogle ScholarDigital LibraryDigital Library
  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.Google ScholarGoogle Scholar
  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.Google ScholarGoogle Scholar

Index Terms

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

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    • 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

      Copyright © 2014 ACM

      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: 8 July 2014
      • Accepted: 1 December 2013
      • Revised: 1 September 2013
      • Received: 1 September 2012
      Published in toms Volume 40, Issue 4

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article
      • Research
      • Refereed

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader