EmbDev.net

Forum: ARM programming with GCC/GNU tools Advantages of Hard/Soft FPU Compiler Settings


Author: Patrick (Guest)
Posted on:

Rate this post
0 useful
not useful
Hello,
I'm working with Cortex-M4 MCU using its floating point unit.

It's possible to enable FPU support with following GCC commands:
-mfloat-abi=softfp or  -mfloat-abi=hard

I heard with SoftFloat the code is still compatible for MCUs without 
FPU.

Now my question is: Is there any disadvantage e.g. slower performance 
using SoftFloat instead of HardFloat ?

What is the code difference between Softfloat and Hardfloat and how is 
the Compiler/Controller handling it?

Kind regards,
Patrick

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 useful
not useful
The ABI defines how user code-calls (library-)functions. There are three 
methods:

(1) user-code calls by using the soft-abi, library's interface is 
soft-abi and the library uses FPU emulation

(2) user-code calls by using the soft-abi, library's interface is 
soft-abi and the library uses hardware-FPU (for example v*-commands on 
Cortex-M4)

(3) user-code calls by using hard-abi, library's interface is hard-abi 
and the library uses hardware-FPU

Libraries are for example the libraries which come with the toolchain 
(like libgcc). If libraries for all options are available and all code 
of the user-application can be recompiled the 3rd method may have the 
advantage that there is no need to transfer registers-content. I did not 
look too close into the generated assembly-code to give information 
about the "overhead", maybe somebody else can.

As far as I can see (I just made a few tests with STM32F4 Cortex M4 and 
GNU tools) the main advantage of the soft-abi is the possiblity to "mix" 
libraries which are only available as object code (archives/"a-files"). 
As long as the library has been compiled with soft-abi and it uses 
FPU-emulation internally it can be linked with every other object-code 
that uses the soft-abi and everything should work. For hard-ABI all 
object-code in the application has to be compiled with this setting and 
the hardware-FPU has be be enabled. If a library uses the soft-ABI but 
the hardware-FPU interally the interface is compatible with other code 
but if the FPU is not enabled there will be core-exceptions.

You may read the getting-started.pdf for Codebench lite from 
Mentor/Codesourcery for some more information and the GNU manuals for 
even more.

Hope this helps at least it little bit.

Author: Marcus Harnisch (mharnisch)
Posted on:

Rate this post
0 useful
not useful
Patrick wrote:
> Now my question is: Is there any disadvantage e.g. slower performance
> using SoftFloat instead of HardFloat ?

At least in theory, you will experience slightly lower performance. 
Whether this has a noticeable impact on you application depends on the 
actual code.

With softfp, floating point function parameters/return values will be 
passed in core registers, while hardfp will make use of VFP registers.

--
Marcus

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.