Skip to main content

Efficient Expression Templates for Operator Overloading-Based Automatic Differentiation

  • Conference paper
  • First Online:
Recent Advances in Algorithmic Differentiation

Part of the book series: Lecture Notes in Computational Science and Engineering ((LNCSE,volume 87))

Abstract

Expression templates are a well-known set of techniques for improving the efficiency of operator overloading-based forward mode automatic differentiation schemes in the C\(++\) programming language by translating the differentiation from individual operators to whole expressions. However standard expression template approaches result in a large amount of duplicate computation, particularly for large expression trees, degrading their performance. In this paper we describe several techniques for improving the efficiency of expression templates and their implementation in the automatic differentiation package Sacado (Phipps et al., Advances in automatic differentiation, Lecture notes in computational science and engineering, Springer, Berlin, 2008; Phipps and Gay, Sacado automatic differentiation package. http://trilinos.sandia.gov/packages/sacado/, 2011). We demonstrate their improved efficiency through test functions as well as their application to differentiation of a large-scale fluid dynamics simulation code.

Sandia National Laboratories is a multi-program laboratory managed and operated by Sandia Corporation, a wholly owned subsidiary of Lockheed Martin Corporation, for the U.S. Department of Energy’s National Nuclear Security Administration under contract DE-AC04-94AL85000.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 84.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 109.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info
Hardcover Book
USD 109.99
Price excludes VAT (USA)
  • Durable hardcover edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Note that num_args is a compile-time constant that is uniquely determined by each expression in the code, and thus while it is “static”, it isn’t a static variable in the traditional sense.

References

  1. Abrahams, D., Gurtovoy, A.: C\(++\) Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond. Addison-Wesley (2004)

    Google Scholar 

  2. Aubert, P., Di Césaré, N.: Expression templates and forward mode automatic differentiation. In: Corliss et al. [8], chap. 37, pp. 311–315

    Google Scholar 

  3. Aubert, P., Di Césaré, N., Pironneau, O.: Automatic differentiation in C\(++\) using expression templates and application to a flow control problem. Computing and Visualization in Science 3, 197–208 (2001)

    Google Scholar 

  4. Bartlett, R.A., Gay, D.M., Phipps, E.T.: Automatic differentiation of C\(++\) codes for large-scale scientific computing. In: V.N. Alexandrov, G.D. van Albada, P.M.A. Sloot, J. Dongarra (eds.) Computational Science – ICCS 2006, Lecture Notes in Computer Science, vol. 3994, pp. 525–532. Springer, Heidelberg (2006). DOI 10.1007/11758549{ _}73

    Google Scholar 

  5. Bischof, C.H., Bücker, H.M., Hovland, P.D., Naumann, U., Utke, J. (eds.): Advances in Automatic Differentiation, Lecture Notes in Computational Science and Engineering, vol. 64. Springer, Berlin (2008). DOI 10.1007/978-3-540-68942-3

    Google Scholar 

  6. Bischof, C.H., Carle, A., Khademi, P., Mauer, A.: ADIFOR 2.0: Automatic differentiation of Fortran 77 programs. IEEE Computational Science & Engineering 3(3), 18–32 (1996)

    Google Scholar 

  7. Bischof, C.H., Haghighat, M.R.: Hierarchical approaches to automatic differentiation. In: M. Berz, C. Bischof, G. Corliss, A. Griewank (eds.) Computational Differentiation: Techniques, Applications, and Tools, pp. 83–94. SIAM, Philadelphia, PA (1996)

    Google Scholar 

  8. Corliss, G., Faure, C., Griewank, A., Hascoët, L., Naumann, U. (eds.): Automatic Differentiation of Algorithms: From Simulation to Optimization, Computer and Information Science. Springer, New York, NY (2002)

    Google Scholar 

  9. Dawes, B., Abrahams, D.: Boost C\(++\) Libraries. http://www.boost.org (2011)

  10. Eisenstat, S.C., Walker, H.F.: Globally convergent inexact Newton methods. SIAM J. Optim. 4, 393–422 (1994)

    Google Scholar 

  11. Griewank, A.: Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation. No. 19 in Frontiers in Appl. Math. SIAM, Philadelphia, PA (2000)

    Google Scholar 

  12. Naumann, U., Hu, Y.: Optimal vertex elimination in single-expression-use graphs. ACM Transactions on Mathematical Software 35(1), 1–20 (2008). DOI 10.1145/1377603.1377605

    Google Scholar 

  13. Pawlowski, R.P., Phipps, E.T., Salinger, A.G.: Automating embedded analysis capabilities using template-based generic programming. Scientific Programming (2012). In press.

    Google Scholar 

  14. Pawlowski, R.P., Phipps, E.T., Salinger, A.G., Owen, S.J., Siefert, C., Staten, M.L.: Applying template-based generic programming to the simulation and analysis of partial differential equations. Scientific Programming (2012). In press.

    Google Scholar 

  15. Phipps, E.T., Bartlett, R.A., Gay, D.M., Hoekstra, R.J.: Large-scale transient sensitivity analysis of a radiation-damaged bipolar junction transistor via automatic differentiation. In: Bischof et al. [5], pp. 351–362. DOI 10.1007/978-3-540-68942-3{ _}31

    Google Scholar 

  16. Phipps, E.T., Gay, D.M.: Sacado Automatic Differentiation Package. http://trilinos.sandia.gov/packages/sacado/ (2011)

  17. Riehme, J., Griewank, A.: Algorithmic differentiation through automatic graph elimination ordering (adtageo). In: U. Naumann, O. Schenk, H.D. Simon, S. Toledo (eds.) Combinatorial Scientific Computing, no. 09061 in Dagstuhl Seminar Proceedings. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, Germany, Dagstuhl, Germany (2009)

    Google Scholar 

  18. Shadid, J.N., Salinger, A.G., Pawlowski, R.P., Lin, P.T., Hennigan, G.L., Tuminaro, R.S., Lehoucq, R.B.: Large-scale stabilized FE computational analysis of nonlinear steady-state transport/reaction systems. Computer methods in applied mechanics and engineering 195, 1846–1871 (2006)

    Google Scholar 

  19. Veldhuizen, T.: Expression templates. C\(++\) Report 7(5), 26–31 (1995)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Eric Phipps .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2012 Springer-Verlag Berlin Heidelberg

About this paper

Cite this paper

Phipps, E., Pawlowski, R. (2012). Efficient Expression Templates for Operator Overloading-Based Automatic Differentiation. In: Forth, S., Hovland, P., Phipps, E., Utke, J., Walther, A. (eds) Recent Advances in Algorithmic Differentiation. Lecture Notes in Computational Science and Engineering, vol 87. Springer, Berlin, Heidelberg. https://doi.org/10.1007/978-3-642-30023-3_28

Download citation

Publish with us

Policies and ethics