[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*To*: info-macl@cambridge.apple.com*Subject*: FPC*From*: gat@robotics.jpl.nasa.gov (Erann Gat)*Date*: Mon, 7 Jan 91 17:20:38 PST

The requests for FPC have been rather overwhelming. There were so many requests that I have decided to post it rather than sending it out individually to everyone who asked. Thanks for the requests! The downside of this public distribution is that I am withholding the source code for now and sending only a binhexed fasl file. FPC is written in T, not Common Lisp, and so the source wouldn't be useful for most people anyway. If there is enough demand I may put together a CL version (and add all those new features that I haven't gotten around to yet!) A documentation file is also included. Please send me comments, bug reports, and suggestions for new features. Some that I already have in the queue: 1. Install some type checking, especially for the first argument of destructive functions. FPC was designed for speed at the expense of safety, but the consequences of this particular bug are too scary to be left unaddressed. 2. Add support for EXPT. 3. Add support for LET. 4. Add support for arrays, DOTIMES, integer and mixed-mode math, etc. FPC stores code in the MAC heap, and therefore will not work with DUMPLISP. (If anyone knows a way to allocate a block of memory on the lisp heap that won't be interpreted as LISP data by the garbage collector please let me know.) FPC is copyrighted. You may distribute this posting provided that it is distributed in its entirety (including this preamble) and that nothing is removed, added or deleted. ------------------------ Begin file FPC.DOC ------------------------ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; FPC (floating point compiler) Common Lisp Alpha Test version 1.0 ;;; copyright (c) Erann Gat 1989 - all rights reserved ;;; Latest revision: 16 November 1989 ;;; ;;; Please send bug reports and comments to: ;;; Erann Gat ;;; JPL MS 301-440 ;;; 4800 Oak Grove Drive ;;; Pasadena, CA 91109 ;;; (818) 354-4203 ;;; get@robotics.jpl.nasa.gov ;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; This program is a floating point accelerator for Allegro Common Lisp. ;;; It compiles floating point expressions into 68881 code and builds a LISP ;;; interface to this code. (FPC requires a coprocessor.) ;;; ;;; There are three ways to use it. There are two top-level definition ;;; forms, FPC-DEFUN and FPC-DEFUN-DESTRUCTIVE. The syntax for these is: ;;; ;;; (FPC-DEFUN (name &rest args) expression) ;;; (FPC-DEFUN-DESTRUCTIVE (name &rest args) expression) ;;; ;;; The expression must be a legal floating point expression. Destructive ;;; floating point operations store their result in their first argument. ;;; (They also return their result.) Destructive functions run a bit faster ;;; because they don't have to cons up a new float. IMPORTANT: Read the warning ;;; below before using destructive floating point operations! ;;; ;;; The third way to use FPC is by means of the FPC-INLINE macro. The syntax ;;; for FPC-INLINE is: ;;; ;;; (FPC-INLINE expression) ;;; ;;; FPC-INLINE compiles EXPRESSION and replaces the expression with a call to ;;; the compiled version. ;;; ;;; Because of the overhead associated with function calls and copying ;;; floating point numbers, expressions compiled with FPC-DEFUN and FPC-INLINE ;;; will not realize any speedup unless the expression involves at least two ;;; floating point operations. FPC-DEFUN-DESTRUCTIVE will realize aboout a 30% ;;; speedup for a single floating-point operation. The more operations are ;;; contained in a compiled expression, the greater the speedup. ;;; ;;; The following functions are currently implemented: +, -, *, /, sin, ;;; cos, tan, asin, acos, atan, sinh, cosh, tanh, atanh, exp, exp2, exp10, ;;; log, log2, log10, abs, mod, and sqrt. ;;; ;;; FPC stores code on the MAC heap, and therefore will not work with DUMPLISP. ;;; ;;; NOTE: FPC has only been tested on MacIntosh Allego Common Lisp version ;;; 1.2.2 and 1.3. It makes use of a number of undocumented features and makes ;;; unwarranted assumptions about the behavior of the compiler. There is ;;; therefore a very high probability that it will not work in other ;;; versions of MACL. Be careful. ;;; ;;; ;;; WARNING!!! WARNING!!! WARNING!!! WARNING!!! ;;; ;;; FPC achieves its speedup by messing with the innerds of compiled functions ;;; and doing no type checking whatsoever. If a function defined with FPC-DEFUN ;;; is passed a value which is not a float it will yield random results and ;;; possibly crash the machine. If a function defined with FPC-DEFUN-DESTRUCTIVE ;;; is passed a non-float or a constant as its first argument the system will ;;; almost certainly crash (but not necessarily right away, and not necessarily ;;; while Lisp is running. This problem should be fixed in the next release.) ;;; FPC has also been known to cause randon crashes on machines with a 68882 ;;; coprocessor (e.g. the MacII-CX). The cause for this is not yet known. ;;; (If you figure it out, please tell me!) ;;; ;;; USE FPC WITH EXTREME CAUTION!!! THIS PROGRAM IS A PROTOTYPE ;;; AND IS NOT FULLY DEBUGGED!!! #| An example: load FPC and evaluate the following forms in order: (setq x 1.2) (setq y 3.4) (setq result 0.0) (fpc-defun fpc* (x y) (* x y)) (fpc-defun-destructive fpc*! (result x y) (* x y)) (fpc-defun fpc-hypotenuse (x y) (sqrt (+ (* x x) (* y y)))) (fpc-defun-destructive fpc-hypotenuse! (result x y) (sqrt (+ (* x x) (* y y)))) (defun hypotenuse (x y) (sqrt (+ (* x x) (* y y)))) (defmacro bench (&rest body) `(lisp:time (lisp:dotimes (i 10000) ,@body))) (bench (* x y)) (bench (fpc* x y)) (bench (fpc*! result x y)) (bench (hypotenuse x y)) (bench (fpc-hypotenuse x y)) (bench (fpc-hypotenuse! result x y)) (bench (sqrt (+ (* x x) (* y y)))) (bench (fpc-inline (sqrt (+ (* x x) (* y y))))) The above example produced the following output on a Mac II: (DOTIMES (I 10000) (* X Y)) took 62 ticks (1.033 seconds) to run. (DOTIMES (I 10000) (FPC* X Y)) took 71 ticks (1.183 seconds) to run. (DOTIMES (I 10000) (FPC*! RESULT X Y)) took 51 ticks (0.850 seconds) to run. (DOTIMES (I 10000) (HYPOTENUSE X Y)) took 276 ticks (4.600 seconds) to run. (DOTIMES (I 10000) (FPC-HYPOTENUSE X Y)) took 87 ticks (1.450 seconds) to run. (DOTIMES (I 10000) (FPC-HYPOTENUSE! RESULT X Y)) took 56 ticks (0.933 seconds) to run. (DOTIMES (I 10000) (SQRT (+ (* X X) (* Y Y)))) took 274 ticks (4.567 seconds) to run. (DOTIMES (I 10000) (FPC-INLINE (SQRT (+ (* X X) (* Y Y))))) took 72 ticks (1.200 seconds) to run. |# --------------------- Begin file FPC.FASL --------------------- (This file must be converted with BinHex 4.0)

- Prev by Date:
**cell-select on exist** - Next by Date:
**Re: Faster image processing on the Mac** - Previous by thread:
**cell-select on exist** - Next by thread:
**FPC** - Index(es):