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

5

70

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?

Aestival answered 22/7, 2010 at 16:7 Comment(1)
Small correction: it's armv6 and armv7, not arm6 and arm7. Note the v.Tarnish
H
55

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).

Herriott answered 22/7, 2010 at 16:17 Comment(2)
Actually, according to Stephen Canon, both single- and double-precision floating-point operations are performed in hardware in armv6: #1623229Schear
That's true. I missed that out.Herriott
S
77

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:

Schear answered 22/7, 2010 at 17:26 Comment(4)
As of Xcode 4.3, as part of the project migration, Apple is setting GCC_THUMB_SUPPORT = NO unconditionally. Any comment? Seems counter intuitive to me and (of course/unfortunately) there's nothing from Apple about this. Their docs still say use thumb for armv7.Staging
@Staging - It could be a glitch in the project migration, because the instruction set shouldn't have changed. It still should be advantageous to have Thumb-2 instructions be generated for ARMv7. Worst case, profile your application (memory and performance) under both conditions to see how the setting changes things. Every time I've tried this, building for Thumb helped on ARMv7.Schear
Thanks, Brad. I think I will leave my current overrides in and reject Xcode's. Now to fix the other stuff 4.3 broke ...Staging
FWIW, the text that Xcode displays when it wants to make this change is that it wants to use ARM for THUMB on armv6. But the setting it adds doesn't appear to be conditioned on the architecture ...Staging
H
55

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).

Herriott answered 22/7, 2010 at 16:17 Comment(2)
Actually, according to Stephen Canon, both single- and double-precision floating-point operations are performed in hardware in armv6: #1623229Schear
That's true. I missed that out.Herriott
S
4

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.

Stray answered 22/7, 2010 at 21:11 Comment(0)
T
3

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.

Tamratamsky answered 22/7, 2010 at 16:9 Comment(2)
So what is the significance of active architecture in the dropdown menu for building?Aestival
I believe they took that out in the latest SDK. It was usually overriden by your build settings anyway.Tamratamsky
L
3

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.

Lawman answered 22/7, 2010 at 16:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.