S32K344 Double Precision Support

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

S32K344 Double Precision Support

ソリューションへジャンプ
5,064件の閲覧回数
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,036件の閲覧回数
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,017件の閲覧回数
tony-atlismv
Contributor III

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

Tony

0 件の賞賛
返信
5,023件の閲覧回数
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,037件の閲覧回数
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