Reply
Thread Tools
Posts: 73 | Thanked: 33 times | Joined on Nov 2010
#1
What are the best CFLAGS for the N900, to compile code best optimized for the N900's architecture, running the fastest?

I've seen some presentation of Nokia, which said: "... and don't forget to set CFLAGS XXXXXXXX to take care of XXXXXX" but can't find it...

From what I've searched for and found, I've got:

Code:
-O6 -mcpu=cortex-a8 -mtune=cortex-a8 -fomit-frame-pointer -fsigned-char -mfpu=neon -mfloat-abi=softfp
The -O6 is from some stuff that I read way back, where they were disscussing, -O3 and some guy said why not -O4, to which there were replies like -O4 doesn't even exist in GCC and somebody got to the resolution of -O6 being the best for any given architecture?

I've tried to read the GCC documentation, but got no resolution of anything beyond -O3 existing...

Does it?

And then is there anything I should add to the CFLAGS above, or are these the best custom choice for the N900?
 
Posts: 73 | Thanked: 33 times | Joined on Nov 2010
#2
How about:

Code:
-O6 -mcpu=cortex-a8 -mtune=cortex-a8 -fomit-frame-pointer -fsigned-char -mfpu=neon -mfloat-abi=softfp -march=armv7-a
-mlittle-endian -mfpu=vfpv3 -mfloat-abi=softfp
or is -march=armv7-a-neon better?

Last edited by jj0; 2011-04-03 at 17:58.
 
javispedro's Avatar
Posts: 2,355 | Thanked: 5,249 times | Joined on Jan 2009 @ Barcelona
#3
Best flags usually are:
-O2

With sometimes -Os being better, depending on your application. If it does lots of 32-bit floating point operations, mfpu=neon might also help. Benchmark as necessary

Half of the stuff you're specifying is already the default in scratchbox (mcpu, mtune, fomit-frame-pointer, mfpu=vfpv3, mfloat-abi, mlittle-endian),
the other half is contradictory (mfpu=neon when you also specified mfpu=vfp ?) ,
and some do not exist (O4, O5, O6, ...).

My suggestion is that you use as few flags as possible.

Last edited by javispedro; 2011-04-03 at 18:04.
 

The Following User Says Thank You to javispedro For This Useful Post:
Posts: 73 | Thanked: 33 times | Joined on Nov 2010
#4
Maybe also add?

Code:
-fmessage-length=0 -ftree-vectorize -Os -pipe
 
Posts: 73 | Thanked: 33 times | Joined on Nov 2010
#5
Originally Posted by javispedro View Post
Half of the stuff you're specifying is already the default in scratchbox (mcpu, mtune, fomit-frame-pointer, mfpu=vfpv3, mfloat-abi, mlittle-endian)
I build a lotta stuff on the N900 when I don't have access to the PC, or it won't build in scratchbox...

-O2
So wouldnd't -O3 be better? I mean if it segfaults, you can always try with -O2...
 
javispedro's Avatar
Posts: 2,355 | Thanked: 5,249 times | Joined on Jan 2009 @ Barcelona
#6
Originally Posted by jj0 View Post
I build a lotta stuff on the N900 when I don't have access to the PC, or it won't build in scratchbox...
If you are using the SDK repository compiler they have the same defaults IIRC.

Originally Posted by jj0 View Post
So wouldnd't -O3 be better?
Not necessarily, it will probably slow things down because of memory pressure. As usual, the answer is: don't assume it is, and benchmark.

Originally Posted by jj0 View Post
-fmessage-length=0 -ftree-vectorize -Os -pipe
tree-vectorize does virtually nothing with the GCC version we have, and message-length does not change anything in the resulting binary...
 

The Following 2 Users Say Thank You to javispedro For This Useful Post:
Posts: 73 | Thanked: 33 times | Joined on Nov 2010
#7
Originally Posted by javispedro View Post
Not necessarily, it will probably slow things down because of memory pressure. As usual, the answer is: don't assume it is, and benchmark.
You're right, I should do that.

How'd I go about benchmarking, I've never done it? Just pick a process that takes some power and use `time'?

Anything more sophisticated?
 
Banned | Posts: 358 | Thanked: 160 times | Joined on Dec 2010
#8
Originally Posted by jj0 View Post
What are the best CFLAGS for the N900, to compile code best optimized for the N900's architecture, running the fastest?

I've seen some presentation of Nokia, which said: "... and don't forget to set CFLAGS XXXXXXXX to take care of XXXXXX" but can't find it...

From what I've searched for and found, I've got:

Code:
-O6 -mcpu=cortex-a8 -mtune=cortex-a8 -fomit-frame-pointer -fsigned-char -mfpu=neon -mfloat-abi=softfp
The -O6 is from some stuff that I read way back, where they were disscussing, -O3 and some guy said why not -O4, to which there were replies like -O4 doesn't even exist in GCC and somebody got to the resolution of -O6 being the best for any given architecture?

I've tried to read the GCC documentation, but got no resolution of anything beyond -O3 existing...

Does it?

And then is there anything I should add to the CFLAGS above, or are these the best custom choice for the N900?
I usually use -O3 -fomit-frame-pointer -ffast-math on my other Linux box. This is quite safe and with -fast-math on it should be quite fast too. But it depends on you usage!
 
Posts: 958 | Thanked: 483 times | Joined on May 2010
#9
so folks, what's the best CFLAGS for the N900???

i'm trying to compile the apple2 emulator for the N900. the cflags i'm using causes it to hang my phone when i run the binary on the N900.

for reference - http://talk.maemo.org/showthread.php...36#post1037336
 
Posts: 726 | Thanked: 345 times | Joined on Apr 2010 @ Sweden
#10
Fiddling about with the -O flag assuming that the bigger the number, the faster the code is a big no-no.

Just a week ago I was asked to have a look at some C++ code that didn't behave properly when compiled with g++. When it was compiled with the MSVC compiler, it worked just as intended (doing some quite complicated calculations).

The solution: change "-O3" to "-O2" to avoid a nasty "feature" that had been introduced in that version of the compiler.

It still compiled and the binary produced a result, but an incorrect result. So, be wary of unneeded optimizations unless you're really certain that you know what'll happen.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 16:53.