Hi,
When compiling a function, I get this strange error message:
; in: DEFUN UMFPACK-SOLVE ; (CFFI-SYS:NULL-POINTER) ; ; note: *INLINE-EXPANSION-LIMIT* (200) was exceeded, probably trying to ; inline a recursive function.
The code looks like this, it is in my cl-sparsematrix package (asdf-installable), cffi version is 20080217, using SBCL 1.0.16.0. The code looks like below, I tried to come up with a smaller example but couldn't (does not happen in one-liners using null-pointer). null-pointer does not look recursive to me... umfpack-catch-error is a macro. If there is something obvious I am doing wrong, please let me know, if not, helpful hints on how to determine what is going on are welcome.
(defun umfpack-solve (a-csc b &optional (symbolic (umfpack-symbolic a-csc))) "Use umfpack-solve to solve the sparse system A x = b, where a-csc is A packed in csc format. If you are solving many systems of the same shape, you should precalculate the symbolic object and supply it for a minor increase in speed." (with-slots (nrow ncol ap ai ax) a-csc (assert (= nrow ncol)) ; need square matrix (let ((x (make-ffa nrow :double))) ; Ax=b (with-slots ((symbolic-pointer pointer)) symbolic (with-pointers-to-arrays ((ap ap-pointer :uint32 (length ap) :copy-in) (ai ai-pointer :uint32 (length ai) :copy-in) (ax ax-pointer :double (length ax) :copy-in) (x x-pointer :double (length x) :copy-out) (b b-pointer :double (length b) :copy-in)) (with-foreign-pointer (numeric-goes-here (foreign-type-size :pointer)) ;; calculate Numeric object (format t "umfpack: calculating numeric object~%") (umfpack-catch-error (umfpack_di_numeric ap-pointer ai-pointer ax-pointer symbolic-pointer numeric-goes-here (null-pointer) (null-pointer))) ;; solve system (format t "umfpack: solving system~%") (umfpack-catch-error (umfpack_di_solve 0 ap-pointer ai-pointer ax-pointer x-pointer b-pointer (mem-ref numeric-goes-here :pointer) (null-pointer) (null-pointer)))) ;; return x x))))))
Thanks,
Tamas
Hello Tamas,
On Sun, May 18, 2008 at 7:42 PM, Tamas K Papp tpapp@princeton.edu wrote:
When compiling a function, I get this strange error message:
; in: DEFUN UMFPACK-SOLVE ; (CFFI-SYS:NULL-POINTER) ; ; note: *INLINE-EXPANSION-LIMIT* (200) was exceeded, probably trying to ; inline a recursive function.
The code looks like this, it is in my cl-sparsematrix package (asdf-installable), cffi version is 20080217, using SBCL 1.0.16.0. The code looks like below, I tried to come up with a smaller example but couldn't (does not happen in one-liners using null-pointer). null-pointer does not look recursive to me... umfpack-catch-error is a macro. If there is something obvious I am doing wrong, please let me know, if not, helpful hints on how to determine what is going on are welcome.
Here's a smaller example:
(defun foo () (list . #.(loop repeat 200 collect '(cffi:null-pointer))))
Or, without CFFI:
(declaim (inline a)) (defun a () 0) (defun b () (list . #.(loop repeat 200 collect '(a))))
Notice that what you're getting is just a compiler note saying that it has decided to not inline any more functions:
CL-USER> (describe '*inline-expansion-limit*) *INLINE-EXPANSION-LIMIT* is an external symbol in #<PACKAGE "SB-EXT">. It is a special variable; its value is 200. Special documentation: an upper limit on the number of inline function calls that will be expanded in any given code object (single function or block compilation)
So, I suppose that's what's going on with your code. You could probably avoid that note by adding a (declare (notinline null-pointer)) or binding *INLINE-EXPANSION-LIMIT* to a bigger number while building your library. However, 200 inline expansions in one function does seem like a lot at first sight; perhaps you should investigate why that's happening.
HTH.
On Thu, May 22, 2008 at 2:59 AM, Luís Oliveira luismbo@gmail.com wrote:
However, 200 inline expansions in one function does seem like a lot at first sight; perhaps you should investigate why that's happening.
Your WITH-POINTER-TO-ARRAYS macro seems to be the culprit. It has a big expansion containing at least 31 inlineable calls to INC-POINTER, 31 to FOREIGN-FREE, 31 to %FOREIGN-ALLOC and for some reason its body is repeated 32 times. Since you have NULL-POINTER twice in your body, I count 157 inlineable calls so far. That's pretty close to the 200 limit and I'm sure there are other calls I'm missing.
In case it helps, I used SB-CLTL2:MACROEXPAND-ALL and the function below to figure out those numbers.
(defun tree-count (x tree) (loop for el in tree sum (if (atom el) (if (eql el x) 1 0) (tree-count x el))))