Boost logo

Boost :

From: hervebronnimann_at_[hidden]
Date: 2008-05-22 18:13:29


I have to react to this. There is something called aliasing that prevent compilers to optimize, and passing builtins by const ref is generally NOT a good idea performance wise.

There is something called the const-forwarding type that resolves to value for built-ins and const refs for UDT that might be useful here.

Finally, something that no one seems to be concerned about in this thread, is the cost of all these templates in terms of byte object code. In such a low-level header, you can expect all these templates to end up in every UoR in your libraries, linked together into an executable. Keeping positive_ and negative_ out of your template names is going to save that many bytes in your object. You may think its nothing. I've seen placeholders (_1 to _10) defined as static const Placeholder<N> take up to .5M for essentially nothing (it's an empty class!) We saved that .5MB by declaring them extern, as is done in Boost. So the rule is: keep it as simple and short as possible while remaining readable code.

Sent via BlackBerry from T-Mobile

-----Original Message-----
From: "Simonson, Lucanus J" <lucanus.j.simonson_at_[hidden]>

Date: Thu, 22 May 2008 12:49:41
To:boost_at_[hidden]
Subject: Re: [boost] [math] pow redux and observations


John Moeller wrote:
>One more thing. The argument is passed by value, which is ok for
builtins.
>Will all those potentially excess temporaries be an issue for larger
UDTs?
>Perhaps the argument type of result() should be wrapped so that it's a
>const
>reference if it's larger than a pointer.

It may be best to simply pass all arguments types by const reference in
this instance. When instantiated then inlined the function call
overhead related to making temp-copy of the argument doesn't need to be
stripped away by the compiler during subsequent optimization, which can
make it easier for the compiler to identify that it is a good idea to
inline the function in the first place. There is no real draw back to
passing a built in type by const reference, particularly if your
intention is for the compiler to inline the function anyway.

Luke
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk