Is this the optimal FIR filter on all platforms?

J

Johan Bergman

That's an Athlon XP 1800+ / Red Hat 9

Ok, you got about the same execution time as I did on my Linux/x86 platform,
about 1100 million cycles.

Regards,
Johan
 
C

CBFalconer

Johan Bergman wrote: (and eliminated all attributions)
But in my example, I only worked with integers! (By the way,
float/double actually proved to be a lot fast than int on all
tested platforms.)

You still have code with undefined behaviour. Why don't you first
fix the code and stop wasting all our time with this nonsense.
 
J

Johan Bergman

Independently of this problem, to answer the question in the title,
Well, as I wrote, I realize that an FFT approach would be beneficial for
such a long FIR filter. But apart from that, are there any other
optimizations that you can think of? In that case I would be most interested
in hearing them! The best would be to get a piece of code, of course! :)

In your last post, you forgot to answer this question. What are the
optimizations you are thinking of?

Regards,
Johan
 
J

Johan Bergman

Hi Chuck, forgot about the question in my last post:
In your last post, you forgot to answer this question. What are the
optimizations you are thinking of?

I thought you were someone else (Matteo).

Regards,
Johan
 
J

Johan Bergman

Some of you requested a cleaned-up program. Here it is. The first lines
might contain some C++, sorry about that.

I also changed the data type from int to float since it seems to give better
performance on some popular platforms (sun4u sparc and newer x86
processors).

Note: I am aware of the benefits with an FFT approach for such long FIR
filters.

Regards,
Johan


#include <stdlib.h>

int main(void)
{
const int nrof_lags = 10000;
const int nrof_taps = 10000;
float coeff[nrof_taps] = {0};
float input[nrof_taps+nrof_lags-1] = {0};
float output[nrof_lags] = {0};

float sum;
int lag, tap;
float *tmp_coeff_ptr;
float *tmp_input_ptr;
float *tmp_output_ptr = output;
for (lag=0; lag<nrof_lags; lag++)
{
tmp_coeff_ptr = coeff;
tmp_input_ptr = input + lag;
sum = 0;
for (tap=0; tap<nrof_taps; tap++)
{
sum += *tmp_coeff_ptr++ * *tmp_input_ptr++;
}
*tmp_output_ptr++ = sum;
}

return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top