I'm using intel xeon harpertown (E5450) and Python 2.6.4.<div><br></div><div>In the cython code, when I use fpclassify, in the slow case I get 3 (FP_SUBNORMAL)<br><div><div>In the pure-C code, when I use fpclassify, in the case that's supposed to be slow but it's not, I get a 2 (FP_ZERO)</div>
<div><br></div><div>Somehow, the FPU's have different results for exactly the same asm code.</div><div><br></div><div>--mihai</div><div><br><div><div class="gmail_quote">On Tue, Apr 26, 2011 at 11:06 PM, David Cournapeau <span dir="ltr"><<a href="mailto:cournape@gmail.com">cournape@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Wed, Apr 27, 2011 at 4:14 AM, Dan Goodman <<a href="mailto:dg.gmane@thesamovar.net">dg.gmane@thesamovar.net</a>> wrote:<br>

> Hi,<br>
><br>
> On <a href="tel:26%2F04%2F2011%2015" value="+12604201115">26/04/2011 15</a>:40, Mihai Badoiu wrote:<br>
>> I have terrible performance for multiplication when one number gets very<br>
>> close to zero.  I'm using cython by writing the following code:<br>
><br>
> This might be an issue with denormal numbers:<br>
><br>
> <a href="http://en.wikipedia.org/wiki/Denormal_number" target="_blank">http://en.wikipedia.org/wiki/Denormal_number</a><br>
><br>
> I don't know much about them though, so I can't advise any further than<br>
> that...<br>
<br>
</div>This indeed sounds like it. Mihai, which CPU are you using ? Pentium4<br>
are especially known to have terrible (read order of magnitude slower)<br>
performance with denormal numbers.<br>
<br>
There is unfortunately no simple way to know whether a float is<br>
denormal or not in python, but since you are using cython, if you are<br>
under posix you should be able to use fpclassify to check this,<br>
<br>
>From there, if you see a difference between cython/python and C, it<br>
will be easier to debug.<br>
<br>
cheers,<br>
<font color="#888888"><br>
David<br>
</font><div><div></div><div class="h5">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br></div></div></div></div>