[PlanetCCRMA] Pentium-4 and denormal numbers on planetccrma

Fernando Lopez-Lezcano nando@ccrma.Stanford.EDU
Fri Jan 28 16:34:00 2005


On Fri, 2005-01-28 at 16:01, Fernando Lopez-Lezcano wrote:
> On Fri, 2005-01-28 at 15:35, Steve Harris wrote:
> > On Fri, Jan 28, 2005 at 03:17:41PM -0800, Fernando Pablo Lopez-Lezcano wrote:
> > > On Fri, 2005-01-28 at 14:51, Fernando Lopez-Lezcano wrote:
> > > > On Wed, 2005-01-12 at 03:40, Steve Harris wrote:
> > > > > On Mon, Jan 10, 2005 at 11:07:55 +0100, andersvi@extern.uio.no wrote:
> > > > > NB, using the SSE instruction set uses a more efficient denormal handler
> > > > > (about 40x slower than processing a normal number), but it still doesnt
> > > > > zero them, if you also call this function I hacked up when the program
> > > > > starts:
> > > > 
> > > > Hi Steve, I'm trying to use this to see if I can get freeverb back from 
> > > > denormal hell, but I can't compile it as position independent code as in
> > > > that mode the compiler uses the bx register (I did some searches but
> > > > could not find a solution that both compiled and did not segfault :-)
> > > 
> > > I tried adding noise to the inputs (from
> > > http://www.musicdsp.org/files/denormal.pdf):
> > > 
> > > unsigned int rand_state = 1;
> > > 
> > > inline add_white_noise (float &val) {
> > >   rand_state = rand_state * 1234567UL + 890123UL;
> > >   int mantissa = rand_state & 0x807F0000;
> > >   int flt_rnd = mantissa | 0x1e999999;
> > >   val += *reinterpret_cast <const flat*> (&flt_rnd);
> > > }
> > > 
> > > And while it is a hack it did work, surprisingly. 
> > > Perhaps not the best solution.....
> > 
> > Its a perfectly reasonable solution, sorry, I should have suggested it.
> > The thing to test would be to turn up the RT60 time as high as posible and
> > measure the amplitude of the output to see how much it affects the SNR.
> 
> I just tried this: I connected hydrogen to jack-rack running the hacked
> freeverb (max wet output, no dry output, max room size, 0 damping, 0.5
> width) and jack-rack to bitscope. After stopping hydrogen the "smallest
> non-zero sample" shown on bitscope slowly falls down to a noisy -400db
> (the "largest sample" field hovers around -336db). Bitscope is handy :-)
> As much as I hate to introduce "noise" in the signal chain I think most
> probably -300db is quiet enough. I can't hear it, but maybe its just my
> aging ears :-)

Some more tests for the record (and another day is almost gone)

- cmt 1.15, no patches --> no reverb
- cmt 1.15, undenormal #define redefined to do nothing:
  it takes a long long time for the internal stuff to decay and generate
  denormals, when that happens cpu load goes up to almost 100%
- cmt 1.15, undernormal #define redefined to:
  static inline float
  undenormalise(volatile float s)
  {
   s += 9.8607615E-32f;
   return s - 9.8607615E-32f;
  }
  it takes significantly less for the cpu load to go up, and it "only"
  goes up to 50/60% (from a standard of ~15% on a P4 1.7G).

So, I think I will release a package with the "white noise added to
input" solution (no optimization, it would be possible to use a table
but I don't think it is worth it in terms of wasted cpu), and with the
built in denormal code turned off. 

-- Fernando