[PD] P4 optimisation [for Linux?]

Olaf Matthes olaf.matthes at gmx.de
Sat May 24 18:49:47 CEST 2003


derek at x-i.net schrieb:

> i get these CPU jumps in a big way under Linux and Win both. i've been told it
> has a lot to do with signals which are very near zero, but not quite. johannes
> taelman told me the technical name for this, but i have forgotten it...
> "denormal numbers", maybe ....

That's right. The CPU switches to an 'extra accurate and very slow' (i.e. foating
point) mode when it is asked to calculate very small values. A fix in terms of
changing the source code it to add the following:

#define undenormalise(sample) if(((*(unsigned int*)&sample)&0x7f800000)==0)
sample=0.0

and add

undenormalise(myfloatvalue);

wherever a calculation might have produced very small values (reüplaye
'myfloatvalue' with the variable that stores the float). There are many many places
in the Pd sources (and in every external) where this happens. My freeverb~ (and also
cverb~) just wouldn't work work without his since reverb tails tend to get weaker
and weaker but (due to unaccurate calculation) probably never really get 0.0.

> anyway, if there are any patches which can be applied to a Linux compile of PD
> which are bug fixes for this, can somebody let me know? otherwise, how do people
> usually handle this.

I once realised that this problem (on Win) is reduced when I compile with the intel
compiler and optimisation for P4. Don't know if this would work for Linux as well.
The compiler can be downloaded from Intel and has a 30-day trial time, maybe someone
can give it a try.
'Fresh' P4-optimised binaries for Win can be downloaded from
http://www.akustische-kunst.org/puredata/experimental/pd0.36-win-P4.zip (based on
pd0.36-0 since pd0.37-test4 does not work with my Motu 828). Just unzip the files
into Pd's bin directory.

> thomas musil says he just pumps a very small signal that is
> over this threshold through the whole system. could you also "clip~" the signal
> streams, except to clip them on the low end?

The trick is to avoid signals of getting below a certain limit. The code above does
this by setting them to 0.0, adding a signal does it by always keeping the signals
above this threshold.

Olaf





More information about the Pd-list mailing list