arm linux fpu,多媒体处理,利用ARM NEON/FPU提升performance

在有些软件中需要大量的浮点运算,举个例子; 音频处理。

如果所用的CPU不带FPU,这些运算就要用软件实现,举个例子:

其中乘法操作,可能会用 __aeabi_dmul 来代替,

The ARM floating-point environment is an implementation of the IEEE 754-1985 standard for

binary floating-point arithmetic.

An ARM system might have:

? a VFP coprocessor

? no floating-point hardware.

If you compile for a system with a hardware VFP coprocessor, the ARM compiler makes use of

it. If you compile for a system without a coprocessor, the compiler implements the computations

in software. For example, the compiler option --fpu=vfp selects a hardware VFP coprocessor

and the option --fpu=softvfp specifies that arithmetic operations are to be performed in

software, without the use of any coprocessor instructions.

具体请参考:

__aeabi_dmul 2 double double Return x times y

这样会很慢。

如果硬件支持FPU,可以直接使用FPU来运算。

例如: 上面的double 乘法操作,会直接使用 :

vmul.f64 来完成,这样会很快。

我谢了一段code做了一个测试;

volatile double para_1 = 10.10;

volatile double para_2 = 10.10;

volatile double result;

int index;

for(index=0;index<0x1000000;index++)

{

result = para_1 * para_2;

}

同样的10M 次乘法操作,如果不使用FPU,消耗大约 1700ms 如果利用FPU,只需要350ms左右。

除法运算差异更大;   如果不适用FPU,需要6,700 ms ,使用FPU 只需要515ms

如果CPU有FPU,则尽可能把他们利用起来,可以大幅度提升performance。

另外ARM根据不同CPU给出了另外的优化建议;

例如,Cortex A9 可以参考:

Cortex?-A9 Floating-Point Unit

Revision: r4p1

Technical Reference Manual

==> 1.3 Writing optimal FP code

另外,如果用的是Cortex-A 的ARM,同时可以考虑利用NEON来优化。具体请参考:  Introducing NEON Development Article

It extends the SIMD concept by defining groups of instructions operating on vectors stored in 64-bit D, doubleword, registers and 128-bit Q, quadword, vector registers.

NEON这个feature已经集成到了gcc,可以直接使用。

NEON intrinsics with GCC

To use NEON intrinsics in GCC, you must specify -mfpu=neon on the compiler

command line:

arm-none-linux-gnueabi-gcc -mfpu=neon intrinsic.c

Depending on your toolchain, you might also have to add -mfloat-abi=softfp to indicate

to the compiler that NEON variables must be passed in general purpose registers.

A complete list of supported intrinsics can be found at

===>另外注意NEON跟VFP不是绝对存在的,但是ARM建议是有VFP就有NEON (Cortex-A系列都实现了NEON,)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值