Advantages of Hard/Soft FPU Compiler Settings

Guest #2721130
Rate this post
• ▲ 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
Guest #2721405
Rate this post
• ▲ 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.
#2722161
Rate this post
• ▲ 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

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.