[m-dev.] for review: passing boxed floats to pragma C code

Fergus Henderson fjh at cs.mu.OZ.AU
Sun Jan 2 17:53:50 AEDT 2000


On 31-Dec-1999, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> > Tabling does work for MLDS now.  I just added it ;-)
> 
> How extensively have you tested it?

Nearly as well as most of the other MLDS features have been tested,
which is to say hardly at all ;-)

> >> The complication is quite small; just one extra field for pragma_cs in the
> >> LLDS.
> > 
> > And code to parse it, and to output it, and to process it...
> 
> The code to parse it, and to output it, and to process it, is about a hundred
> lines all up; I would call that small. The code to pass it around is the bulk
> of the diff.

Well, 100 lines is a lot of code if the alternative (using `boxed(float)')
is only about 20 lines of code.

> > What's the performance cost of the work-around using `boxed(float)'?
> > If the compiler does a good job of inlining, that should not have
> > any performance overhead.  (If the compiler does not do a good job
> > of inlining, then we should fix inlining!)
> 
> The real problem is not passing floats vs passing words. The real problem
> is that the passed floats must be stored in the hash table, and the existing
> hash table design requires the hash table elements to be Words. This requires
> boxing the floats again, so that they can be stored, and later compared against
> other floats. Your boxed(float) proposal does not touch on this at all.
> My proposal would have optimized this by reusing the original boxes of the
> floats.

Perhaps you didn't understand my `boxed(float)' proposal.
That proposal would have optimized this in exactly the same way that
your proposal for a new c_code attribute flag would have.
If you give the parameters type `boxed(float)' rather than `float',
then the compiler will pass them boxed rather than unboxed.
That's why the new attribute flag isn't needed: you can achieve
the same effect without extending the language.

> The solution I have now adopted instead is to parameterize the hash table code
> even further, by type, so that instead of one table type, there are three.
> This allows the code to store floats in the hash table in their native format.

That sounds like a fine solution.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list