Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
343 views
in Technique[技术] by (71.8m points)

objective c - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...