PDA

View Full Version : GCC 4.2.0 SRA optimization



brewbuck
08-14-2007, 10:18 PM
I'd like to point out that as of version 4.2.0, GCC now supports SRA -- scalar replacement of aggregates. I've been doing some preliminary testing, and seen improvements of up to 30% speed increase for template algorithms that heavily instantiate various simple objects.

Generic programming just got a lot more efficient.

Yet another reason for me to harp my favorite points:

1) Strive to create constructors that have no side effects
2) Hold all data by value whenever possible

Mad_guy
08-15-2007, 04:08 AM
Too bad my GCC hates me. :(


[austin@continuum ~]$ gcc --version | head -1
gcc (GCC) 4.2.1
[austin@continuum ~]$ cat > test.c
int main() { return 42; }
[austin@continuum ~]$ gcc test.c
/usr/lib/gcc/i686-pc-linux-gnu/4.2.1/ld: unrecognized option '--hash-style=both'
/usr/lib/gcc/i686-pc-linux-gnu/4.2.1/ld: use the --help option for usage information
collect2: ld returned 1 exit status
[austin@continuum ~]$
(damn you bleeding edge! damn you!)
gcc3 to the rescue, though.

Seriously though, quite an impressive increase in efficiency I'd say. Mind posting a couple of benchmarks?

CornedBee
08-15-2007, 08:23 AM
Mad_guy, perhaps you need to update your binutils?

Mad_guy
08-15-2007, 08:48 AM
Mad_guy, perhaps you need to update your binutils?

This is what I'm figuring, however, the entire system is up to date.
I've BEEN up to date for a while, I'm fairly religious about not letting updates pile ontop of me.

twomers
08-15-2007, 09:12 AM
Would that make much difference to this thread - http://cboard.cprogramming.com/showthread.php?t=88491 if anyone besides myself can remember.

brewbuck
08-15-2007, 02:09 PM
Too bad my GCC hates me. :(

Looks like your GCC build and binutils are out of sync. This can happen even if you have up-to-date binutils, if you installed a GCC binary that was compiled against some other version of binutils. Did you compile 4.2.1 yourself, or install from binary?

You can work around it for now by using an older GCC for the linking step. You can still compile with 4.2.1.

Best thing, though, is probably to compile your own 4.2.1 build. The GCC build process has become much easier to handle lately. It can take a while, though.

brewbuck
08-15-2007, 02:10 PM
Would that make much difference to this thread - http://cboard.cprogramming.com/showthread.php?t=88491 if anyone besides myself can remember.

I'm still getting my grips on the behavior of GCC 4.2.x so I couldn't really say for certain. Best thing is to try it and see!

twomers
08-16-2007, 03:21 AM
Believe me I would but it's slightly awkward at the moment.

Mad_guy
08-16-2007, 08:47 AM
Looks like your GCC build and binutils are out of sync. This can happen even if you have up-to-date binutils, if you installed a GCC binary that was compiled against some other version of binutils. Did you compile 4.2.1 yourself, or install from binary?

You can work around it for now by using an older GCC for the linking step. You can still compile with 4.2.1.

Best thing, though, is probably to compile your own 4.2.1 build. The GCC build process has become much easier to handle lately. It can take a while, though.

I installed from binary however, the problem was solved as GCC was calling out to a version of ld that was out of date (how ld got in that particular location, I have no idea.) It simply involved deleting that version of ld in that directory. :)