Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the advantages of armv7 over armv6 when compiling iPhone apps?

If there are any advantages at all... couldn't find anything conclusive in the docs.

Apparently armv7 is for newer version of iOS... is it faster? smaller? Better at X?

like image 963
M. Ryan Avatar asked Jul 22 '10 16:07

M. Ryan


5 Answers

The older iOS devices (iPhone, iPhone 3G, first and second generation iPod touch) had CPUs that only supported the armv6 instruction set. The iPhone 3G S (and iPad and third-generation iPod touch) has a newer processor that also supports the armv7 instruction set. In general, armv7 is faster on these newer processors and it is recommended that you at least include an armv7 build in your applications going forward (in an iPad-only application, you can probably just build for armv7).

As Jasarien points out, the area of largest difference between the instruction sets is in floating-point operations. On armv6, applications tended to be built using the reduced Thumb instruction set to produce smaller binaries, but Thumb floating-point performance was terrible. Therefore, you needed to disable Thumb is you wanted faster floating-point calculations. On armv7, the Thumb-2 instruction set no longer has this limitation, so Apple recommends you compile using it almost all the time.

You can make the Thumb build setting conditional so that it is off for older devices and on for newer ones. To do this, go to your Xcode build settings and select the Compile for Thumb option. Go to the menu at the bottom-left of the screen and choose the Add Build Setting Condition option. In the new build setting condition, choose ARMv6 for the architecture, turn off Thumb for it, add another condition, choose ARMv7 for its architecture, and enable Thumb for it.

According to Stephen Canon's answer here, both single and double-precision floating-point operations are supported in hardware in armv6. I've found that single-precision arithmetic performs slightly better on this platform, perhaps due to more operations fitting into cache. On armv7, the NEON SIMD floating-point unit only works on single-precision operations, so there can be a vast difference in performance between single and double precision operations.

Other questions that might be of interest on this subject include:

  • "What are the benefits/consequences of compiling an armv7 only architecture?"
  • "How does changing armv6/armv7 architecture to armv6 affect my iPad app? Will there be performance/stability losses?"
  • "iPhone detecting processor model / NEON support"
  • "Fast sine/cosine for ARMv7+NEON: looking for testers…"
like image 65
Brad Larson Avatar answered Nov 13 '22 11:11

Brad Larson


One of the bigger differences is that the armv6 architecture has hardware support for double precision floating point arithmetic, while armv7 only provides legacy software support for double precision floating point arithmetic.

To compensate, the armv7 architecture has a "NEON" unit that provides blindingly fast hardware support for single precision floating point arithmetic.

This is something you'll need to take into account if you're doing anything that involves floating point arithmetic, whether you're doing it in single or double precision. If you're doing it in double precision, but don't necessarily need that amount of precision, you can probably get a significant performance boost on armv7 devices by using single precision instead.

Apple covered a lot of the differences between armv6 and armv7 and an introduction to the Accelerate framework in one of their WWDC sessions this year. The videos should still be available on iTunes ( as of July '10).

like image 40
Jasarien Avatar answered Nov 13 '22 11:11

Jasarien


To me, the main advantages of ARMv7 are:

  • thumb-2
  • NEON

NEON must be explicitly coded for, you don't take advantage of it by simply recompiling, but if you can invest the time it can accelerate multimedia/gaming operations by a factor of 8. However thumb-2 is pretty much a free reduction in code size with almost no drawback (contrary to thumb on ARMv6, which makes floating-point code much slower compared to ARM mode). Of course, adding another version of your executable in ARMv7 will not reduce your executable size, but it will reduce your code in memory, caches, etc.

like image 4
Pierre Lebeaupin Avatar answered Nov 13 '22 11:11

Pierre Lebeaupin


You must compile for both if you want your app to run on iPad and all iPhone/iPod toch models. Older iOS devices use arm6 and new ones use arm7.

The only reason to not compile for one or the other would be reduced app size since it only needs one compiled version of the code. But unless you have a seriously large codebase, this file size difference will be pretty marginal.

like image 3
Alex Wayne Avatar answered Nov 13 '22 10:11

Alex Wayne


arm7 is more optimized for the iPod Touch (3rd Gen) and iPhone 3GS and newer. You need to use 'Standard/arm6+arm7' when building for older devices. In practice, I haven't seen much performance difference in my applications.

like image 3
Alex Argo Avatar answered Nov 13 '22 11:11

Alex Argo