Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
12 years ago

FP Custom Instructions - exp() won't get any faster

Hi everybody.

I'm working on a design using Nios II/f that heavily relies on floating point math.

In Qsys I addedd Floating Point Hardware and I connected it to the Custom Instruction Master of the Nios II.

Apparently everything works.

My design is a Neural Network, so basically I have a loop of multiplication\addition and a loop of exponential calculus.

The first loop gets faster (about 10x), the second one doesen't change at all.

I tried to make a benchmark code, something like:

Performance Start
float a = 10;
for(i = 0; i < 1000; i++)
a = exp(a);
Performance End

And run it with and without the following pragmas:

# pragma no_custom_fadds# pragma no_custom_fsubs# pragma no_custom_fmuls# pragma no_custom_fdivs

The performance (about 6Mcycles if I remember correctly) doesen't change.

Hardware divide is enabled both in the Floating Point Hardware module and in the Nios II/f.

My doubt is that since i'm using qsys and not sopc i didn't find the "custom instructions" tab in the Nios II module where to specify the usage of FP Hardware, I assumed that in Qsys when you connect the module the FP hardware is always used unless de-activating pragmas are declared.

Maybe I was wrong here?

These are my includes:

# include <stdio.h># include "io.h"# include <sys/alt_alarm.h># include <altera_avalon_performance_counter.h># include "system.h"# include <math.h># include <float.h>

Thanks for the help! :)

12 Replies