[Dune] Dune on Windows MinGW
Steffen Müthing
steffen.muething at ipvs.uni-stuttgart.de
Wed May 4 16:14:56 CEST 2011
Static functions shouldn't be a performance problem with regard to built-in types,
at least with gcc. Since version 4.3, gcc is capable of evaluating most constant expressions
at compile time (see http://gcc.gnu.org/gcc-4.3/changes.html, General Optimizer Improvements).
The list of supported math functions given there is quite extensive...
As for non-standard types like GMP, I think you will want to specialize for those anyway
as you might have to return a const reference in order to avoid a costly copy constructor
(as far as I know, GMP doesn't do copy-on-write).
Steffen
Am 04.05.2011 um 15:28 schrieb Carsten Gräser:
> Am 04.05.2011 15:01, schrieb Martin Nolte:
>> Hi Jö,
>>
>> I don't have any problem with a static variable -- as long as it is really
>> faster. If Carstens suggestion is correct, the static variable variant might
>> be slower due to an additional if-condition whether the variable has already
>> been initialized.
>>
>> With respect to the specialization: You are right in that this is possible. On
>> the other hand, your approach allows asking for MC< int >::e, which might give
>> a pretty stupid error message. Such points are exactly what needs discussion.
>>
>> But I think there are more important points to be discussed: The names, static
>> methods vs. static variables. These have an impact on code actually asking for
>> these values. For example, I guess we want to change the use of Pi in the DGF
>> parser (and the other places indicated by Bernd) soon. It would be great, if
>> we agreed on an interface before these changes.
>>
>> You are, of course, right that templatized variables generate weak symbols --
>> I indeed overlooked this. Does anyone know why numeric_limits uses static
>> methods over static member variables? For me, this was the inspiration to
>> suggest static methods.
>
> I'd prefer the static methods. For other types where the compiler does
> not optimize the call one could still use a static local member.
>
> Carsten
>
> PS:
> You can check the optimization yourself with the attached example.
>
>
> --
> ----------------------------------------------------------------------
> Carsten Gräser | phone: +49-30 / 838-75349
> Freie Universität Berlin | fax : +49-30 / 838-54977
> Institut für Mathematik | email: graeser at math.fu-berlin.de
> Arnimallee 6 |
> 14195 Berlin, Germany | URL : http://page.mi.fu-berlin.de/graeser
> ----------------------------------------------------------------------
> <compile_time_expressions.cc>_______________________________________________
> Dune mailing list
> Dune at dune-project.org
> http://lists.dune-project.org/mailman/listinfo/dune
Steffen Müthing
Universität Stuttgart
Institut für Parallele und Verteilte Systeme
Universitätsstr. 38
70569 Stuttgart
Tel: +49 711 685 88429
Fax: +49 711 685 88340
Email: steffen.muething at ipvs.uni-stuttgart.de
More information about the Dune
mailing list