Author Topic: What Are The Useful Cflags?  (Read 6043 times)

ZDevil

  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
    • http://
What Are The Useful Cflags?
« on: January 22, 2007, 05:12:33 am »
What are the useful cflags we can use to make an optimized package for pdaXrom?    

So far I only know -O2 and -march=armv5te (and perhaps -mcpu too but doesn't seem different than -march to me), while most other flags are too complicated to a non-nerd such as me.

(... well, is the --march flag needed at all?)

Look forward to reading from the gurus and experts here.

Thanks!
« Last Edit: January 22, 2007, 05:15:10 am by ZDevil »

Life is too precious for hacking *too much*
Visit my Z screencap gallery[/color]
My EeePC 701 Black = Debian (Lenny) on IceRocks + Transcend SDHC Class6 8GB + 2GB RAM
My Zaurus SL-C3200 = Debian EABI (kernel 2.6.24.3-yonggun) on a swapped internal Sandisk Extreme III CF 16gb
My Debian EABI feed: http://matrixmen.free.fr/zaurus/debian/
My OpenBSD/Zaurus feeds:  Link1, Link2
[/i][/font][/color][/size]

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
What Are The Useful Cflags?
« Reply #1 on: January 22, 2007, 01:46:19 pm »
I too would be very interested in hearing what flags to use. I haven't been using any, as I have no clue what ones to use.
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

ZDevil

  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
    • http://
What Are The Useful Cflags?
« Reply #2 on: January 22, 2007, 02:21:18 pm »
I feel that the build runs faster with both -O2 and -march=armv5te CFLAGS, after playing with different compile settings of the roguelikes and *band ports (usually the binaries alone are around 1~2MB), at least by the launch/loading time. Or is it my delusion again?
« Last Edit: January 22, 2007, 02:22:00 pm by ZDevil »

Life is too precious for hacking *too much*
Visit my Z screencap gallery[/color]
My EeePC 701 Black = Debian (Lenny) on IceRocks + Transcend SDHC Class6 8GB + 2GB RAM
My Zaurus SL-C3200 = Debian EABI (kernel 2.6.24.3-yonggun) on a swapped internal Sandisk Extreme III CF 16gb
My Debian EABI feed: http://matrixmen.free.fr/zaurus/debian/
My OpenBSD/Zaurus feeds:  Link1, Link2
[/i][/font][/color][/size]

Meanie

  • Hero Member
  • *****
  • Posts: 2803
    • View Profile
    • http://www.users.on.net/~hluc/myZaurus/
What Are The Useful Cflags?
« Reply #3 on: January 22, 2007, 06:14:09 pm »
Quote
I feel that the build runs faster with both -O2 and -march=armv5te CFLAGS, after playing with different compile settings of the roguelikes and *band ports (usually the binaries alone are around 1~2MB), at least by the launch/loading time. Or is it my delusion again?
[div align=\"right\"][a href=\"index.php?act=findpost&pid=152075\"][{POST_SNAPBACK}][/a][/div]

what is the performance difference when you compile with -march=armv5te vs -march=xscale ?

btw, I use -mtune and -mcpu instead of -march
« Last Edit: January 22, 2007, 06:16:39 pm by Meanie »
SL-C3000 - pdaXii13 build5.4.9 (based on pdaXrom beta3) / SL-C3100 - Sharp ROM 1.02 JP (heavily customised)
Netgear MA701 CF, SanDisk ConnectPlus CF, Socket Bluetooth CF, 4GB Kingston CF,  4GB pqi SD, 4GB ChoiceOnly SD, 2GB SanDisk SD USB Plus, 1GB SanDisk USB Plus, 1GB Transcend SD, 2GB SanDisk MicroSD with SD adaptor, Piel Frama Leather Case, GoldX 5-in-1 USB cable, USB hub, USB mouse, USB keyboard, USB ethernet, USB HDD, many other USB accessories...
(Zaurus SL-C3000 owner since March 14. 2005, Zaurus SL-C3100 owner since September 21. 2005)
http://members.iinet.net.au/~wyso/myZaurus - zBook3K

ZDevil

  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
    • http://
What Are The Useful Cflags?
« Reply #4 on: January 23, 2007, 02:55:13 am »
Quote
Quote
I feel that the build runs faster with both -O2 and -march=armv5te CFLAGS, after playing with different compile settings of the roguelikes and *band ports (usually the binaries alone are around 1~2MB), at least by the launch/loading time. Or is it my delusion again?
[div align=\"right\"][{POST_SNAPBACK}][/a][/div]

what is the performance difference when you compile with -march=armv5te vs -march=xscale ?

btw, I use -mtune and -mcpu instead of -march
[div align=\"right\"][a href=\"index.php?act=findpost&pid=152096\"][{POST_SNAPBACK}][/a][/div]

Thanks. So, for those who are curious, according to the official GCC documentation [a href=\"http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/ARM-Options.html#ARM-Options]http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gc...tml#ARM-Options[/url],

-mcpu=name
    This specifies the name of the target ARM processor. GCC uses this name to determine what kind of instructions it can emit when generating assembly code. Permissible names are: ... `arm1136jfs' ,`xscale', `iwmmxt', `ep9312'.

-mtune=name
    This option is very similar to the -mcpu= option, except that instead of specifying the actual target processor type, and hence restricting which instructions can be used, it specifies that GCC should tune the performance of the code as if the target were of the type specified in this option, but still choosing the instructions that it will generate based on the cpu specified by a -mcpu= option. For some ARM implementations better performance can be obtained by using this option.

-march=name
    This specifies the name of the target ARM architecture. GCC uses this name to determine what kind of instructions it can emit when generating assembly code. This option can be used in conjunction with or instead of the -mcpu= option. Permissible names are: ... `armv4t', `armv5', `armv5t', `armv5te', `armv6j', ...

and there's a simpler guide (for newbies) http://linuxreviews.org/howtos/compiling/ :

Code: [Select]
The most important flags are -mcpu and -march.

`-mcpu=pentium3` means the code will be optimized to run on Pentium3, but will also run on i386.  (<-- Does this mean -march is more specific than -mcpu?)

`-march=pentium3` means the code will only run on a Pentium3.

when -march=arch is set, -mcpu=arch is honored.  (<-- Well, what does this mean?)

`-O[n]` (the letter O, and a number) Various levels of optimization. -O1 , -O2 and -O3, where -O3 is highest.

And perhaps `-fomit-fame-pointer` as well?  

Code: [Select]
`-fomit-fame-pointer` makes programs faster at runtime, but makes debugging impossible. -O turns on -fomit-frame-pointer on machines where doing so does not interfere with debugging. x86 processors need the frame pointer for debugging, so -fomit-frame-pointer is not turned on by default.

A few more questions:
1) My impression is that many Makefiles have -O2 and`-fomit-fame-pointer` CFLAGS preset, usually architecture-specific options are not (which makes sense). But then which combination would do the best? -march and/or -cpu and/or -mtune? Chances are that some source codes don't like some of them. I've come across make errors because of the -O flag and the -march/-mcpu flag(s).

2) What is the common and easy way to test the performance of the build, as Meanie suggests?

3) Does all this matter at all, given the not exceptionally fast processors in Zaurus?
« Last Edit: January 23, 2007, 02:55:56 am by ZDevil »

Life is too precious for hacking *too much*
Visit my Z screencap gallery[/color]
My EeePC 701 Black = Debian (Lenny) on IceRocks + Transcend SDHC Class6 8GB + 2GB RAM
My Zaurus SL-C3200 = Debian EABI (kernel 2.6.24.3-yonggun) on a swapped internal Sandisk Extreme III CF 16gb
My Debian EABI feed: http://matrixmen.free.fr/zaurus/debian/
My OpenBSD/Zaurus feeds:  Link1, Link2
[/i][/font][/color][/size]

lardman

  • Hero Member
  • *****
  • Posts: 4512
    • View Profile
    • http://people.bath.ac.uk/enpsgp/Zaurus/
What Are The Useful Cflags?
« Reply #5 on: January 23, 2007, 07:28:13 am »
Quote
3) Does all this matter at all, given the not exceptionally fast processors in Zaurus?

Even more so in that case!

Quote
2) What is the common and easy way to test the performance of the build, as Meanie suggests?

I'd test whatever it is you want to optimise - mplayer for example. On the other hand you could try some benchmarking programs (though these just test single things - floating point, integer operations, etc.).

See this thread for some results from a long time back: https://www.oesf.org/forums/index.php?showtopic=3451&hl=

and here for some Nokia binaries (not that useful of course) plus download URLs and compilation command lines: http://people.bath.ac.uk/enpsgp/benchmarks...ling_things.txt

Opie has an applet which provides some benchmarks for various things: This can be found here: http://handhelds.org/cgi-bin/cvsweb.cgi/op...ttings/sysinfo/ (benchmarkinfo*)

And those files say they were inspired by zbench, the original URL for which is gone, but some source is here: http://linuxtogo.org/~mickeyl/mirror/zbench-2.0.tar.bz2


Si
« Last Edit: January 23, 2007, 07:29:04 am by lardman »
C750 OZ3.5.4 (GPE, 2.6.x kernel)
SL5500 OZ3.5.4 (Opie)
Nokia 770
Serial GPS, WCF-12, Socket Ethernet & BT, Ratoc USB
WinXP, Mandriva

ZDevil

  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
    • http://
What Are The Useful Cflags?
« Reply #6 on: January 23, 2007, 09:34:01 am »
Quote
what is the performance difference when you compile with -march=armv5te vs -march=xscale ?

btw, I use -mtune and -mcpu instead of -march
[div align=\"right\"][a href=\"index.php?act=findpost&pid=152096\"][{POST_SNAPBACK}][/a][/div]

Is -march=xscale allowed?  
The official doc says: "... Permissible names are: `armv2', `armv2a', `armv3', `armv3m', `armv4', `armv4t', `armv5', `armv5t', `armv5te', `armv6j', `iwmmxt', `ep9312'."  No "xscale", though.

I've tried both -march=armv5te -mcpu=xscale. Make complains about conflicting architecture flags.

Also tried --mcpu=xscale --mtune=xcale when recompiling Angband. So far so good.  

Life is too precious for hacking *too much*
Visit my Z screencap gallery[/color]
My EeePC 701 Black = Debian (Lenny) on IceRocks + Transcend SDHC Class6 8GB + 2GB RAM
My Zaurus SL-C3200 = Debian EABI (kernel 2.6.24.3-yonggun) on a swapped internal Sandisk Extreme III CF 16gb
My Debian EABI feed: http://matrixmen.free.fr/zaurus/debian/
My OpenBSD/Zaurus feeds:  Link1, Link2
[/i][/font][/color][/size]

ZDevil

  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
    • http://
What Are The Useful Cflags?
« Reply #7 on: January 23, 2007, 09:37:32 am »
Quote
Quote
3) Does all this matter at all, given the not exceptionally fast processors in Zaurus?

Even more so in that case!

So this seems to be the way to go ...    

Quote
Quote
2) What is the common and easy way to test the performance of the build, as Meanie suggests?

I'd test whatever it is you want to optimise - mplayer for example. On the other hand you could try some benchmarking programs (though these just test single things - floating point, integer operations, etc.).

See this thread for some results from a long time back: https://www.oesf.org/forums/index.php?showtopic=3451&hl=

and here for some Nokia binaries (not that useful of course) plus download URLs and compilation command lines: http://people.bath.ac.uk/enpsgp/benchmarks...ling_things.txt

Opie has an applet which provides some benchmarks for various things: This can be found here: http://handhelds.org/cgi-bin/cvsweb.cgi/op...ttings/sysinfo/ (benchmarkinfo*)

And those files say they were inspired by zbench, the original URL for which is gone, but some source is here: http://linuxtogo.org/~mickeyl/mirror/zbench-2.0.tar.bz2
[div align=\"right\"][a href=\"index.php?act=findpost&pid=152139\"][{POST_SNAPBACK}][/a][/div]

Thanks for the resources!  There is so much to learn and so much fun ...  
« Last Edit: January 23, 2007, 09:37:49 am by ZDevil »

Life is too precious for hacking *too much*
Visit my Z screencap gallery[/color]
My EeePC 701 Black = Debian (Lenny) on IceRocks + Transcend SDHC Class6 8GB + 2GB RAM
My Zaurus SL-C3200 = Debian EABI (kernel 2.6.24.3-yonggun) on a swapped internal Sandisk Extreme III CF 16gb
My Debian EABI feed: http://matrixmen.free.fr/zaurus/debian/
My OpenBSD/Zaurus feeds:  Link1, Link2
[/i][/font][/color][/size]

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
What Are The Useful Cflags?
« Reply #8 on: January 23, 2007, 04:02:10 pm »
Is optimizing something like Stratagus likely to make it run a lot better? I know that Battle of Survival on Stratagus 2.2.1 is barely playable, and 2.2.2 just came out, so I was wondering if optimization would help enough to make it play smoothly.

Thanks, and sorry if this is a dumb question.
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

ZDevil

  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
    • http://
What Are The Useful Cflags?
« Reply #9 on: January 23, 2007, 04:09:32 pm »
Quote
Is optimizing something like Stratagus likely to make it run a lot better? I know that Battle of Survival on Stratagus 2.2.1 is barely playable, and 2.2.2 just came out, so I was wondering if optimization would help enough to make it play smoothly.

Thanks, and sorry if this is a dumb question.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=152177\"][{POST_SNAPBACK}][/a][/div]

... Maybe Battle for Wesnoth as well?  Dumb X2  
Let me try this on prboom and Armagetron then (after purging out all the *band jobs).
« Last Edit: January 23, 2007, 04:12:50 pm by ZDevil »

Life is too precious for hacking *too much*
Visit my Z screencap gallery[/color]
My EeePC 701 Black = Debian (Lenny) on IceRocks + Transcend SDHC Class6 8GB + 2GB RAM
My Zaurus SL-C3200 = Debian EABI (kernel 2.6.24.3-yonggun) on a swapped internal Sandisk Extreme III CF 16gb
My Debian EABI feed: http://matrixmen.free.fr/zaurus/debian/
My OpenBSD/Zaurus feeds:  Link1, Link2
[/i][/font][/color][/size]

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
What Are The Useful Cflags?
« Reply #10 on: January 23, 2007, 04:16:08 pm »
Quote
Quote
Is optimizing something like Stratagus likely to make it run a lot better? I know that Battle of Survival on Stratagus 2.2.1 is barely playable, and 2.2.2 just came out, so I was wondering if optimization would help enough to make it play smoothly.

Thanks, and sorry if this is a dumb question.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=152177\"][{POST_SNAPBACK}][/a][/div]

... Maybe Battle for Wesnoth as well?  Dumb X2  
Let me try this on prboom and Armagetron then (after purging out all the *band jobs).
[div align=\"right\"][a href=\"index.php?act=findpost&pid=152179\"][{POST_SNAPBACK}][/a][/div]

I tried compiling Wesnoth a while ago, but it swapped so much that it didn't get anything done overnight, and I ended up stopping it.
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

ZDevil

  • Hero Member
  • *****
  • Posts: 1998
    • View Profile
    • http://
What Are The Useful Cflags?
« Reply #11 on: January 24, 2007, 05:31:35 am »
Sorry that I have yet to look at the tools lardman refers to. Here is just a very impressionistic report:

I've tested different builds of Angband, Hellband, Frazband and Xangband. The binaries are not too small (1~2MB). I can feel the speed-up after using -O2 -mcpu=xscale -mtune=xscale. The games launch almost instantly.

With -O2 alone it seems to take (at least) a second or two to launch.  

I also feel movement is more responsive in the game.

This is especially obvious in my Angband build with SDL sound support and 32x32 BMP tileset (usually the *band games use 8x8 or 16x16, some no graphical tiles at all), the game loads obviously faster and the sound effects play properly, while I feel a tiny bit of delay sometimes in my original build without architecture optimization.  

I will also go rebuild ToME and Furyband (posted before) with this setting, particularly because they take longer time to load than the *band.
« Last Edit: January 24, 2007, 05:32:48 am by ZDevil »

Life is too precious for hacking *too much*
Visit my Z screencap gallery[/color]
My EeePC 701 Black = Debian (Lenny) on IceRocks + Transcend SDHC Class6 8GB + 2GB RAM
My Zaurus SL-C3200 = Debian EABI (kernel 2.6.24.3-yonggun) on a swapped internal Sandisk Extreme III CF 16gb
My Debian EABI feed: http://matrixmen.free.fr/zaurus/debian/
My OpenBSD/Zaurus feeds:  Link1, Link2
[/i][/font][/color][/size]

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
What Are The Useful Cflags?
« Reply #12 on: January 24, 2007, 07:46:59 am »
Quote
Sorry that I have yet to look at the tools lardman refers to. Here is just a very impressionistic report:

I've tested different builds of Angband, Hellband, Frazband and Xangband. The binaries are not too small (1~2MB). I can feel the speed-up after using -O2 -mcpu=xscale -mtune=xscale. The games launch almost instantly.

With -O2 alone it seems to take (at least) a second or two to launch. 

I also feel movement is more responsive in the game.

This is especially obvious in my Angband build with SDL sound support and 32x32 BMP tileset (usually the *band games use 8x8 or 16x16, some no graphical tiles at all), the game loads obviously faster and the sound effects play properly, while I feel a tiny bit of delay sometimes in my original build without architecture optimization. 

I will also go rebuild ToME and Furyband (posted before) with this setting, particularly because they take longer time to load than the *band.
[div align=\"right\"][a href=\"index.php?act=findpost&pid=152222\"][{POST_SNAPBACK}][/a][/div]
YES!!! Of course, now I want my Z to be working more than ever. I'll build the new Stratagus and see hoe BoS runs!
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo

koen

  • Hero Member
  • *****
  • Posts: 1008
    • View Profile
    • http://dominion.thruhere.net/koen/cms/
What Are The Useful Cflags?
« Reply #13 on: January 24, 2007, 11:29:45 am »
Quote
what is the performance difference when you compile with -march=armv5te vs -march=xscale ?

-march=xscale optimizes for the absurdly long pipeline present in the xscales, -march=armv5te only for the v5 instruction set

Quote
btw, I use -mtune and -mcpu instead of -march

x86 and arm gcc have conflicting rules on how to mix and match those
Forums are not bugtrackers!!! Smart questions
Ångström release team
iPAQ h2210, iPAQ h5550, iPAQ hx4700, Zaurus SL-C700, Nokia 770, all running some form of GPE
My blog

Capn_Fish

  • Hero Member
  • *****
  • Posts: 2342
    • View Profile
    • http://
What Are The Useful Cflags?
« Reply #14 on: January 24, 2007, 08:19:11 pm »
When I try to compile Stratagus with any CFLAGS or CXXFLAGS it doesn't configure. It doesn't find strings.h, memory.h, etc.

My command is:

#./configure --with-opengl=no --with-x CFLAGS=-O2,-mcpu=xscale,-mtune=xscale

Any idea what the problem is? The same thing happens when I try that with CXXFLAGS or both.

If you need any or all of the output, let me know.

Any help would be appreciated.
SL-C750- pdaXrom beta 1 (mostly unused)
Current distro: Gentoo