S32K344 Double Precision Support

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

S32K344 Double Precision Support

跳至解决方案
5,058 次查看
tony-atlismv
Contributor III

I would like to know if the S32K344 FPU supports double precision floating point? Per the S32K3xx datasheet, only single precision is mentioned, which I believe is referenced to fpv5-sp-d16? Per the ARM Cortex-M7 website, double precision is supported, but only as an option. So, I believe this is up to the MCU manufacturer? 

For the S32K344, I am using NXP's GCC 10.2 for Arm 32-bit Bare-Metal compiler that came with the S32DS IDE, which includes a C math library based on doubles. So, I'm wondering how much precision is lost when using the double precision math library on a single precision FPU with the S32K344 (per the S32K3xx datasheet)? Is there a single precision math library that supports all floats instead of doubles for the S32K344? Or do I have to cast all doubles to floats and loose precision in regard to using the C math library functions? Or does the NXP compiler handle double precision math with additional ARM instructions for the single precision FPU?

Thanks.

0 项奖励
回复
1 解答
5,030 次查看
kef2
Senior Contributor V

Hi,

K3 like K1 seem having single precision FPU. But if you wonder about S32 DS, it supports software emulated double precission math.

  • library based on doubles. 

It isn't based on doubles, it is full featured by default: single precision functions sinf(), cosf(), etc utilizing SP FPU, and double precision functions sin(), cos(), .. using software FP emulation for double precision math.

  • I'm wondering how much precision is lost when using the double precision math library on a single precision FPU with the S32K344 (per the S32K3xx datasheet)?

Hm. If vendor would take source code for DP FP math and just replaced all DP objects with SP objects, it would be not only much slower due to extra pointless multiplies and additions, but as well calculation accuracy would be worse than using SP optimized library. 

  • Or do I have to cast all doubles to floats and loose precision in regard to using the C math library functions? Or does the NXP compiler handle double precision math with additional ARM instructions for the single precision FPU?

Hm, I fear I don't understand these questions.

If you need double precision then just use doubles. If single precision is enough, then just switch Float ABI setting in your project to "FPU SP only". It will make all doubles treated as floats. 

kef2_0-1670152281017.png

 

 

在原帖中查看解决方案

3 回复数
5,011 次查看
tony-atlismv
Contributor III

Thanks for all of the replies! The information was very helpful!

Tony

0 项奖励
回复
5,017 次查看
davidtosenovjan
NXP TechSupport
NXP TechSupport

S32K3 uses single point floating point configuration (fpv5-sp-d16).

In the S32DS, there is an option choosing whether floating point operation are software or hardware, anyway double bit precision will be HW emulated.

davidtosenovjan_0-1670241900010.png

 

0 项奖励
回复
5,031 次查看
kef2
Senior Contributor V

Hi,

K3 like K1 seem having single precision FPU. But if you wonder about S32 DS, it supports software emulated double precission math.

  • library based on doubles. 

It isn't based on doubles, it is full featured by default: single precision functions sinf(), cosf(), etc utilizing SP FPU, and double precision functions sin(), cos(), .. using software FP emulation for double precision math.

  • I'm wondering how much precision is lost when using the double precision math library on a single precision FPU with the S32K344 (per the S32K3xx datasheet)?

Hm. If vendor would take source code for DP FP math and just replaced all DP objects with SP objects, it would be not only much slower due to extra pointless multiplies and additions, but as well calculation accuracy would be worse than using SP optimized library. 

  • Or do I have to cast all doubles to floats and loose precision in regard to using the C math library functions? Or does the NXP compiler handle double precision math with additional ARM instructions for the single precision FPU?

Hm, I fear I don't understand these questions.

If you need double precision then just use doubles. If single precision is enough, then just switch Float ABI setting in your project to "FPU SP only". It will make all doubles treated as floats. 

kef2_0-1670152281017.png