Segfault while running Gambit; values/receive efficiency
Hi, Well, first of all this segfaults: qp6 napito: ./napito-base.scm Segmentation fault which I guess is a bug. But also, I got a bit carried away trying to remove function calls in matrix multiplication. I'd appreciate some advice - if the code worked, would it be efficient? In particular, do the values/receive pairs get "compiled away"? I hope the code is fairly obvious - I'm trying to unpack a list with contains the non-zero elements from a typical 2D geometric transform and then do the matrix multiplication on a point. Thanks, Andrew
Afficher les réponses par date
I should have added that this is Suse Linux 10.2, amd64 architecture, Gambit Version 4.0 beta 22. Also, problem remains when the receive in nap-join-transforms doesn't have a duplicate value. Andrew
Hi,
Well, first of all this segfaults: qp6 napito: ./napito-base.scm Segmentation fault which I guess is a bug.
But also, I got a bit carried away trying to remove function calls in matrix multiplication. I'd appreciate some advice - if the code worked, would it be efficient? In particular, do the values/receive pairs get "compiled away"?
I hope the code is fairly obvious - I'm trying to unpack a list with contains the non-zero elements from a typical 2D geometric transform and then do the matrix multiplication on a point.
Thanks, Andrew
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
The segfault seems to be caused by a misplaced paren in (define (nap-transform-point transform point) (receive (a b c d e f) (unpack6 transform) (receive (x y) (unpack2 point) (list (dot (row1 a b c d e f) (xyz x y)) (dot (row2 a b c d e f) (xyz x y)))))) (this is the corrected version - the previous code has an additional close at the end of the line with the second receive). I would still appreciate comments on whether this is a reasonable approach. Thanks, Andrew
Hi,
Well, first of all this segfaults: qp6 napito: ./napito-base.scm Segmentation fault which I guess is a bug.
But also, I got a bit carried away trying to remove function calls in matrix multiplication. I'd appreciate some advice - if the code worked, would it be efficient? In particular, do the values/receive pairs get "compiled away"?
I hope the code is fairly obvious - I'm trying to unpack a list with contains the non-zero elements from a typical 2D geometric transform and then do the matrix multiplication on a point.
Thanks, Andrew
_______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
On 18-Aug-07, at 9:13 AM, andrew cooke wrote:
Hi,
Well, first of all this segfaults: qp6 napito: ./napito-base.scm Segmentation fault which I guess is a bug.
Yes it is. The problem is that your code has a syntax error, so the runtime system tries to raise a syntax error exception. Unfortunately there is a bug in this branch when the code was macro expanded, or passed to eval. Anyway, the fix is to replace the line (head (##source-code (##car code))) by (head (##source-code (##sourcify (##car code) src))) in lib/_eval.scm and then rebuild Gambit with a make.
But also, I got a bit carried away trying to remove function calls in matrix multiplication. I'd appreciate some advice - if the code worked, would it be efficient? In particular, do the values/receive pairs get "compiled away"?
No they don't. The call (values 1 2 3) actually creates a vector- like object, tagged as a multiple-value. So the code is the same efficiency as (vector 1 2 3). You'll get much better optimization by using a CPS-style. This is easy in your case: just pass in the consumer of your values as a parameter, i.e. replace (define-syntax row1 (syntax-rules () ((_ a b c d e f) (values a b c)))) (receive (x y z) (row1 1 2 3 4 5 6) (list x y z)) by (define-syntax row1 (syntax-rules () ((_ a b c d e f consumer) (consumer a b c)))) (row1 1 2 3 4 5 6 (lambda (x y z) (list x y z))) I am considering adding a deforestation optimization to the Gambit compiler to eliminate the construction of multiple-values objects (and pairs, vectors, etc) when it is easy. But that's still under development. Marc
[...]
efficiency as (vector 1 2 3). You'll get much better optimization by using a CPS-style. This is easy in your case: just pass in the consumer of your values as a parameter, i.e. replace
doing this and switching to vectors saved over 40% time, thanks. andrew
On 19-Aug-07, at 9:16 PM, andrew cooke wrote:
[...]
efficiency as (vector 1 2 3). You'll get much better optimization by using a CPS-style. This is easy in your case: just pass in the consumer of your values as a parameter, i.e. replace
doing this and switching to vectors saved over 40% time, thanks.
Removing the vectors should save you quite a bit more... Marc
participants (2)
-
andrew cooke -
Marc Feeley