如何在i.MX6UL平台上实现硬浮点与软浮点?
本次开发使用的硬件平台为飞凌嵌入式OKMX6UL-C开发板(产品详情:www.forlinx.com/69.htm),其它板卡请酌情参考使用,具体实现操作步骤如下:
硬浮点交叉编译方法为
arm-linux-gcc -march=armv7-a -mfpu=neon -mfloat-abi=hard -o test test.c
加入编译参数 -mfloat-abi=hard,并且使用arm-linux-readelf -A test查看,如下:
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "7-A"
Tag_CPU_arch: v7
Tag_CPU_arch_profile: Application
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-2
Tag_FP_arch: VFPv3
Tag_Advanced_SIMD_arch: NEONv1
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_ABI_HardFP_use: SP and DP
Tag_ABI_VFP_args: VFP registers
Tag_DIV_use: Not allowed
采用的是Tag_ABI_VFP_args: VFP registers ,已经采用硬浮点了。
软浮点交叉编译方法:
arm-linux-gcc -o teset_soft test.c 并且使用arm-linux-readelf -A test_soft查看,如下:
Attribute Section: aeabi
File Attributes
Tag_CPU_name: "ARM10TDMI"
Tag_CPU_arch: v5T
Tag_ARM_ISA_use: Yes
Tag_THUMB_ISA_use: Thumb-1
Tag_ABI_PCS_wchar_t: 4
Tag_ABI_FP_denormal: Needed
Tag_ABI_FP_exceptions: Needed
Tag_ABI_FP_number_model: IEEE 754
Tag_ABI_align_needed: 8-byte
Tag_ABI_align_preserved: 8-byte, except leaf SP
Tag_ABI_enum_size: int
Tag_DIV_use: Not allowed
未使用VFP
测试结果:
进行10亿次加减乘除运算,硬浮点时间为1分34.8 软浮点时间为4分19.7。