Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Altera_Forum
Honored Contributor I
802 Views

FPU hardware not being used by Newlib

I am trying to build some code that uses plenty of math operations like powf, expf, logf, etc. 

I know that these are first translated into Newlib implementations which, in turn, should be using the underlying FPH2 that I have instantiated with a NiosII CPU. 

 

I see the custom instruction compile flags being used when I rebuild Newlib, but the code is way slower than I anticipated, and the disassembled code for the __ieee754_powf (as an example), contains many calls to soft-implemented floating point multiplications (__mulsf3), additions (__addsf3), subtractions (__subsf3), and divisions (__divsf3), as opposed to using the corresponding FPH2 custom instructions. 

 

While these simple operations are inferred in my own C code, then are not being propagated into the Newlib routines. 

So, if I use a floating point multiplication in my code, it uses the FPH2. 

If I use a powf (which translates to a Newlib soft implementation), it does not make use of the FPH2. 

 

What could I be missing here? 

 

 

Here is the command line that Eclipse executes for generating the Newlib: 

 

nios2-newlib-gen --no-multilib ./newlib-build-tmp ./newlib --custom " -O2 -g -Wall -mno-hw-div -mhw-mul -mno-hw-mulx -pg -fno-math-errno -mcustom-fabss=224 -mcustom-fadds=253 -mcustom-fcmpeqs=227 -mcustom-fcmpges=228 -mcustom-fcmpgts=229 -mcustom-fcmples=230 -mcustom-fcmplts=231 -mcustom-fcmpnes=226 -mcustom-fdivs=255 -mcustom-fixsi=249 -mcustom-floatis=250 -mcustom-fmuls=252 -mcustom-fnegs=225 -mcustom-fsubs=254 "
0 Kudos
1 Reply
Altera_Forum
Honored Contributor I
44 Views

Actually, I have just did an objdump on the libm.a from newlib and it does make use of the hardware FPU. 

So, somewhere I need to link to this libm.a instead of some other math library. 

 

How do I specify the Newlib libm.a instead of whatever it is trying to use??
Reply