It is currently Fri Oct 19, 2018 5:51 am Advanced search

g++ optimizations from custom makefiles (-funroll-loops)

Code won't compile? Found a bug? Post here!

g++ optimizations from custom makefiles (-funroll-loops)

Postby zugzug » Tue Feb 09, 2010 8:42 pm

Will this contest support custom makefiles, or at least more aggresive compiler optimizations, like -funroll-loops?

I've been testing my code, and see more than 50% increase in speed for my worst case move calculations, when it is compiled with :
g++ -c -O3 -funroll-loops

vs what is being used by default right now:
g++ -c -O2

This optimization is the difference between successfully calculating a move in under 1s in a worst case scenario, or going over the time limit and being disqualified for my best performing bot.
zugzug
Cadet
 
Posts: 2
Joined: Tue Feb 09, 2010 8:31 pm

Re: g++ optimizations from custom makefiles (-funroll-loops)

Postby amstan » Sat Feb 13, 2010 11:05 pm

I'm sorry we do not follow makefiles on compilation for security reasons.
Our gcc uses only -O2
Alexandru M. Stan
Contest Organizer
User avatar
amstan
Contest Organizer
 
Posts: 691
Joined: Sun Jan 31, 2010 4:02 am
Location: Stoney Creek, Ontario

Re: g++ optimizations from custom makefiles (-funroll-loops)

Postby montanalow » Thu Feb 18, 2010 10:42 pm

For those of us who have tested -O3 locally, and would like to use it in competition, what about creating a new "language" definition for MyTronBot.cpp, instead of .cc, that uses:
g++ -c -O3 MyTronBot.cpp
montanalow
Lieutenant-Colonel
 
Posts: 42
Joined: Thu Feb 18, 2010 6:50 pm

Re: g++ optimizations from custom makefiles (-funroll-loops)

Postby ebrahim » Thu Feb 18, 2010 11:19 pm

If you decided to do it, please also add -funroll-loops.
I think even you can enable profile-guided optimization through --profile-use. So I can include my profiling info in uploaded ZIP file, and GCC will use it for optimizing.
ebrahim
Lieutenant-Colonel
 
Posts: 49
Joined: Mon Feb 08, 2010 7:03 pm

Re: g++ optimizations from custom makefiles (-funroll-loops)

Postby montanalow » Fri Feb 19, 2010 1:04 am

"g++ -03 -fprofile-use" results in a 4x speed up over -O2 for me.

-funroll-loops is redundant when -fprofile-use is used, since -fprofile-use implies -funroll-loops.

I think these optimizations are "fair", since several modern vm's (at least java and python, I'm not familiar enough with the rest) do these sort of profiling optimizations during run time. Since c++ code is not run in a vm, it never has a chance to undergo this sort of profiled optimization, except at compile time.
montanalow
Lieutenant-Colonel
 
Posts: 42
Joined: Thu Feb 18, 2010 6:50 pm

Re: g++ optimizations from custom makefiles (-funroll-loops)

Postby jeff.cameron » Fri Feb 19, 2010 2:38 am

I don't see why not. Let's give it a try.

Hold on to your hats... C++ is getting FAAAAASTER!
jeff.cameron
Contest Organizer
 
Posts: 91
Joined: Sun Jan 31, 2010 4:06 am

Re: g++ optimizations from custom makefiles (-funroll-loops)

Postby montanalow » Fri Feb 19, 2010 3:14 am

Just to be clear, -funroll-loops may not be faster for everyones c++ code, and the same goes for -O3 in general. But for small programs, with lots of short loops, they are a big win!

In case anyone else is interested, I have lots of loops like:
for( direction i = north; i <= west; ++i ) { check(i); }

-funroll-loops enables gcc to eliminate the loop altogether, and turn it into:

check(north);
check(east);
check(south);
check(west);

on the other hand, if someone has:
for( int i = 0; i < 1000000; ++i ) { united_nations_inspector( i ).inspect( ebrahims_tech ); }
-funroll_loops is probably gonna hurt, bad.
montanalow
Lieutenant-Colonel
 
Posts: 42
Joined: Thu Feb 18, 2010 6:50 pm


Return to Technical Issues

Who is online

Users browsing this forum: No registered users and 1 guest

cron