1

我有一个带有 Linux 操作系统的基于 ARM 的平台。尽管其基于 gcc 的工具链同时支持 hardfp 和 softfp,但供应商建议使用 softfp,并且该平台附带了一组标准和平台相关的库,这些库只有 softfp 版本。

我正在制作基于 OpenCV 和 tensorflow lite 的计算密集型 (NEON) AI 代码。按照供应商指南,我使用 softfp 选项构建了这些。但是,我感觉我的代码与其他有点相似的 hardfp 平台相比表现不佳。

代码性能是否取决于 softfp/hardfp 设置?我是否正确理解编译器为构建我的程序而生成的所有 .o 和 .a 文件也使用了 softfp 约定,这不太有效?如果是这样,是否有任何棘手的方法可以在内部使用 hardfp 调用约定,而对外部库使用 softfp?

4

2 回答 2

0

Normally, all objects that are linked together need to have the same float ABI. So if you need to use this softfp only library, i'm afraid you have to compile your own software in softfp too.

I had the same question about mixing ABIs. See here

Regarding the performance: the performance lost with softfp compared to hardfp is that you will pass (floating point) function parameters through usual registers instead of using FPU registers. This requires some additional copy between registers. As old_timer said it is impossible to evaluate the performance lost. If you have a single huge function with many float operations, the performance will be the same. If you have many small function calls with many floating variables and few operations, the performance will be dramatically slower.

于 2019-11-20T12:41:18.200 回答
-3

softfp选项仅影响参数传递。

换句话说,除非您float在调用函数时传递大量类型参数,否则与hardfp.

而且由于设计良好的项目严重依赖于传递指向结构的指针而不是许多单个值,所以我会坚持使用softfp.

于 2019-10-15T07:39:44.590 回答