PDA

View Full Version : Denormals


junioreq
12-08-2009, 03:10 PM
What are you guys doing for denormal removal. I was using this:

double catchdenorms = 0.0000000000000000001;
catchdenorms = catchdenorms + 0.000000001;
catchdenorms = catchdenorms - 0.000000001 ;

No luck:

Still shooting up to 20% cpu on idle.

~Rob.

bvesco
12-09-2009, 09:30 AM
There are some denormal macros in the WDL though I don't remember where off-hand and don't have my code right next to me to check.

However, you have a flaw in your approach as you don't add/subtract from some arbitrary number. You have to add/subtract from the value that is causing the denormal. Find the spot in your audio processing algorithm that is denormaling and do something like:

currSample += denormalizer;
currSample -= denormalizer;

That's pretty much what the WDL macro does as I remember it. Basically in your audio code it will end up looking something like:

DENORMAL(currSample);

Tale
01-13-2010, 04:31 AM
There indeed is a denorm fix included in verbengine.h:

#include "verbengine.h"

...

double sample;

... // Generate/parse the sample, e.g. apply a low-pass filter

WDL_VERB_FIXDENORM((unsigned int *)&sample);

Tale
04-16-2010, 01:43 AM
The WDL v2010.04.15 update now contains a range of denormal functions. This means the above fix doesn't work anymore, but e.g. this does:

#include "denormal.h"

...

double sample;

... // Generate/parse the sample, e.g. apply a low-pass filter

denormal_fix_double(&sample);

junioreq
05-07-2010, 10:01 PM
Where do I put this, in this code:

http://musicdsp.org/files/CFxRbjFilter.h

I think xenakios gave me a denormal free version, but I had a HD failure..

seems when I do this, it doesn't pass audio:


float filter(float in0)
{

//fix denormals

WDL_VERB_FIXDENORM((unsigned int *)&in0);

// filter
float const yn = b0a0*in0 + b1a0*in1 + b2a0*in2 - a1a0*ou1 - a2a0*ou2;



~Rob.

Getting 90% cpu lol denorms, old version too... not updating..

Tale
05-08-2010, 03:31 AM
I think in your example the denormals will occur at the filter's output, not the input, e.g.:

#include "denormal.h"

...

float filter(float in0)
{
// filter
float yn = b0a0*in0 + b1a0*in1 + b2a0*in2 - a1a0*ou1 - a2a0*ou2;

// fix denormals
denormal_fix_float(&yn);

// push in/out buffers
in2=in1;
in1=in0;
ou2=ou1;
ou1=yn;

// return output
return yn;
}

junioreq
05-08-2010, 07:56 AM
Nope, doesn't work there :( I am using 6 of these, one of which is a HP filter. Still no luck. It does pass audio when I put it there, but the cpu goes from .7 to 5.0 and then when I stop audio it shoots up the same as before :(

~Rob.

bvesco
05-08-2010, 11:14 AM
The first thing you'll need to do which none of us can help you with is trace through your code and find the spot that is causing the denormals. You can also instead find all spots with the potential to cause denormals. Put a denormal fixer in each spot. This should be super cheap on processing power. On my old Athlon machine it had no noticeable affect on the final measured performance (in Reaper) when I put a denormal fixer on every single filter of an EQ. I did that because the output of each individual filter had the potential to be a denormal which would feed into the input of the next filter in line and slow it down. It works great. I use the +/- method (housed in a macro). Find those spots in your code and put it in.

junioreq
05-08-2010, 12:20 PM
ahh.. I was under the impression that just putting it in front or maybe behind one filter in the chain would solve, lemme try this.

~Rob.

Justin
06-01-2010, 06:06 PM
If you're using an IIR filter, you'd want to prevent denormals inside the filter...