S32K344 Double Precision Support

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

S32K344 Double Precision Support

Jump to solution
5,085 Views
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 Kudos
Reply
1 Solution
5,057 Views
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

 

 

View solution in original post

3 Replies
5,038 Views
tony-atlismv
Contributor III

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

Tony

0 Kudos
Reply
5,044 Views
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 Kudos
Reply
5,058 Views
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