ios 编译 iPhone 应用程序时,armv7 与 armv6 相比有哪些优势?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3310907/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 17:26:07  来源:igfitidea点击:

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

iphoneobjective-ciosxcodearmv7

提问by M. Ryan

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?

显然 armv7 适用于较新版本的 iOS ......它更快吗?更小?更擅长X?

采纳答案by Jasarien

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.

更大的区别之一是 armv6 架构对双精度浮点运算有硬件支持,而 armv7 仅提供对双精度浮点运算的传统软件支持。

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

作为补偿,armv7 架构有一个“NEON”单元,为单精度浮点运算提供极快的硬件支持。

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.

如果您正在做任何涉及浮点运算的事情,无论是单精度还是双精度,您都需要考虑到这一点。如果您在双精度下执行此操作,但不一定需要那么高的精度,则可以通过改用单精度在 armv7 设备上获得显着的性能提升。

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

Apple 在今年的一次 WWDC 会议中介绍了 armv6 和 armv7 之间的许多差异,并介绍了 Accelerate 框架。这些视频应该仍然可以在 iTunes 上使用(截至 10 年 7 月)。

回答by Brad Larson

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

较旧的 iOS 设备(iPhone、iPhone 3G、第一代和第二代 iPod touch)的 CPU 仅支持 armv6 指令集。iPhone 3GS(以及 iPad 和第三代 iPod touch)具有更新的处理器,也支持 armv7 指令集。一般来说,armv7 在这些较新的处理器上速度更快,建议您至少在未来的应用程序中包含 armv7 构建(在仅限 iPad 的应用程序中,您可能只为 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.

作为Jasarien指出,指令集之间的最大差异的领域是浮点运算。在 armv6 上,应用程序倾向于使用简化的 Thumb 指令集构建以生成更小的二进制文件,但 Thumb 浮点性能很差。因此,如果您想要更快的浮点计算,您需要禁用 Thumb。在 armv7 上,Thumb-2 指令集不再有此限制,因此 Apple 建议您几乎一直使用它进行编译。

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.

您可以将 Thumb 构建设置设置为有条件的,以便它在旧设备上关闭而在新设备上打开。为此,请转到您的 Xcode 构建设置并选择 Compile for Thumb 选项。转到屏幕左下角的菜单,然后选择添加构建设置条件选项。在新建的build设置条件下,架构选择ARMv6,关闭Thumb,再添加一个条件,架构选择ARMv7,开启Thumb。

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.

根据这里的Stephen Canon 的回答,armv6 中的硬件支持单精度和双精度浮点运算。我发现单精度算术在这个平台上的性能稍好一些,这可能是因为更多的操作适合缓存。在 armv7 上,NEON SIMD 浮点单元仅适用于单精度运算,因此单精度运算和双精度运算之间的性能可能存在巨大差异。

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

其他可能对这个主题感兴趣的问题包括:

回答by Pierre Lebeaupin

To me, the main advantages of ARMv7 are:

对我来说,ARMv7 的主要优点是:

  • thumb-2
  • NEON
  • 拇指 2

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.

NEON 必须明确编码,你不能通过简单的重新编译来利用它,但如果你能投入时间,它可以将多媒体/游戏操作加速 8 倍。 然而,拇指 2 几乎是免费减少代码大小几乎没有缺点(与 ARMv6 上的拇指相反,这使得浮点代码与 ARM 模式相比要慢得多)。当然,在 ARMv7 中添加另一个版本的可执行文件不会减少可执行文件的大小,但会减少内存、缓存等中的代码。

回答by Alex Wayne

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.

如果您希望您的应用程序在 iPad 和所有 iPhone/iPod toch 型号上运行,您必须为两者编译。较旧的 iOS 设备使用 arm6,新设备使用 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.

不为一个或另一个编译的唯一原因是减少应用程序的大小,因为它只需要一个编译版本的代码。但是除非你有一个非常大的代码库,否则这个文件大小差异将非常小。

回答by Alex Argo

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.

arm7 针对 iPod Touch(第 3 代)和 iPhone 3GS 及更新机型进行了更优化。为旧设备构建时需要使用“标准/arm6+arm7”。在实践中,我在我的应用程序中没有看到太大的性能差异。