[Patch, Fortran, OOP] PR 50960: vtables not marked as constant

Tobias Burnus burnus@net-b.de
Mon Nov 14 09:24:00 GMT 2011


On 11/13/2011 09:25 AM, Salvatore Filippone wrote:
> Il giorno mer, 09/11/2011 alle 16.34 +0100, Janus Weil ha scritto:
>> Still, I'm curious to see whether it will have any effect. (Of course,
>> seeing a difference in performance between 4.6 and current trunk does
>> not necessarily mean that this is due to the constant vtables.)
> Indeed, if anything, the 4.7 code is slightly slower than 4.6.2 (tried
> on two different AMD and an Intel Core2), about 1-2 %.
> Of course, having used a rather complex example, there's no way to
> isolate the vtable contribution, nor do I have any idea of what other
> changes might have an effect. As Janus pointed out, I do not currently
> have any non-overridable routines in psblas/mld2p4.

As Janus already mentioned, we have two recent optimizations:
- With NON_OVERRIDABLE, we directly call the function without using a 
vtable. This optimization is always effective.
- By marking the vtable as readonly, also without non_overridable 
several optimizations are possible. The optimizations are probably only 
effective for a single file or if you use link-time optimization (LTO). 
For the latter, compile *and* link with -flto. If libraries are 
involved: LTO is only effective for static libraries (.a) and only if 
the linker plugin is used.

Regarding the performance regression: Which flags do you use for 
compilation? Safe and fast options would be "-O2 -march=native 
-fstack-arrays -funroll-loops"; for benchmarks, you could use "-Ofast 
-march-native -funroll-loops". As -Ofast implies -ffast-math 
-fno-protect-parens, it might do "unsafe" optimizations. For some 
programs, also "-flto" helps a lot. Additionally, the inline-limit of 
GCC is often too low for Fortran programs, use e.g. -finline-limit=600 
to increase it. To reduce the filesize (and add very few additional 
optimizations), you could also link with -fwhole-program.

For details to the options, see the "gcc" manual (for -fstack-arrays: 
The 4.7 release notes or the "gfortran" manual.)

Tobias



More information about the Fortran mailing list