GCC -Ofast

Code, algorithms, languages, construction...
Post Reply
User avatar
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

GCC -Ofast

Post by kingliveson » Thu Mar 31, 2011 2:05 pm

According to released document:

Code: Select all

-Ofast
Disregard strict standards compliance. ‘-Ofast’ enables all ‘-O3’ optimizations.
It also enables optimizations that are not valid for all standard compliant pro-
grams. It turns on ‘-ffast-math’.

Code: Select all

-ffast-math
Sets ‘-fno-math-errno’, ‘-funsafe-math-optimizations’, ‘-ffinite-math-only’,
‘-fno-rounding-math’, ‘-fno-signaling-nans’ and ‘-fcx-limited-range’.
This option causes the preprocessor macro __FAST_MATH__ to be defined.
Is there an advantage over -O3 for chess engines and what's wrong with the following combination?

-Ofast -fstrict-aliasing -fomit-frame-pointer -fno-exceptions -ffp-contract=fast \
-fkeep-static-consts -fmodulo-sched -fmodulo-sched-allow-regmoves -fgcse-las \
-fgcse-after-reload -fdce -fdse -fira-loop-pressure -fschedule-insns2 \
-fsched-pressure -fsched-spec-load -fsched2-use-superblocks \
-fipa-pta -fbranch-probabilities -fwhole-program -flto \
-fprofile-generate
PAWN : Knight >> Bishop >> Rook >>Queen

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: GCC -Ofast

Post by hyatt » Thu Mar 31, 2011 9:51 pm

It will vary by program, and by gcc version, and by processor type. Try the options and compare the NPS speeds. Choose the options that lead to the highest NPS and you can't go wrong...

orgfert
Posts: 183
Joined: Fri Jun 11, 2010 5:35 pm
Real Name: Mark Tapley

Re: GCC -Ofast

Post by orgfert » Sat Apr 02, 2011 4:08 am

hyatt wrote:It will vary by program, and by gcc version, and by processor type. Try the options and compare the NPS speeds. Choose the options that lead to the highest NPS and you can't go wrong...
Shouldn't we go by best time-to-ply?

User avatar
Bo Persson
Posts: 14
Joined: Thu Jun 10, 2010 10:34 am
Real Name: Bo Persson
Location: Malmö, Sweden

Re: GCC -Ofast

Post by Bo Persson » Sat Apr 02, 2011 1:03 pm

kingliveson wrote:

Code: Select all

-ffast-math
Sets ‘-fno-math-errno’, ‘-funsafe-math-optimizations’, ‘-ffinite-math-only’,
‘-fno-rounding-math’, ‘-fno-signaling-nans’ and ‘-fcx-limited-range’.
This option causes the preprocessor macro __FAST_MATH__ to be defined.
Those seems to be floating point options. Probably not useful for a chess program.

User avatar
kingliveson
Posts: 1388
Joined: Thu Jun 10, 2010 1:22 am
Real Name: Franklin Titus
Location: 28°32'1"N 81°22'33"W

Re: GCC -Ofast

Post by kingliveson » Sat Apr 02, 2011 1:29 pm

hyatt wrote:It will vary by program, and by gcc version, and by processor type. Try the options and compare the NPS speeds. Choose the options that lead to the highest NPS and you can't go wrong...
I might get a chance to do some benchmarks later on today in combination with the other flags to see.
orgfert wrote:
hyatt wrote:It will vary by program, and by gcc version, and by processor type. Try the options and compare the NPS speeds. Choose the options that lead to the highest NPS and you can't go wrong...
Shouldn't we go by best time-to-ply?
Wouldnt best NPS for the program give better time-to-ply?
Bo Persson wrote:
kingliveson wrote:

Code: Select all

-ffast-math
Sets ‘-fno-math-errno’, ‘-funsafe-math-optimizations’, ‘-ffinite-math-only’,
‘-fno-rounding-math’, ‘-fno-signaling-nans’ and ‘-fcx-limited-range’.
This option causes the preprocessor macro __FAST_MATH__ to be defined.
Those seems to be floating point options. Probably not useful for a chess program.
Aha, this is what I was looking for specifically regarding '-Ofast'.
PAWN : Knight >> Bishop >> Rook >>Queen

hyatt
Posts: 1242
Joined: Thu Jun 10, 2010 2:13 am
Real Name: Bob Hyatt (Robert M. Hyatt)
Location: University of Alabama at Birmingham
Contact:

Re: GCC -Ofast

Post by hyatt » Sun Apr 03, 2011 5:40 am

orgfert wrote:
hyatt wrote:It will vary by program, and by gcc version, and by processor type. Try the options and compare the NPS speeds. Choose the options that lead to the highest NPS and you can't go wrong...
Shouldn't we go by best time-to-ply?
That will be exactly the same measurement. Since you are not changing the search tree shape at all (assuming the program has no bugs where the optimizer can change the tree in odd ways when you have uninitialized data) time-to-ply or nps are going to be exactly proportional...

To reduce the time-to-ply by 10% you have to increase the NPS by 10%.

Post Reply