[racket-dev] extflonum unboxing, f80vector ffi

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Fri Feb 15 14:39:47 EST 2013

Merged - thanks!

I'm not certain why the example below didn't work for you, but I think
it had to do with shuffling unboxed arguments to `loop'. Please check
whether the current version works; it now works for me.

There was a mismatch in the order that unboxed arguments are gathered
for the call and the order that they're expected, and that mismatch
made shuffling the arguments complex. Now, unboxed arguments are
accumulated directly to the right order in memory, and
generate_fp_argument_shuffle() is replaced by a simple
generate_fp_argument_shift().

At Fri, 15 Feb 2013 13:44:38 +0300, Michael Filonenko wrote:
> Hi all.
> 
> This time I use the github pull requesting tool, which is more
> comfortable for annotation, I think.
> 
> The following merge request https://github.com/plt/racket/pull/245 contains:
> 
>   * small fixes for extflonum arithmetic: two functions were not jitted.
>   * experimental extflonum unboxing
>   * f80vector type for ffi (sorry, not documented yet)
> 
> I used the extfl flag and therefore did much less copypaste than previous time.
> 
> Unfortunately the extflonum unboxing is not stable and is disabled by default.
> You can uncomment USE_EXTFLONUM_UNBOXING definition in jit.h to turn
> on extfl unboxing.
> 
> The following test case fails all the time:
> 
>   (require racket/unsafe/ops)
> 
>   (let ()
>     (define f (lambda (x)
>                 (collect-garbage)
>                 (let loop ([a 0.0t0][v 0.0t0][n 1000])
>                   (if (zero? n)
>                       v
>                       (if (odd? n)
>                           (let ([b (unsafe-extfl+ a a)])
>                             (loop b v (sub1 n)))
>                           ;; First arg is un place, but may need re-boxing
>                           (loop a
>                                 (unsafe-extfl+ v x)
>                                 (- n 1)))))))
>     (let ((res (f 1.0t0)))
>       (when (not (equal? res 500.0t0))
>         (printf "error extfl ~a~%" res))))
> 
> If the (collect-garbage) call is removed, then the test can pass (or not).
> My hypothesis is that the gc collects unboxed extflonums as garbage,
> which pollutes the memory and breaks further calculations.
> 
> Other than that, I ran out of ideas. I continue exploring the gc,
> but an advice would be of great help. How do you think, what other
> reason could it be?
> 
> 
> --
> With best regards, Michael Filonenko
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev

Posted on the dev mailing list.