If you are compiling with SSE and/or SSE2 instructions enabled, you could consider enabling the floating point &quot;Flush-to-zero&quot; mode and maybe (if supported on the processor) enable &quot;denormals are zero&quot;.  The flush-to-zero is probably the more important of the two.<div>
<br></div><div><a href="http://software.intel.com/en-us/articles/x87-and-sse-floating-point-assists-in-ia-32-flush-to-zero-ftz-and-denormals-are-zero-daz/">http://software.intel.com/en-us/articles/x87-and-sse-floating-point-assists-in-ia-32-flush-to-zero-ftz-and-denormals-are-zero-daz/</a><br>
<div><br></div><div><br></div><div><br><div class="gmail_quote">On Wed, Sep 23, 2009 at 4:06 AM, Jean-Marc Valin <span dir="ltr">&lt;<a href="mailto:jean-marc.valin@usherbrooke.ca">jean-marc.valin@usherbrooke.ca</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Mark Schilling a écrit :<br>
<div class="im">&gt; I recompiled with FIXED_POINT and CPU utilization stays below 4%. This is a great improvement.<br>
&gt; So how can I fix this to work with floating point ?<br>
<br>
</div>OK, so it looks a lot like a denorm problem. The issue is basically that<br>
there are filters that decay exponentially, so when the input suddenly<br>
goes to zero, then the filter&#39;s output value becomes smaller and smaller<br>
until it reaches ~1e-37. At that point, your CPU takes &gt;10x the normal<br>
time to make calculations (why is beyond me).<br>
<br>
Now, the work-around is to prevent some signals from going to exacly<br>
zero. Have a look at how the VERY_SMALL macro is currently being used.<br>
It&#39;s defined as 0 for fixed-point, but 1e-15f for float. By adding that<br>
value to the right signal(s), you can prevent denormalized numbers from<br>
being generated. The key is to find that place or those places. A<br>
profiler may be able to tell you where the problem happens so you can<br>
add VERY_SMALL just before that place. I suspect that just doing that at<br>
the output of the preprocessor may be enough but I&#39;m not sure.<br>
<br>
Cheers,<br>
<font color="#888888"><br>
        Jean-Marc<br>
</font><div class="im"><br>
<br>
&gt; Thanks.<br>
&gt;<br>
&gt; Mark<br>
&gt;<br>
&gt; -----Ursprüngliche Nachricht-----<br>
&gt; Von: Jean-Marc Valin [mailto:<a href="mailto:jean-marc.valin@usherbrooke.ca">jean-marc.valin@usherbrooke.ca</a>]<br>
&gt; Betreff: Re: [Speex-dev] High CPU usage<br>
&gt;<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; Sound like it could be the good old denormalised float problem on the Intel chips. Just to make sure, can you try compiling in fixed-point<br>
&gt; (FIXED_POINT) and see if the problem goes away (it&#39;s not a fix, just a test)? If that&#39;s the case, there&#39;s probably a few VERY_SMALL&#39;s to add to some signals.<br>
&gt;<br>
&gt; Cheers,<br>
&gt;<br>
&gt;       Jean-Marc<br>
&gt;<br>
&gt;<br>
&gt; Mark Schilling a écrit :<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; I have a curious problem with speex. As long as I&#39;m talking, it takes about 2-5% of my CPU. This seems ok.<br>
&gt;&gt; But as soon as I stop talking, CPU utilization rises to about 30-45% and stays there until I start talking again.<br>
&gt;&gt;<br>
&gt;&gt; I compiled speex from source and use it with these settings:<br>
&gt;&gt; - Preprocessor: Denoiser = ON, AGC = ON<br>
&gt;&gt; - Encoder: ABR = 15000, DTX = 1, Mode = narrowband, Rate = 8000 Hz.<br>
&gt;&gt;<br>
&gt;&gt; My platform: Windows XP SP3, MSVS 2008 SP1, 1.8 GHz Core Duo CPU, 2 GB RAM.<br>
&gt;&gt;<br>
&gt;&gt; Thanks for your help :-)<br>
&gt;&gt; Mark<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
&gt;<br>
</div><div><div></div><div class="h5">_______________________________________________<br>
Speex-dev mailing list<br>
<a href="mailto:Speex-dev@xiph.org">Speex-dev@xiph.org</a><br>
<a href="http://lists.xiph.org/mailman/listinfo/speex-dev" target="_blank">http://lists.xiph.org/mailman/listinfo/speex-dev</a><br>
</div></div></blockquote></div><br></div></div>