skip to main content
article
Free Access

Fast floating-point processing in Common Lisp

Published:01 March 1995Publication History
Skip Abstract Section

Abstract

Lisp, one of the oldest higher-level programming languages, has rarely been used for fast numerical (floating-point) computation. We explore the benefits of Common Lisp, an emerging new language standard with some excellent implementations, for numerical computation. We compare it to Fortran in terms of the speed of efficiency of generated code, as well as the structure and convenience of the language. There are a surprising number of advantages to Lisp, especially in cases where a mixture of symbolic and numeric processing is needed.

References

  1. AHO, A. V., HOPCROFT, J., AND ULLMAN J. D. 1974. The Design and Analysts of Computer Algorithms. Addison-Wesley, Reading, Mass. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. AHO, A. V., SETm, R., ULLMAN, J. D. 1986. Compiler: Principles, Techniques, and Tools. Addison-Wesley, Reading, Mass. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. ANDERSON, E., BAI, Z., BISEHOF, C., DEMMEL, J., DONGARRA, J., Du CROZ, J., GREENBAUM, h., HAMMARLING, S., McKENNEY, A., OSTROUCHOV, S., AND SORENSEN, D. 1992. LAPACK Users' Guide, Release 1.0. SIAM, Philadelphia, Pa. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. BAKER, H.G. 1990. The Nimble Type Inferencer for Common Lisp-84. Nimble Computer Corp., Encino, Calif.Google ScholarGoogle Scholar
  5. BOISVERT, R. F., HOWE, S. E., AND KAHANER, D. K. 1985. GAMS--A framework for the management of scientific software. ACM Trans. Math. Softw. 11,313-355. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. BROUGHAN, K.A. 1992. SENAC: Lisp as a platform for constructing a problem solving environment. In Programming Environments for High-Level Scientific Problem Solving, P. W. Gaffney and E. N. Houstis, Eds. North-Holland/IFIP, Amsterdam, 351-359. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. BROUGHAN, K. A. 1991. SENAC: A high-level interface for the NAG Library. ACM Trans. Math. Softw. 17, 4, 462 480. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. BROUGHAN, K.A. 1990a. The SENAC Manuals. Vol. I and II. University of London, London.Google ScholarGoogle Scholar
  9. BROUGHAN, K.A. 1990b. Interactive access to subroutine libraries: An interlink for SENAC. In Proceedings of the Internattonal Conference on Computational Techniques and Applications, CTAC-89, J. Horvath, Ed. Hemisphere, Washington, D.C., 145-151.Google ScholarGoogle Scholar
  10. BROUGHAN, K. A. 1987. Naglink--A working symbolic/numeric interface. In IFIP TC2 / W.G.2.5 Working Conference on Problem-Solving Environments for Scientific Computing, B. Ford and F. Chatelin, Eds. Elsevier, Amsterdam, 343-350.Google ScholarGoogle Scholar
  11. BROUGHAN, K.A. 1986. A symbolic numeric interface for the NAG Library. Newslett. Num. Alg. Group (Aug.), 16-24.Google ScholarGoogle Scholar
  12. BROUGHAN, K.A. 1985. The Naglink Manual--An Interface between MACSYMA and NAG. Version 1.0. Development Finance Corp. of New Zealand.Google ScholarGoogle Scholar
  13. BROUGHAN, K. A. AND KEADY, G. 1991. Numlink and Naglink: Links to the NAG Library from SENAC and Macsyma. In Proceedings on the Interface between Symbolic and Numeric Computing. Helsinki University, Helsinki, Finland, 19-34.Google ScholarGoogle Scholar
  14. BROUGHAN, K. A., KEADY, G., ROBB, T. D., RICHARDSON, M. G., AND DEWAR, M.C. 1991. Some symbolic computing links to the NAG numeric library. SIGSAM Bull. 3/25, 28-37. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. BURNET% D.S. 1988. F~nzte Element Analysis Addison-Wesley, Reading, Mass.Google ScholarGoogle Scholar
  16. COOK, G. O., JR. 1992. Code generation in ALPAL using symbolic techniques. In Proceedings of the Internattonal Symposium on Symbolic and Algebraic Computation, P. Wang, Ed. ACM, New York, 27-35. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. FODERARO, J. K., (ED.) 1991. Special section on Lisp. Commun. ACM 34, 9 (Sept.), 27-69. Google ScholarGoogle ScholarDigital LibraryDigital Library
  18. FODERARO, J. K., SKLOWER, K. L., AND LAYER, K. 1983. The Franz L~sp Manual. Univ. of California, Berkeley, Calif.Google ScholarGoogle Scholar
  19. FORD, B. 1982. Transportable numerical software. In Lecture Notes in Computer Science. Vol. 142. Sprmger-Verlag, New York, 128-140. Google ScholarGoogle ScholarDigital LibraryDigital Library
  20. FRANZ. 1991. Allegro CL Users Guide, Release 4.0. Franz Inc., Berkeley, Calif.Google ScholarGoogle Scholar
  21. KAJLER, N. 1992. A portable and extensible interface for computer algebra systems. In Proceedings of the International Symposium on Symbolic and Algebraic Computation, P. Wang, Ed. ACM, New York, 376-386. Google ScholarGoogle ScholarDigital LibraryDigital Library
  22. KNUTH D. E. 1981. The Art of Computer Programming. Vol. II. 2nd ed. Addison-Wesley, Reading, Mass. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. LANAM, D.H. 1981. An algebraic front-end for the production and use of numeric programs In Proceedings of the 1981 ACM Symposium on Symboltc and Algebraic Computation, P. Wang, Ed. ACM, New York, 223-227. Google ScholarGoogle ScholarDigital LibraryDigital Library
  24. LAWSON, C. L., HANSON, R. J., KINCA~D, D., AND KROGH, F. T. 1979. Basic linear algebra subprograms for FORTRAN usage. ACM Trans. Math, Softw. 5, 3, 308-323. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. LUCID, INC. 1991. Lucid Common L~sp/Sun Advanced User's Guide, Release 4.0. Lucid, Inc., Menlo Park, Calif.Google ScholarGoogle Scholar
  26. MACLACI~LAN, R.A. 1992. The Python compiler for CMU Common Lisp. In Proceedings of the ACM Conference on Lisp and Functional Programming. ACM, New York. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. MARSTEN, R.E. 1981. The design of the XMP linear programming library. ACM Trans. Math. Softw. 7, 4, 481-497. Google ScholarGoogle ScholarDigital LibraryDigital Library
  28. MATt~LAB GROUP. 1977. The Macsyma Reference Manual, Version 9. Mathlab Group, Lab. for Computer Science, MIT, Cambridge, Mass.Google ScholarGoogle Scholar
  29. McCARTHY, J., ABRAHAMS, P. W., EDWARDS, D. J., FOX, P. A., HART, T. P., AND LEVIN, M.J. 1962. Lisp 1.5 Programmers MaTlual. MIT Press, Cambridge, Mass Google ScholarGoogle ScholarDigital LibraryDigital Library
  30. MESZTENY, C. AND W~TZaALL, C. 1967. Stable evaluation of polynomials. J. Res. NGt. Bur. Stand.-B 71B, I (Jan.), 11-17.Google ScholarGoogle Scholar
  31. PRESS, W. H., FLANNERY. B. P., TEUKOLSKY, S. A., AND VETTERLINa, W.T. 1989. Numerical Recipes. Cambridge University Press, Cambridge, U K.Google ScholarGoogle Scholar
  32. ScHOU, W. C. AND BROUGHAN, K.A. 1989. The Risch algorithms of Macsyma and SENAC. SIGSAM Bull. 23 1, 19-22. Google ScholarGoogle ScholarDigital LibraryDigital Library
  33. STEELE, G. L., JR. 1990. Common Lisp the Language. 2nd ed. Digital Press, Cambridge, Mass. Google ScholarGoogle ScholarDigital LibraryDigital Library
  34. WANG, P.S. 1986. FINGER: A symbolic system for automatic generation of numerical programs in finite element analysis. J. Symb. Comput. 2, 305-316. Google ScholarGoogle ScholarDigital LibraryDigital Library
  35. WHITE, J.L. 1979. NIL: A perspective. In Proceedings of the 1979 MACSYMA Users' Conference. MIT, Cambridge, Mass.Google ScholarGoogle Scholar
  36. W~ITE, J.L. 1977. Lisp: Program is Data: A historical perspective on MACLISP. In Proceedings of the 1977 MACSYMA Users' Conference. MIT, Cambridge, Mass., 181-189.Google ScholarGoogle Scholar
  37. WroTH, M. C. 1980. On the automation of computational physics Ph.D. dissertation, Davis School of Applied Science, Univ. of California, Berkeley, Cahf.Google ScholarGoogle Scholar

Index Terms

  1. Fast floating-point processing in Common Lisp

        Recommendations

        Reviews

        John R. Levine

        Basically, this paper is a polemic about LISP arithmetic. It starts with an overview of why one might want to do floating point arithmetic in LISP: there are packages that do a combination of symbolic and numerical mathematics, and techniques that glue pieces of FORTRAN object code into LISP programs do not work very well. Then it looks at the advantages and disadvantages of Common Lisp for numerical programming. On the disadvantage side, LISP's very late binding and automatic storage management can make it difficult to generate object code that is competitive with FORTRAN. LISP supports a large set of numeric types, and does not require that the types of variables be declared before use. Hence, it is possible that an operand to an addition might be a double-precision float one time, but a multiprecision integer the next, forcing operations to be interpreted rather than compiled in-line. Procedures can be called with varying numbers and types of arguments. To aid in garbage collection, values are usually “boxed,” stored in a separate area of memory and referred to indirectly through pointers. The authors describe methods by which each of these impediments to efficient compilation may be addressed. On the positive side, LISP can be used as a much higher-level language than FORTRAN, and a polynomial evaluation, for example, can be written as a LISP macro that, at compile time, selects one of a variety of different algorithms based on the types and values of the argument and coefficients. Loops can be expressed in various high-level ways that similarly allow optimizations not possible in lower-level code. LISP has much more flexible storage management than FORTRAN, permitting far more effective data sharing than FORTRAN COMMON allows. Storage allocation to make the most effective use of hardware caches is also possible, again because LISP allows a higher-level description of algorithms. The authors look at the object code generated by some widely used LISP compilers for a few common numerical tasks such as clearing an array and matrix multiplication. While not as good as the code from an optimizing FORTRAN compiler, LISP code is better than unoptimized FORTRAN and is usually within a small integer factor of the best FORTRAN. The authors suggest, waving their hands somewhat, that improving the quality of the LISP code would not be hard. They finish by describing a prototype FORTRAN-to-LISP translator that turns FORTRAN code into equivalent LISP, making the LISP as amenable as possible to efficient calculation. The hand-waving gets intense in this part (“We expect to continue to refine the tool”), but it is clear that even the prototype is good enough to translate chunks of FORTRAN into LISP that is usable directly or with modest tweaking. Programmers familiar with both LISP and numerical programming (an admittedly small group) have known for decades that it is possible to write LISP numeric code that runs adequately fast. As the size and complexity of numerical packages continue to grow, numerical programmers steeped in FORTRAN should consider that a package that runs a little slower than a FORTRAN version is a lot better than one that does not run at all, and LISP is a more productive programming language than FORTRAN will ever be.

        Access critical reviews of Computing literature here

        Become a reviewer for Computing Reviews.

        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 21, Issue 1
          March 1995
          156 pages
          ISSN:0098-3500
          EISSN:1557-7295
          DOI:10.1145/200979
          • Editor:
          • Ronald F. Boisvert
          Issue’s Table of Contents

          Copyright © 1995 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: 1 March 1995
          Published in toms Volume 21, Issue 1

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • article

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader