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

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Dec 31 03:40:35 AEDT 1999


On 30-Dec-1999, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> > Is that case really worth optimizing?
> > It seems to me that tabling of floats would probably be fairly rare.
> 
> Any tabled predicate at presents incurs the overhead of one call to GC_malloc
> per float output. This is a small number of predicates, but the relative
> overhead is quite high.
> 
> > Given that this feature is easy to simulate in this manner,
> > and that the need for it is rare (after all, the word_to_float()
> > and float_to_word() macros are not part of the documented interface,
> > so they can only be used within the Mercury implementation),
> > I'm not convinced that it would be worth complicating the C code
> > interface with this feature.
> 
> 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...

> I was not proposing to document the new attribute, so it is no
> complication at all for users, and I was not proposing changing the MLDS.

Well, the MLDS back-end would require changes to handle the new attribute.

> The benefit is improved performance on benchmarks. Your proposed workarounds 
> all have performance costs of their own, so they are not suitable replacements.

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!)

> > For the MLDS back-end, we pass float arguments unboxed.
> > So in many cases, this would not gain anything.
> 
> Since tabling does not work for MLDS, this point is moot.

Tabling does work for MLDS now.  I just added it ;-)
There were only a couple of very minor things needed.
It was easier to just implement them than to explain
how easy they would be to implement.

> > For the LLDS back-end, our long-term plan was also to eventually
> > pass float arguments unboxed, in separate floating point registers.
> > That now appears unlikely, since in the long term we will probably
> > shift our focus from the LLDS back-end to the MLDS back-end.
> 
> Exactly. In the meantime, however, we get better benchmark numbers.

I think you should be able to get the same benchmark numbers
using the `boxed(float)' work-around.

-- 
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