如何在i.MX6UL平臺上實現硬浮點與軟浮點?
本次開發使用的硬件平臺為飛凌嵌入式OKMX6UL-C開發板(產品詳情:www.powerye.cn/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。