chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] csc: unsafe unboxing and f64vectors on amd64?


From: Jeronimo Pellegrini
Subject: [Chicken-users] csc: unsafe unboxing and f64vectors on amd64?
Date: Wed, 17 Feb 2010 23:52:23 -0200
User-agent: Mutt/1.5.20 (2009-06-14)

Hi,

The manpage for csc (and also the manual [0]) mentions this option:

-optimize-level 4          is equivalent to -optimize-leaf-routines -local 
-inline -unsafe


But looking at chicken.scm at git experimental/HEAD, it seems that -O4 and -O5 
also turn
on unboxing:

[(4)
   (set! options
     (cons* 'optimize-leaf-routines 'inline 'local 'unboxing 'unsafe
             options) ) ]

Good -- I've been looking for that :-)  So, I started playing with it and got
segfaults... I've found why:

This program:

/--- srfi4-test.scm ---
(use srfi-4)

(let ((v (make-f64vector 4)))
  (print v)
  (f64vector-set! v 3 (exact->inexact 10))
  (print v))
\----------------------

Behaves differently with and without the combination of unboxing and unsafe.

$ csc  srfi4-test.scm -o srfi4-test
#f64(-6.95040154098792e-310 6.95322012238471e-310 6.9532201223776e-310 
6.9532201223859e-310)
#f64(-6.95040154098792e-310 6.95322012238471e-310 6.9532201223776e-310 10.0)
                                                                       ^^^^
OK, element of index 3 (the fourth one) was set to 10.0.

Now,

$ csc  -unboxing -unsafe srfi4-test.scm -o srfi4-test
#f64(6.92800592446958e-310 1.08694442085074e-322 6.95323789418212e-310 
6.95323789956941e-310)
#f64(6.92800592446958e-310 10.0 6.95323789418212e-310 6.95323789956941e-310)
                           ^^^^

Aha -- with unboxing and unsafe, the index passed to f64vector-set (3) is 
interpreted
differently (3 x 32-bit word, that when aligned ends up being the address of 
the second
element, and not the fourth).

OK, no problem, I can multiply that by 2. But then it won't work without 
unsafe-unboxing.

Is there a way around this? Like, a predicate that I can use to tell if I'm 
using
-unsafe and -unboxing?

I'm using a 64 bit machine (amd64/Linux).

Thanks!
J.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]