Speed of chess programs on the iPhone/iPod Touch

Discussion of chess software programming and technical issues.

Moderators: hgm, Dann Corbit, Harvey Williamson

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 8:19 pm
Location: Oslo, Norway

Speed of chess programs on the iPhone/iPod Touch

Post by Tord Romstad » Thu Jan 01, 2009 6:28 pm

Hi all,

I have managed to compile Glaurung 2.2 (only the UCI engine; no GUI so far) to the iPhone OS, and am somewhat disappointed by the speed on my first-generation iPod Touch (which uses an ARM CPU running at 450 MHz, if I recall correctly). From the opening position, Glaurung searches about 14 Kn/s, which is almost a factor of 100 slower than when running on a single core of my 2.8 GHz Core 2 Duo. Based on benchmarks elsewhere, I expected a slowdown by a factor of only about 40.

Is a factor of 100 normal, or is it likely that something is wrong? I use these compiler switches:

Code: Select all

CXXFLAGS = -O3 -fno-exceptions -fomit-frame-pointer -fno-rtti -fstrict-aliasing -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk/
Tord

Sven
Posts: 4004
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany
Full name: Sven Schüle
Contact:

Re: Speed of chess programs on the iPhone/iPod Touch

Post by Sven » Thu Jan 01, 2009 7:59 pm

Tord Romstad wrote:I use these compiler switches:

Code: Select all

CXXFLAGS = -O3 -fno-exceptions -fomit-frame-pointer -fno-rtti -fstrict-aliasing -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk/
Just a small note: -fomit-frame-pointer and -fstrict-aliasing are probably redundant in these settings since they are already switched on by -O2 (and therefore also by -O3).

As to "-arch armv6": isn't it "-march=armv6"? Or do I mix up something here?

Sven

Michel
Posts: 2236
Joined: Sun Sep 28, 2008 11:50 pm

Re: Speed of chess programs on the iPhone/iPod Touch

Post by Michel » Thu Jan 01, 2009 8:09 pm

I assume you did profile? -fprofile-use seems to missing from you command line.

Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 8:19 pm
Location: Oslo, Norway

Re: Speed of chess programs on the iPhone/iPod Touch

Post by Tord Romstad » Thu Jan 01, 2009 8:35 pm

Sven Schüle wrote:
Tord Romstad wrote:I use these compiler switches:

Code: Select all

CXXFLAGS = -O3 -fno-exceptions -fomit-frame-pointer -fno-rtti -fstrict-aliasing -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk/
Just a small note: -fomit-frame-pointer and -fstrict-aliasing are probably redundant in these settings since they are already switched on by -O2 (and therefore also by -O3).
They are redundant, but harmless, and save some typing when I want to experiment with only -O (as I sometimes do).
As to "-arch armv6": isn't it "-march=armv6"? Or do I mix up something here?
No, "-arch armv6" is correct. You are probably just confused because the -arch switch is Apple-specific.

Tord

Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 8:19 pm
Location: Oslo, Norway

Re: Speed of chess programs on the iPhone/iPod Touch

Post by Tord Romstad » Thu Jan 01, 2009 8:37 pm

Michel wrote:I assume you did profile? -fprofile-use seems to missing from you command line.
I never use profile-generated optimization with GCC, simply because it doesn't work for me. Whenever I try, I just get an executable that crashes instantly at startup. This happens with all GCC versions I have tried, in Linux as well as in Mac OS X.

Tord

Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 8:19 pm
Location: Oslo, Norway

Re: Speed of chess programs on the iPhone/iPod Touch

Post by Tord Romstad » Thu Jan 01, 2009 9:04 pm

I just tried the same experiment with Fruit, and found a slowdown by a factor of just 50. Perhaps Glaurung pays a huge penalty for its bitboard infrastructure?

Tord

Sven
Posts: 4004
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany
Full name: Sven Schüle
Contact:

Re: Speed of chess programs on the iPhone/iPod Touch

Post by Sven » Thu Jan 01, 2009 9:36 pm

Tord Romstad wrote:
Sven Schüle wrote:As to "-arch armv6": isn't it "-march=armv6"? Or do I mix up something here?
No, "-arch armv6" is correct. You are probably just confused because the -arch switch is Apple-specific.
Tord,

sorry to bother you, I don't know much about GCC on Mac, but ... quoted from http://developer.apple.com/DOCUMENTATIO ... gcc.1.html which seems to describe gcc-4.0.1 (dated 2007-09-23):

Code: Select all

       -arch arch
           Compile for the specified target architecture arch.  The allowable values are i386, ppc and
           ppc64.  Multiple options work, and direct the compiler to produce ``universal'' binaries
           including object code for each architecture specified with -arch.  This option only works if
           assembler and libraries are available for each architecture specified.  (APPLE ONLY)

[...]

       -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: armv2, armv2a, armv3,
           armv3m, armv4, armv4t, armv5, armv5t, armv5te, armv6, armv6j, iwmmxt, ep9312.
So maybe something has changed since then?

Sven

Tord Romstad
Posts: 1808
Joined: Wed Mar 08, 2006 8:19 pm
Location: Oslo, Norway

Re: Speed of chess programs on the iPhone/iPod Touch

Post by Tord Romstad » Thu Jan 01, 2009 9:51 pm

Sven Schüle wrote:
Tord Romstad wrote:
Sven Schüle wrote:As to "-arch armv6": isn't it "-march=armv6"? Or do I mix up something here?
No, "-arch armv6" is correct. You are probably just confused because the -arch switch is Apple-specific.
Tord,

sorry to bother you, I don't know much about GCC on Mac, but ... quoted from http://developer.apple.com/DOCUMENTATIO ... gcc.1.html which seems to describe gcc-4.0.1 (dated 2007-09-23):

Code: Select all

       -arch arch
           Compile for the specified target architecture arch.  The allowable values are i386, ppc and
           ppc64.  Multiple options work, and direct the compiler to produce ``universal'' binaries
           including object code for each architecture specified with -arch.  This option only works if
           assembler and libraries are available for each architecture specified.  (APPLE ONLY)

[...]

       -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: armv2, armv2a, armv3,
           armv3m, armv4, armv4t, armv5, armv5t, armv5te, armv6, armv6j, iwmmxt, ep9312.
So maybe something has changed since then?
That documentation is for a different compiler: The "standard" gcc used to compile Mac OS X applications, which cannot compile iPhone programs. There is a different gcc executable included in the iPhone SDK, that's the one I use. "-arch armv6" is certainly correct, otherwise my program wouldn't even run on the iPhone.

Tord

Sven
Posts: 4004
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany
Full name: Sven Schüle
Contact:

Re: Speed of chess programs on the iPhone/iPod Touch

Post by Sven » Thu Jan 01, 2009 10:43 pm

Tord Romstad wrote:That documentation is for a different compiler: The "standard" gcc used to compile Mac OS X applications, which cannot compile iPhone programs. There is a different gcc executable included in the iPhone SDK, that's the one I use. "-arch armv6" is certainly correct, otherwise my program wouldn't even run on the iPhone.

Tord
I downloaded the iPhone gcc package (v4.0.1) and looked into its gcc manual page. Please have a look into it again by yourself ("man gcc").

That your program runs on the iPhone is IMO accomplished already by using the iPhone gcc executable. So my theory is that "-arch armv6" could be no-op (unknown but not causing a compile error), and that "-march=armv6" could result in some code improvements. I may be wrong, but in cases like that I tend to believe in the written manual first.

Maybe I still look at the wrong manual?

Sven

Sven
Posts: 4004
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany
Full name: Sven Schüle
Contact:

Re: Speed of chess programs on the iPhone/iPod Touch

Post by Sven » Thu Jan 01, 2009 10:58 pm

Tord Romstad wrote:and am somewhat disappointed by the speed on my first-generation iPod Touch (which uses an ARM CPU running at 450 MHz, if I recall correctly).
According to Wikipedia it runs at 400 MHz.
Just nitpicking a little bit :)
Sven

Post Reply