skip to main content
research-article

Algorithm 1005: Fortran Subroutines for Reverse Mode Algorithmic Differentiation of BLAS Matrix Operations

Published:20 March 2020Publication History
Skip Abstract Section

Abstract

A set of Fortran subroutines for reverse mode algorithmic (or automatic) differentiation of the basic linear algebra subprograms (BLAS) is presented. This is preceded by a description of the mathematical tools used to obtain the formulae of these derivatives, with emphasis on special matrices supported by the BLAS: triangular, symmetric, and band. All single and double precision BLAS derivatives have been implemented, together with the Cholesky factorization from Linear Algebra Package (LAPACK). The subroutines are written in Fortran 2003 with a Fortran 77 interface to allow use from C and C++, as well as dynamic languages such as R, Python, Matlab, and Octave. The subroutines are all implemented by calling BLAS, thereby attaining fast runtime. Timing results show derivative runtimes that are about twice those of the corresponding BLAS, in line with theory. The emphasis is on reverse mode because it is more important for the main application that we have in mind, numerical optimization. Two examples are presented, one dealing with the least squares modeling of groundwater, and the other dealing with the maximum likelihood estimation of the parameters of a vector autoregressive time series. The article contains comprehensive tables of formulae for the BLAS derivatives as well as for several non-BLAS matrix operations commonly used in optimization.

Skip Supplemental Material Section

Supplemental Material

References

  1. 2017. Intel Math Kernel Library. Retrieved October 13, 2017 from https://software.intel.com/en-us/mkl.Google ScholarGoogle Scholar
  2. 2017. OpenBLAS: An optimized BLAS library. Retrieved December 4, 2017 from http://www.openblas.net/.Google ScholarGoogle Scholar
  3. Ai Barraud. 1977. A numerical algorithm to solve AT XA − X = Q. IEEE Transactions on Automatic Control 22, 5 (1977), 883--885.Google ScholarGoogle ScholarCross RefCross Ref
  4. Thomas F. Coleman and Arun Verma. 1998. ADMAT: An automatic differentiation toolbox for MATLAB. In Proceedings of the SIAM Workshop on Object Oriented Methods for Inter-Operable Scientific and Engineering Computing, SIAM, Philadelphia, PA, Vol. 2.Google ScholarGoogle Scholar
  5. Thomas F. Coleman and Wei Xu. 2016. Automatic Differentiation in MATLAB Using ADMAT with Applications. SIAM.Google ScholarGoogle Scholar
  6. Jack J. Dongarra, Jeremy Du Croz, Sven Hammarling, and Iain S. Duff. 1990. A set of level 3 basic linear algebra subprograms. ACM Transactions on Mathematical Software (TOMS) 16, 1 (1990), 1--17.Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. Jack J. Dongarra and David W. Walker. 1995. Software libraries for linear algebra computations on high performance computers. SIAM Review 37, 2 (1995), 151--180.Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Paul S. Dwyer and M. S. MacPhail. 1948. Symbolic matrix derivatives. The Annals of Mathematical Statistics 19, 4 (1948), 517--534.Google ScholarGoogle ScholarCross RefCross Ref
  9. Shaun A. Forth. 2006. An efficient overloaded implementation of forward mode automatic differentiation in MATLAB. ACM Transactions on Mathematical Software (TOMS) 32, 2 (2006), 195--222.Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Ralf Giering and Thomas Kaminski. 1998. Recipes for adjoint code construction. ACM Transactions on Mathematical Software (TOMS) 24, 4 (1998), 437--474.Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. M. B. Giles. 2008. An Extended Collection of Matrix Derivative Results for Forward and Reverse Mode Automatic Differentiation. Technical Report. Oxford University Computing Laboratory.Google ScholarGoogle Scholar
  12. Mike B. Giles. 2008. Collected matrix derivative results for forward and reverse mode algorithmic differentiation. In Advances in Automatic Differentiation, Christian H. Bischof, H. Martin Bücker, Paul D. Hovland, Uwe Naumann, and J. Utke (Eds.). Springer, Berlin, 35--44.Google ScholarGoogle Scholar
  13. Kazushige Goto and Robert van de Geijn. 2008. High-performance implementation of the level-3 BLAS. ACM Transactions on Mathematical Software (TOMS) 35, 1 (2008), 4.Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. Andreas Griewank. 1989. On automatic differentiation. In Mathematical Programming, Masao Iri and K. Tanabe (Eds.). Kluwer Academic Publishers, Dordrecht, 83--108.Google ScholarGoogle Scholar
  15. Andreas Griewank. 2003. A mathematical view of automatic differentiation. In Acta Numerica. Vol. 12. Cambridge University Press, Cambridge, 321--398.Google ScholarGoogle Scholar
  16. Andreas Griewank. 2012. Who invented the reverse mode of differentiation? Documenta Mathematica, Extra Volume ISMP (2012), 389--400.Google ScholarGoogle Scholar
  17. Andreas Griewank. 2015. Automatic differentiation, Mark R. Dennis, Paul Glendinning, Paul A. Martin, Fadil Santosa, and Jared Tanner (Eds.). Princeton University Press, 749--752.Google ScholarGoogle Scholar
  18. Andreas Griewank, David Juedes, and Jean Utke. 1996. Algorithm 755: ADOL-C: A package for the automatic differentiation of algorithms written in C/C++. ACM Transactions on Mathematical Software 22, 2 (1996), 131--167.Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. Andreas Griewank and Andrea Walther. 2008. Evaluating Derivatives: Principles and Techniques of Algorithmic Differentiation (2nd ed.). Number 105 in Other Titles in Applied Mathematics. SIAM, Philadelphia, PA.Google ScholarGoogle ScholarCross RefCross Ref
  20. Masao Iri. 1991. History of automatic differentiation and rounding error estimation. In Automatic Differentiation of Algorithms: Theory, Implementation, and Application, Andreas Griewank and George F. Corliss (Eds.). SIAM, Philadelphia, 1--16.Google ScholarGoogle Scholar
  21. Kristjan Jonasson. 2008. Algorithm 878: Exact VARMA likelihood and its gradient for complete and incomplete data with Matlab. ACM Transactions on Mathematical Software (TOMS) 35, 1 (2008), 6:1--6:11.Google ScholarGoogle Scholar
  22. Kristjan Jonasson. 2009. Algorithm 892: DISPMODULE, a Fortran 95 module for pretty-printing matrices. ACM Transactions on Mathematical Software (TOMS) 36, 1 (2009), 6:1--6:7.Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Gershon Kedem. 1980. Automatic differentiation of computer programs. ACM Trans. Math. Software 6, 2 (June 1980), 150--165.Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. Chuck L. Lawson, Richard J. Hanson, David R. Kincaid, and Fred T. Krogh. 1979. Basic linear algebra subprograms for Fortran usage. ACM Transactions on Mathematical Software (TOMS) 5, 3 (1979), 308--323.Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. Uwe Naumann. 2008. Optimal Jacobian accumulation is NP-complete. Mathematical Programming 112, 2 (2008), 427--441.Google ScholarGoogle ScholarDigital LibraryDigital Library
  26. Uwe Naumann. 2012. The Art of Differentiating Computer Programs: An Introduction to Algorithmic Differentiation. Siam, Philadelphia, PA.Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. S. P. Smith. 1995. Differentiation of the Cholesky algorithm. Journal of Computational and Graphical Statistics 4, 2 (1995), 134--147.Google ScholarGoogle Scholar
  28. Arun Verma. 1998. Structured Automatic Differentiation. Ph.D. Dissertation. Department of Computer Science, Cornell University, Ithaca, NY.Google ScholarGoogle Scholar
  29. Arun Verma. 1999. ADMAT: Automatic differentiation in MATLAB using object oriented methods. In Object Oriented Methods for Interoperable Scientific and Engineering Computing: Proceedings of the 1998 SIAM Workshop, M. E. Henderson, C. R. Anderson, and S. L. Lyons (Eds.). SIAM, Philadelphia, 174--183.Google ScholarGoogle Scholar
  30. Sebastian F. Walter and Lutz Lehmann. 2013. Algorithmic differentiation in Python with AlgoPy. Journal of Computational Science 4, 5 (2013), 334--344.Google ScholarGoogle ScholarCross RefCross Ref
  31. Qian Wang, Xianyi Zhang, Yunquan Zhang, and Qing Yi. 2013. AUGEM: Automatically generate high performance dense linear algebra kernels on x86 CPUs. In Proceedings of the International Conference on High Performance Computing, Networking, Storage and Analysis. ACM, 25:1--25:12.Google ScholarGoogle Scholar
  32. Matthew J. Weinstein and Anil V. Rao. 2017. Algorithm 984: ADiGator, a toolbox for the algorithmic differentiation of mathematical functions in matlab using source transformation via operator overloading. ACM Transactions on Mathematical Software (TOMS) 44, 2 (2017), 21:1--21:25.Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. R. Clint Whaley, Antoine Petitet, and Jack J. Dongarra. 2001. Automated empirical optimizations of software and the ATLAS project. Parallel Computing 27, 1 (2001), 3--35.Google ScholarGoogle ScholarCross RefCross Ref

Index Terms

  1. Algorithm 1005: Fortran Subroutines for Reverse Mode Algorithmic Differentiation of BLAS Matrix Operations

          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 46, Issue 1
            March 2020
            214 pages
            ISSN:0098-3500
            EISSN:1557-7295
            DOI:10.1145/3387915
            Issue’s Table of Contents

            Copyright © 2020 Owner/Author

            Permission to make digital or hard copies of part or all 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 third-party components of this work must be honored. For all other uses, contact the Owner/Author.

            Publisher

            Association for Computing Machinery

            New York, NY, United States

            Publication History

            • Published: 20 March 2020
            • Revised: 1 August 2019
            • Accepted: 1 August 2019
            • Received: 1 December 2017
            Published in toms Volume 46, Issue 1

            Check for updates

            Qualifiers

            • research-article
            • Research
            • Refereed
          • Article Metrics

            • Downloads (Last 12 months)55
            • Downloads (Last 6 weeks)3

            Other Metrics

          PDF Format

          View or Download as a PDF file.

          PDF

          eReader

          View online with eReader.

          eReader

          HTML Format

          View this article in HTML Format .

          View HTML Format