[linux-audio-dev] Re: Fixing Freeverb and Denormals

Neil Klepeis nklepeis at sbcglobal.net
Sat Jan 22 13:01:37 UTC 2005


Steve,

OK.  I put your denormal-zeroing function w/SSE into the freeverb.cpp 
code, and when compiling with the SSE option and calling 
set_denormal_flags() in the activateFreeverb3 function (see below), I 
get this error wherever asm is called:

freeverb/freeverb.cpp: In function `void set_denormal_flags()':
freeverb/freeverb.cpp:48: error: can't find a register in class `BREG' 
while reloading `asm'

Do you have an idea of what might be wrong?

Here is where I put the call to your function.  Does this make sense?

void
activateFreeverb3(LADSPA_Handle Instance) {
   Freeverb3 * poFreeverb = (Freeverb3 *)Instance;
   poFreeverb->mute();
   /* call the Steve Harris denormal zeroing function w/SSE flag */
   set_denormal_flags();
}


--Neil


PS: Maybe we should move this discussion to just linux-audio-dev for now


PPS: For reference, this is your function for zeroing denormals w/SSE 
that I am using:

#ifdef __SSE__
#include <xmmintrin.h>
#endif

void set_denormal_flags()
{
     unsigned long a, b, c, d;

#ifdef __SSE__

     asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (1));
     if (d & 1<<25) { /* It has SSE support */
         _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);

         asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (0));
         if (b == 0x756e6547) { /* It's an Intel */
             int stepping, model, family, extfamily;

             family = (a >> 8) & 0xf;
             extfamily = (a >> 20) & 0xff;
             model = (a >> 4) & 0xf;
             stepping = a & 0xf;
             if (family == 15 && extfamily == 0 && model == 0 && 
stepping < 7) {
                 return;
             }
         }
         asm("cpuid": "=a" (a), "=b" (b), "=c" (c), "=d" (d) : "a" (1));
         if (d & 1<<26) { /* bit 26, SSE2 support */
             _mm_setcsr(_mm_getcsr() | 0x40);
         }
     } else {
         fprintf(stderr, "This code has been built with SSE support, but 
your processor does not support\nthe SSE instruction set.\nexiting\n");
         exit(1);
     }
#endif
}



-------------Steve Harris wrote:---------------

For something like a reverb the best option is going to be to build with
SSE maths and call the function I posed here a week ago or so. There are
so many places where denormals can occur in reverbs that youre going to
burn a load of CPU trying to kill them.

OTOH I'm not sure how that function would interact with the host when
loaded as a plugin






More information about the Linux-audio-dev mailing list