From: Waldek Hebisch <hebisch@ma...>  20090902 02:03:23

The following file at safety 0 in 64bit sbcl produces inline code (with no function calls in inner loop). However, in ecl operations are done via function calls. If I replace types with specified accuracy by fixnum array access, addition and multiplication is done via inline code. However, I would like to avoid overhead for untagging values and extra space taken by fixnums on 64bit machines. Also, fixnum accuracy on 32bit machines is too low, so I have to specify 64bit type. I wonder how much effort it would take to generate inline code for 32bit and 64bit types. I looked at sysfun.lsp and it seems that before defining inline I need a correct "representation types". Remark: For the specific code I could probably put all code in a single C inline. But I would like to compose several similar functions using macros... <cut here> ;;; (proclaim '(optimize (speed 3) (safety 0))) ;;; Vectors of 32bit numbers (defmacro ELT32(v i) `(aref (the (simplearray (unsignedbyte 32) (*)) ,v) ,i)) ;;; (x*y + z) using 32bit x and y and 64bit z and assuming that ;;; intermediate results fits into 64 bits (defmacro QSMULADD6432 (x y z) `(the (unsignedbyte 64) (+ (the (unsignedbyte 64) (* (the (unsignedbyte 32) ,x) (the (unsignedbyte 32) ,y))) (the (unsignedbyte 64) ,z)))) (defmacro QSMUL6432 (x y) `(the (unsignedbyte 64) (* (the (unsignedbyte 32) ,x) (the (unsignedbyte 32) ,y)))) (defmacro QSMOD6432 (x p) `(the (unsignedbyte 32) (rem (the (unsignedbyte 64) ,x) (the (unsignedbyte 32) ,p)))) (defmacro QSPLUS (x y) `(the fixnum (+ (the fixnum ,x) (the fixnum ,y)))) (defmacro QMODDOT0 (eltfun varg1 varg2 ind1 ind2 kk s0 p) `(let ((s ,s0) (v1 ,varg1) (v2 ,varg2) (i1 ,ind1) (i2 ,ind2) (k0 ,kk) (k 0)) (declare (type (unsignedbyte 64) s) (type fixnum i1 i2 k k0)) (prog () l1 (if (>= k k0) (return (QSMOD6432 s ,p))) (setf s (QSMULADD6432 (,eltfun v1 (QSPLUS i1 k)) (,eltfun v2 (QSPLUS i2 k)) s)) (setf k (QSPLUS k 1)) (go l1)))) (defmacro QMODDOT32 (v1 v2 ind1 ind2 kk s0 p) `(QMODDOT0 ELT32 ,v1 ,v2 ,ind1 ,ind2 ,kk ,s0 ,p)) (defun myDot (v1 v2 ind1 ind2 kk s0 p) (QMODDOT32 v1 v2 ind1 ind2 kk s0 p)) <cut here>  Waldek Hebisch hebisch@... 