Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Is this the optimal FIR filter on all platforms?

Reply
Thread Tools

Is this the optimal FIR filter on all platforms?

 
 
Sheldon Simms
Guest
Posts: n/a
 
      10-26-2003
On Sun, 26 Oct 2003 18:06:59 +0100, Johan Bergman wrote:

> Hi Sheldon, what kind of processor do you have? What is the clock frequency?


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

 
Reply With Quote
 
 
 
 
Johan Bergman
Guest
Posts: n/a
 
      10-26-2003
> 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


 
Reply With Quote
 
 
 
 
CBFalconer
Guest
Posts: n/a
 
      10-27-2003
Johan Bergman wrote: (and eliminated all attributions)
>
> > You are not initializing the input. Apart from the fact that the
> > behavior is undefined, as pointed out by previous posters, you
> > ought to be aware that floating-point arithmetic on infinities
> > and NaN's on Intel processors is much slower than floating-point
> > arithmetic on finite floating-point numbers. Your observed
> > slowdown is likely caused by a floating-point NaN that happens
> > to be in the uninitialized array.

>
> 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.

--
Chuck F ((E-Mail Removed)) ((E-Mail Removed))
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!

 
Reply With Quote
 
Johan Bergman
Guest
Posts: n/a
 
      10-27-2003
> > Independently of this problem, to answer the question in the title,
> > your FIR filter is not optimal on *any* platform that I can think of,
> > but the reason is way off-topic for this newsgroup. (It is also
> > suboptimal from a roundoff error point of view.)

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


 
Reply With Quote
 
Johan Bergman
Guest
Posts: n/a
 
      10-27-2003
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


 
Reply With Quote
 
Johan Bergman
Guest
Posts: n/a
 
      10-27-2003
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;
}


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: fir decimation filter in VHDL mindenpilot VHDL 1 11-21-2005 04:38 AM
Bitplane approach to FIR filter architecture Wiener, Norbert VHDL 4 11-18-2004 02:31 AM
info regarding digital low pass fir filter design in VHDL... dhaanya nair VHDL 0 02-26-2004 08:36 AM
FIR filter design + COE file Yttrium VHDL 1 02-15-2004 08:09 PM
FIR Filter Hari VHDL 3 01-30-2004 12:56 AM



Advertisments