Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12409 Discussions

FPU hardware not being used by Newlib

Altera_Forum
Honored Contributor II
898 Views

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 II
140 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