 |
 |
|
 |
02-05-2009, 02:48 AM
|
#1 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Location: Orange County, CA
Posts: 20
|
floating point unit?
Does anyone happen to know whether the iPhone has an FPU and what the performance of floating point operations is?
I've seen a few references to a "vector floating point co-processor for 3d graphics" [1], but it's unclear to me whether that's something that needs a special API to access, or is it like a normal FPU and the just compiler uses it whenever you use floats?
I'm guessing there must be decent floating point, what with all the OpenGL stuff going on. But I'm wanting to figure out whether I can use floats or if I'll need to do fixed point math. Are there pointers to performance numbers perhaps?
[1] - iPhone processor found: 620MHz ARM CPU - Engadget
|
|
|
02-05-2009, 05:51 AM
|
#2 (permalink)
|
|
iPhone App Developer
Join Date: Sep 2008
Location: Berlin, Germany
Posts: 229
|
It has a graphic processor that does the opengl stuff. I don't think there is something like a 387 or stuff like that.
__________________
Learn vocabularies on iPhone? iVocabulary!
|
|
|
02-05-2009, 12:22 PM
|
#3 (permalink)
|
|
New Member
Join Date: Feb 2009
Posts: 4
|
The ARM processor used by the iPhone/iPod touch has an extension called VFP for doing fast floating point operations.
If you just want to do a few floating point calculations you probably don't need to worry much. If you're doing a lot of them you should switch off the "Compile for Thumb" option in your project settings for maximum floating point performance. This will make your code run in ARM processor mode instead of Thumb mode. Thumb doesn't directly support floating point.
Here are a couple references that might help:
Break That Thumb For Best iPhone Performance
Floating iPhone | iCocoa
|
|
|
02-06-2009, 02:40 AM
|
#4 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Location: Orange County, CA
Posts: 20
|
Excellent, thank you. (I'm surprised no one's ported a CPU / math / floating point benchmark utility to the iPhone.)
|
|
|
02-06-2009, 12:27 PM
|
#5 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Location: Orange County, CA
Posts: 20
|
Sorry, just to be clear, is there anything special you need to do to use the VFP? Special API calls or whatever? Or can I just use floats/doubles as normal? (except for the non-thumb mode stuff, that is).
Thanks
|
|
|
02-06-2009, 01:48 PM
|
#6 (permalink)
|
|
New Member
Join Date: Feb 2009
Posts: 4
|
In the general case, no. If you want to get fancy you can write assembler to take advantage of the vector instructions which will do several operations at once.
|
|
|
02-07-2009, 12:29 AM
|
#7 (permalink)
|
|
Registered Member
Join Date: Nov 2008
Posts: 251
|
I didn't realize there was an option to compile in ARM mode. This could be handy if you're writing a game or some other really performance intensive application.
Why there's no benchmarking utility? Because there isn't much hardware variation (yet). The Touch 2G has a faster CPU, but otherwise I think everything is all the same on all platforms.
|
|
|
02-07-2009, 02:17 PM
|
#8 (permalink)
|
|
Registered Member
Join Date: Jul 2008
Posts: 328
|
Quote:
Originally Posted by jcollins
...you should switch off the "Compile for Thumb" option in your project settings...
|
Not meaning to be dense, but I can't find "compile for Thumb" in the project's build settings... only a selection of which compiler to use. It seems many moons ago I saw this somewhere, but did it go somewhere?
Directions to this option would help me out! (maybe, we'll see)!
|
|
|
02-07-2009, 08:07 PM
|
#9 (permalink)
|
|
New Member
Join Date: Feb 2009
Posts: 4
|
Yeah, this option likes to hide. The trick is to right-click on your main build target under the "Targets" folder and select "Get Info". For some reason the option only shows when you enter project settings this way. In the dialog that opens make sure the "Build" tab is selected. Then enter "Thumb" in the search and you should see the option.
|
|
|
02-07-2009, 08:28 PM
|
#10 (permalink)
|
|
Registered Member
Join Date: Nov 2008
Posts: 251
|
Project Settings, go all the way to the bottom to the section "GCC 4.0 - Code Generation", there is a setting labeled "Compile for Thumb".
On a commercial project I work on (not iphone-related) we compile some objects in ARM (for speed critical code) and some in Thumb mode (to save space). I don't see an easy way to do that with the Xcode build system though.
|
|
|
02-07-2009, 09:04 PM
|
#11 (permalink)
|
|
New Member
Join Date: Feb 2009
Posts: 4
|
Actually, it's pretty easy. Just right click on a file you want to compile with ARM. Select "Get Info" and make sure the "Build" tab is selected. Should be an large text field. In this text field add "-mno-thumb" and that file will be compiled for ARM.
That works for me on my iPhone app. Alternatively you can use the "#pragma arm" and "#pragma thumb" directives to wrap your ARM code.
|
|
|
02-08-2009, 12:45 PM
|
#12 (permalink)
|
|
Registered Member
Join Date: Jul 2008
Posts: 328
|
Thanks gang... I found it. Interesting though, as a test I compiled not-for-thumb and ran my regression test loop which basically does millions and millions and millions of floating point calculations with no display interaction (very very sparse output to console, one NSLog every 10 minutes or so) and while I didn't wait for it to finish the first segment of the regression test actually was taking longer than it does when compiled-for-thumb. Being the impatient sort with many other things to do than to watch a test run, I terminated after waiting 3x the normal time. My "floating point laden" routines mostly do arithmetic with liberal use of exp, log and pow but no trig (sin/cos etc.) so perhaps the vector graphics unit is optimized for trig? Makes sense to me!
I may benchmark some view generation that I do that contains Quartz2D drawing to see if thumb has any effect, but since I don't do much trig in there either I'm not expecting to see a difference.
All this is just another way to say: it would appear that your mileage may vary!
|
|
|
02-08-2009, 01:14 PM
|
#13 (permalink)
|
|
Registered Member
Join Date: Nov 2008
Posts: 251
|
Quote:
Originally Posted by jcollins
Actually, it's pretty easy. Just right click on a file you want to compile with ARM. Select "Get Info" and make sure the "Build" tab is selected. Should be an large text field. In this text field add "-mno-thumb" and that file will be compiled for ARM.
That works for me on my iPhone app. Alternatively you can use the "#pragma arm" and "#pragma thumb" directives to wrap your ARM code.
|
Good to know. The armcc compiler I use at work supports the same pragmas but I couldn't find any gcc documentation about that.
tawpie, here's the deal with ARM vs Thumb code. ARM code is a larger instruction set and has a lot shiny options that can give you faster performance. But Thumb code is 16 bits/instruction (half the size of ARM code) so you end up with a smaller code image. Smaller code means more of your code is cached and less time in general fetching instructions. So it definitely depends on your application which is optimal.
Probably, it's better to leave everything in Thumb mode and put only the most critical pieces in ARM mode (inner loops, heavy calculations, etc).
|
|
|
02-08-2009, 08:37 PM
|
#14 (permalink)
|
|
Registered Member
Join Date: Jul 2008
Posts: 328
|
Thanks folks!
When I have some time (???) I may run some benchmarks for grins. For now, it'd be the difference of a half sec or so from the viewpoint of the user so it's not crucial but we all know that faster is better!
|
|
|
02-18-2009, 02:35 PM
|
#15 (permalink)
|
|
New Member
Join Date: Jan 2009
Location: San Diego, CA
Posts: 405
|
WHERE is this setting?
Excuse me for being so dense. But I cannot find this setting anywhere.
I've followed all of the advice above, and it just isn't there.
In fact, I don't have a "GCC 4.0 - Code Generation" section at all.
I'm afraid somebody is going to have to give me a click-by-click guide to finding this setting. Or has this been changed?
I'm using the 2.2 SDK.
I've tried "info" on the base for the project, and on the top-level target. The section for GCC Code Generation just isn't there.
P.S. Here's a link to a post about what looks like the same problem:
http://lists.apple.com/archives/Xcod.../msg00171.html
I see the "User-Defined" section at the end of the build info. I do NOT see GCC 4.0 Code Generation, Language, Preprocessing, and Warnings.
Last edited by jtara; 02-18-2009 at 02:44 PM.
Reason: Added info
|
|
|
02-18-2009, 02:56 PM
|
#16 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Posts: 18
|
Quote:
Originally Posted by dannys42
Excellent, thank you. (I'm surprised no one's ported a CPU / math / floating point benchmark utility to the iPhone.)
|
someone has, me.
Check out the app called Diagnostics in the app store. It measures the MFLOPS of your Iphone.
Last edited by AppStore-Diagnostics; 02-19-2009 at 08:31 AM.
|
|
|
02-18-2009, 04:21 PM
|
#17 (permalink)
|
|
Pro. Game Developer
iPhone Dev SDK Supporter
Join Date: Feb 2009
Location: żLa Islas Hermosas?
Posts: 1,669
|
It's NOT You
Quote:
Originally Posted by jtara
Excuse me for being so dense. But I cannot find this setting anywhere.
I've followed all of the advice above, and it just isn't there.
In fact, I don't have a "GCC 4.0 - Code Generation" section at all.
I'm afraid somebody is going to have to give me a click-by-click guide to finding this setting. Or has this been changed?
I'm using the 2.2 SDK.
I've tried "info" on the base for the project, and on the top-level target. The section for GCC Code Generation just isn't there.
P.S. Here's a link to a post about what looks like the same problem:
Re: Target Info: Build: Why sometimes sections of GCC settings?
I see the "User-Defined" section at the end of the build info. I do NOT see GCC 4.0 Code Generation, Language, Preprocessing, and Warnings.
|
I found myself in this position a while back. Let's see if you're having the same problem I was having.
Next time you're in Xcode, looking for those "GCC 4.0..." settings, check your current build settings. Are you building against the Simulator? I was, and you probably are too.
Now, change your build settings so that you're building against the Device and check your project settings again. Do you now have the "GCC 4.0..." settings? I did, and you probably do to.
If this doesn't work for you, I'm sorry as I have no other idea what could be causing your problem. But I've found that once I discovered this behavior pattern, it's been consistent across all of my iPhone projects.
|
|
|
02-18-2009, 04:32 PM
|
#18 (permalink)
|
|
New Member
Join Date: Jan 2009
Location: San Diego, CA
Posts: 405
|
Quote:
Originally Posted by Kalimba
Are you building against the Simulator? I was, and you probably are too.
|
Doh! Thanks!
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 392 |
| 30 members and 362 guests |
| AdamSubach, aderrington, airsoft808, benoitr007, bensj, BrianSlick, Danneman, dev123, ErichGS, gtyt38, gustavo7sexton, HemiMG, Jeremy1026, lifeCoder45, mriphoneman, Ovidius, Paul10, Piequanna, pofak, qilin, Racker, raheel, Sega dude, socals, squidboy, timle8n1, ZunePod |
| Most users ever online was 965, 06-30-2010 at 04:26 AM. |
» Stats |
Members: 41,860
Threads: 49,768
Posts: 213,054
Top Poster: BrianSlick (3,138)
|
| Welcome to our newest member, gustavo7sexton |
|