the difference between library with FP (softfp) and library with FP (hard) in s32k144

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

the difference between library with FP (softfp) and library with FP (hard) in s32k144

Jump to solution
1,076 Views
zhangchun
Contributor III

hello

I tested library with FP (softfp) and FP instructions(hard) using the attached example.

zhangchun_0-1690981466857.jpeg

 

I found that there is no difference in performance between these two floating-point operations. However, from this document(S32K14x系列MCU使用Tips之硬件FPU特性介绍和使用详解 ), it can be seen that hard uses fpu registers, which should have a more significant improvement in floating-point performance.

zhangchun_1-1690981642582.png

 

Now, I don't quite understand how to use hardware floating-point operations in S32K44

thanks

Tags (1)
0 Kudos
Reply
1 Solution
947 Views
Mehul_Patel_NXP
NXP Employee
NXP Employee

Hi, @zhangchun ,

 

I understand looking at the screenshot that you got the no performance improvement.

 

But I feel it may be that because the test case you are trying for performance evaluation is not enough to test, if possible please can you try with more complex floating point operation and more iteration, and check what the result comes. Do also check the disassembly to see what is happening underneath. 

 

Thank you. Kind regards.

- Mehul Patel

View solution in original post

0 Kudos
Reply
5 Replies
980 Views
Mehul_Patel_NXP
NXP Employee
NXP Employee

Hi, @zhangchun 

Hard FP (floating point) will use the FP instructions of the device whereas soft FP will defer to software emulation of FP operations. That is, FP operations are performed by making a library call and the floating point operations are performed using integer instructions.

  • The only difference between softfp and hard is the manner in which floating point values are passed and received from functions. (softfp ABI vs. hard ABI). 
  • Both softfp and hard will generate floating point instructions, but since you do not pass the float values to functions, you will see no difference.
  • So, to truly see a difference between a software float operation and a hardware float operation, use the 'soft' option.
  •  
  • To understand more about it please check this page: https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html

 

Mehul_Patel_NXP_1-1691423669538.png

 

Now, another thing, you can check generate the disassembly file and understand the difference for different float ABI options - soft, hard, and library with FP. 

Mehul_Patel_NXP_2-1691423875334.png

 

Additionally, sometime compiler might optimization also play role, and if the operation is not resource intensive compiler might decide to do differently than you are expecting. You can also check different test case operation to ty out. 

You can change the optimization settings and check accordingly if it improves the performance or not: 

Mehul_Patel_NXP_3-1691424230427.png

Please, can you check and tryout, let us know if you are able to get performance improvement accordingly. 

Thank you, Best regards, 

- Mehul Patel

 

0 Kudos
Reply
964 Views
zhangchun
Contributor III

@Mehul_Patel_NXP 

Dear Mehul_Patel_NXP

I know that Library (soft) will take more time than Library with FP (softfp) or FP instructions (hard). However, FP instructions (hard) use FPU hardware registers, which should take less time than library with FP (softfp), but in reality they do not differ.

 

Based on your suggestion, I performed the operation by calling the function, and the result obtained was the same

zhangchun_2-1691496427922.png

 

My purpose in doing this was to use FP instructions (hard) to improve code execution efficiency, but the result did not achieve my expected goal. During this process, it was found that there was no difference between library with FP (softfp) and FP instructions (hard).

 

Currently, it has been determined to use FP instructions (hard) by reviewing the assembly and compilation parameters

zhangchun_1-1691496402554.png

 

Thank you for your response.

 

0 Kudos
Reply
996 Views
zhangchun
Contributor III
If library with FP (softfp) or FP instructions (hard) are not used in the compilation options, it will indeed take more time, but there is no difference between library with FP (softfp) and FP instructions (hard), which is still incomprehensible
0 Kudos
Reply
948 Views
Mehul_Patel_NXP
NXP Employee
NXP Employee

Hi, @zhangchun ,

 

I understand looking at the screenshot that you got the no performance improvement.

 

But I feel it may be that because the test case you are trying for performance evaluation is not enough to test, if possible please can you try with more complex floating point operation and more iteration, and check what the result comes. Do also check the disassembly to see what is happening underneath. 

 

Thank you. Kind regards.

- Mehul Patel

0 Kudos
Reply
930 Views
zhangchun
Contributor III

@Mehul_Patel_NXP 

Dear Mehul_Patel_NXP

I have a few more questions

  1. Is it necessary to call the math library in cmsis to use the fpu register when using FP (hard) in s32k144? If needed, please tell me how to proceed
  2. I am currently trying to use the AMMCLib, but the performance has not improved either(The AMMCLib is designed to improve performance, and in my opinion, floating-point operations are used the FP hard))

zhangchun_0-1691558555301.png

 

Thanks

0 Kudos
Reply