[gambit-list] Are flonums passed around within Gambit by value or reference? What's their bit width on 32 & 64bir archs?

Guillaume Cartier gcartier at jazzscheme.org
Tue Nov 13 12:30:27 EST 2012


Bradley's answer is correct in saying that Gambit's floats are boxed values
but...

Gambit also supports a very clever mechanism where floats accessed in the
same basic block (a block of code with no branching if my understanding is
correct) are kept and manipulated as unboxed values and only boxed when
they go out of the basic block scope. This feature is key to enable
efficient floating point computation using Gambit.

For example, the following code should generate code equivalent to C code:

(define (foo a b)
  (let ((x (##fl+ a b)))
    (let ((y (##fl* x x)))
      (let ((result (##fl+ x y)))
        result))))

where 'a' and 'b' are unboxed upon function entry, and 'result' is boxed
upon function return.

Guillaume

On Tue, Nov 13, 2012 at 11:10 AM, Bradley Lucier <lucier at math.purdue.edu>wrote:

> On 11/13/2012 11:01 AM, Mikael wrote:
> > Dear Marc,
> >
> > Something I was curious about for long:
> >
> > So fixnums are passed around in Gambit by value and all objects like
> > closures, pairs, vectors and bignums are passed around by reference.
>
> The objects that are boxed are listed in gambit.h:
>
>   * ___sVECTOR       = tag for vectors
>   * ___sPAIR         = tag for pairs
>   * ___sRATNUM       = tag for ratnums
>   * ___sCPXNUM       = tag for cpxnums
>   * ___sSTRUCTURE    = tag for structures
>   * ___sBOXVALUES    = tag for box and multiple-values objects
>   * ___sMEROON       = tag for Meroon objects
>   * ___sJAZZ         = tag for Jazz objects
>   * ___sSYMBOL       = tag for symbols
>   * ___sKEYWORD      = tag for keywords
>   * ___sFRAME        = tag for continuation frames
>   * ___sCONTINUATION = tag for continuations
>   * ___sPROMISE      = tag for promises
>   * ___sWEAK         = tag for weak objects (wills and GC hash tables)
>   * ___sPROCEDURE    = tag for procedures
>   * ___sRETURN       = tag for returns
>   * ___sFOREIGN      = tag for foreign data
>   * ___sSTRING       = tag for strings
>   * ___sS8VECTOR     = tag for 8-bit signed integer vectors
>   * ___sU8VECTOR     = tag for 8-bit unsigned integer vectors
>   * ___sS16VECTOR    = tag for 16-bit signed integer vectors
>   * ___sU16VECTOR    = tag for 16-bit unsigned integer vectors
>   * ___sS32VECTOR    = tag for 32-bit signed integer vectors
>   * ___sU32VECTOR    = tag for 32-bit unsigned integer vectors
>   * ___sF32VECTOR    = tag for 32-bit floating point number vectors
>   * ___sS64VECTOR    = tag for 64-bit signed integer vectors
>   * ___sU64VECTOR    = tag for 64-bit unsigned integer vectors
>   * ___sF64VECTOR    = tag for 64-bit floating point number vectors
>   * ___sFLONUM       = tag for flonums
>   * ___sBIGNUM       = tag for bignums
>
>
> >
> > What about flonums?
> >
> >
> > Also, what's the flonum bit width (exponent & fraction respectively)
> > on 32 and 64bit architecture
>
> 32-bit and 64-bit architectures both use 64-bit IEEE arithmetic. (At
> least, on an architecture where this doesn't happen, some things will be
> computed incorrectly.) That's binary64 in the following table:
>
> https://en.wikipedia.org/wiki/IEEE_floating_point#Basic_formats
>
> >
> > Thanks,
> > Mikael
> >
> >
> >
> > _______________________________________________
> > Gambit-list mailing list
> > Gambit-list at iro.umontreal.ca
> > https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20121113/b4e6c17b/attachment.htm>


More information about the Gambit-list mailing list