skip to main content
research-article

Algorithm 940: Optimal Accumulator-Based Expression Evaluation through the Use of Expression Templates

Published: 01 April 2014 Publication History

Abstract

In this article we present a compile-time algorithm, implemented using C++ template metaprogramming techniques, that minimizes the use of temporary storage when evaluating expressions. We present the basic building blocks of our algorithm---transformations that act locally on nodes of the expression parse tree---and demonstrate that the application of these local transformations generates a (nonunique) expression that requires a minimum number of temporary storage objects to evaluate. We discuss a C++ implementation of our algorithm using expression templates, and give results demonstrating the effectiveness of our approach.

Supplementary Material

ZIP File (940.zip)
Software for Optimal Accumulator-Based Expression Evaluation through the Use of Expression Templates

References

[1]
Prud’hom Christophe. 2006. A domain specific embedded language in c++ for automatic differentiation, projection, integration and variational formulations. Sci. Program. 14, 2, 81--110. http://portal.acm.org/citation.cfm?id=1376891.1376895.
[2]
Daniele Antonio Di Pietro and Alessandro Veneziani. 2009. Expression templates implementation of continuous and discontinuous galerkin methods. Comput. Vis. TSci. 12, 8, 421--436.
[3]
Gaël Guennebaud, Benoît Jacob, et al. 2010. Eigen v3. http://eigen.tuxfamily.org.
[4]
Masakatsu Ito. 2001. Matrix expression templates. http://met.sourceforge.net/.
[5]
George Em Karniadakis and Spencer J. Sherwin. 1999. Spectral/Hp Element Methods for CFD. Oxford University Press, New York.
[6]
Robert C. Kirby. 2003. A new look at expression templates for matrix computation. Comput. Sci. Engin. 5, 3, 66--70.
[7]
Charles L. Lawson, Richard J. Hanson, David R. Kincaid, and Fred T. Krogh. 1979. Basic linear algebra subprograms for fortran usage. ACM Trans. Math. Softw. 5, 3, 308--323.
[8]
Michael Lehn, Alexander Stippler, and Karsten Urban. 2005. Flens --- A flexible library for efficient numerical solutions. http://dml.cz/bitstream/handle/10338.dmlcz/700445/Equadiff_11-2005-2_55.pdf.
[9]
Laurent Plagne, Frank Hülsemann, Denis Barthou, and Julien Jaeger. 2009. Parallel expression template for large vectors. In Proceedings of the 8th Workshop on Parallel/High-Performance Object-Oriented Scientific Computing (POOSC’09). ACM Press, New York.
[10]
Conrad Sanderson. 2010. Armadillo: An open source c++ linear algebra library for fast prototyping and computationally intensive experiments. Tech. rep. NICTA, Australia. http://arma.sourceforge.net/armadillo_nicta_2010.pdf.
[11]
Ravi Sethi and Jeffrey D. Ullman. 1970. The generation of optimal code for arithmetic expressions. J. ACM 17, 4, 715--728.
[12]
David Vandevoorde and Nicolai M. Josuttis. 2002. C++ Templates. Addison-Wesley Longman, Boston, MA.
[13]
Todd L. Veldhuizen. 1995. Expression templates. C++ Rep. 7, 5, 26--31. (Reprinted in C++ Gems, Stanley Lippman, Ed.)
[14]
Todd L. Veldhuizen. 1998. Arrays in blitz++. In Proceedings of the 2nd International Symposium on Computing in Object-Oriented Parallel Environments (ISCOPE’98). Springer, 223--230. http://portal.acm.org/citation.cfm?id=646894.709708.
[15]
Joerg Walter and Mathias Koch. 2002. Boost basic linear algebra library (ublas) homepage. http://www.boost.org/libs/numeric/ublas/.

Index Terms

  1. Algorithm 940: Optimal Accumulator-Based Expression Evaluation through the Use of Expression Templates

      Recommendations

      Comments

      Information & Contributors

      Information

      Published In

      cover image ACM Transactions on Mathematical Software
      ACM Transactions on Mathematical Software  Volume 40, Issue 3
      April 2014
      152 pages
      ISSN:0098-3500
      EISSN:1557-7295
      DOI:10.1145/2610268
      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: 01 April 2014
      Accepted: 01 August 2013
      Revised: 01 February 2013
      Received: 01 February 2012
      Published in TOMS Volume 40, Issue 3

      Permissions

      Request permissions for this article.

      Check for updates

      Badges

      Author Tags

      1. C++
      2. dense linear algebra operations
      3. expression templates
      4. template metaprogramming
      5. temporary storage minimization

      Qualifiers

      • Research-article
      • Research
      • Refereed

      Contributors

      Other Metrics

      Bibliometrics & Citations

      Bibliometrics

      Article Metrics

      • 0
        Total Citations
      • 189
        Total Downloads
      • Downloads (Last 12 months)3
      • Downloads (Last 6 weeks)0
      Reflects downloads up to 16 Feb 2025

      Other Metrics

      Citations

      View Options

      Login options

      Full Access

      View options

      PDF

      View or Download as a PDF file.

      PDF

      eReader

      View online with eReader.

      eReader

      Figures

      Tables

      Media

      Share

      Share

      Share this Publication link

      Share on social media