Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.84.MISMATCH!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'int': 0.05; 'behavior.': 0.07; 'python': 0.07; 'correct.': 0.09; 'looked': 0.10; 'candidate': 0.11; 'pm,': 0.11; 'wrote:': 0.14; 'fpu': 0.16; 'thanks!': 0.18; 'tue,': 0.20; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'code,': 0.20; 'code': 0.22; 'header:In-Reply- To:1': 0.22; 'cc:addr:python-list': 0.22; '(without': 0.23; 'problem?': 0.23; 'received:209.85.214.174': 0.23; 'received:mail- iw0-f174.google.com': 0.23; 'runs': 0.24; "what's": 0.24; 'url:mailman': 0.27; 'tried': 0.27; 'message-id:@mail.gmail.com': 0.28; 'looks': 0.28; 'hi,': 0.29; 'cc:addr:python.org': 0.31; 'zero.': 0.31; 'url:listinfo': 0.33; 'lines': 0.34; 'using': 0.34; 'print': 0.35; 'received:209.85': 0.37; 'url:python': 0.37; 'exactly': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'code:': 0.38; 'url:org': 0.38; 'received:209.85.214': 0.39; 'received:209': 0.39; 'how': 0.39; 'sets': 0.40; "it's": 0.40; 'header:Received:5': 0.40; 'best': 0.60; '2011': 0.62; '26,': 0.68; 'double': 0.69; '0.8': 0.84; "\xa0i'm": 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=0YAXM867DcAdoRql0uavmJnmPqmas5AsnC8ToZfRtTk=; b=a0mpr/kAnd+wVaSN557anUwHK92Nqb9UqKzULofyIUKoMoXnfhSV9NUfC8+Gk3NJr5 Za6x6lOb7gOtdK9ayyqVIzR6i/M8inMhTAbE1h3IYdTEBBJzaFtzIHSfnwRSOBsOBwtw 0UHlG2rcGzsLuuX/CDpN9JkuCTEc6dF/XVCh0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=FtDvnt6Gg758teMoIpSdBvOFINbyC0HibSSjup2NyBj1jDp6NjDUZS7r+PhBDwJKc2 /ADJPSlbIWBbRBB9fFPjZwiNjtaaIN2foeD0ePEnHjVwAKnwtEcM91u6yTpzsn9nfH2v ARZy8eehBw+yWs3okMxucF9HmFnO+GrLLlSMQ= MIME-Version: 1.0 In-Reply-To: References: Date: Wed, 27 Apr 2011 15:11:40 +1000 Subject: Re: Terrible FPU performance From: Alec Taylor To: Mihai Badoiu Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303881103 news.xs4all.nl 81474 [::ffff:82.94.164.166]:36035 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4105 What's an FPU? On Tue, Apr 26, 2011 at 11:40 PM, Mihai Badoiu wrote: > Hi, > I have terrible performance for multiplication when one number gets very > close to zero. =A0I'm using cython by writing the following code: > =A0 =A0 cdef int i > =A0 =A0 cdef double x =3D 1.0 > =A0 =A0 for 0 <=3D i < 10000000: > =A0 =A0 =A0 =A0 x *=3D 0.8 > =A0 =A0 =A0 =A0 #x +=3D 0.01 > =A0 =A0 print x > This code runs much much slower (20+ times slower) with the line x +=3D 0= .01 > uncommented. =A0I looked at the deassembled code and it looks correct. > =A0Moreover, it's just a few lines and by writing a C code (without pytho= n on > top), I get the same code, but it's much faster. =A0I've also tried using= sse, > but I get exactly the same behavior. =A0The best candidate that I see so = far > is that Python sets up the FPU in a different state than C. > Any advice on how to solve this performance problem? > thanks! > -- > http://mail.python.org/mailman/listinfo/python-list > >