From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 999 invoked by alias); 29 Apr 2013 12:32:38 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Received: (qmail 941 invoked by uid 48); 29 Apr 2013 12:32:35 -0000 From: "wbrana at gmail dot com" To: glibc-bugs@sourceware.org Subject: [Bug math/14412] Removal of sysdeps/x86_64/fpu/s_sincos.S causes regressions Date: Mon, 29 Apr 2013 12:32:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: math X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: wbrana at gmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: 2.18 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2013-04/txt/msg00212.txt.bz2 http://sourceware.org/bugzilla/show_bug.cgi?id=3D14412 --- Comment #28 from wbrana at gmail dot com 2013-04-29 12:32:34 UTC --- according to http://sourceware.org/bugzilla/show_bug.cgi?id=3D13658#c2 fast functions can be used when source operand is in certain range. Slow functions should be used only outside interval. "The FPTAN, FSIN, FCOS, and FSINCOS instructions set the C2 flag to 1 to indicate that the source operand is beyond the allowable range of =C2=B12^6= 3 and clear the C2 flag if the source operand is within the allowable range." So, outside the interval [-2^63,+2^63] ("allowable range"), these instructi= ons must not be used (or they can be used, but with a fallback if the C2 flag is set to 1). But note that the glibc implementation is more accurate, even wi= th (very probably) correct rounding, so that it is better to use it anyway. --=20 Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=3Demail ------- You are receiving this mail because: ------- You are on the CC list for the bug. >>From glibc-bugs-return-18506-listarch-glibc-bugs=sources.redhat.com@sourceware.org Mon Apr 29 13:06:43 2013 Return-Path: Delivered-To: listarch-glibc-bugs@sources.redhat.com Received: (qmail 25697 invoked by alias); 29 Apr 2013 13:06:43 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Delivered-To: mailing list glibc-bugs@sourceware.org Received: (qmail 25638 invoked by uid 48); 29 Apr 2013 13:06:40 -0000 From: "siddhesh at redhat dot com" To: glibc-bugs@sourceware.org Subject: [Bug math/14412] Removal of sysdeps/x86_64/fpu/s_sincos.S causes regressions Date: Mon, 29 Apr 2013 13:06:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: math X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: siddhesh at redhat dot com X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: 2.18 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-SW-Source: 2013-04/txt/msg00213.txt.bz2 Content-length: 2297 http://sourceware.org/bugzilla/show_bug.cgi?id=3D14412 --- Comment #29 from Siddhesh Poyarekar 2013-0= 4-29 13:06:40 UTC --- (In reply to comment #28) > according to http://sourceware.org/bugzilla/show_bug.cgi?id=3D13658#c2 > fast functions can be used when source operand is in certain range. > Slow functions should be used only outside interval. >=20 > "The FPTAN, FSIN, FCOS, and FSINCOS instructions set the C2 flag to 1 to > indicate that the source operand is beyond the allowable range of =C2=B12= ^63 and > clear the C2 flag if the source operand is within the allowable range." >=20 > So, outside the interval [-2^63,+2^63] ("allowable range"), these instruc= tions > must not be used (or they can be used, but with a fallback if the C2 flag= is > set to 1). But note that the glibc implementation is more accurate, even = with > (very probably) correct rounding, so that it is better to use it anyway. The problem is not just about range reduction. fsincos is not always accur= ate within the allowable range either. (In reply to comment #27) > With all that said, I still question the cause of the huge performance dr= op. > The only cost of the correct sin/cos versus the incorrect one should be > argument reduction, which should be a no-op if the argument is already in= the > range [-pi,pi] or so and cheap even a good ways outside of that range... I considered the possibility of keeping the assembly default and then falli= ng into the default implementation if the exception flags indicate that the re= sult was not accurate enough, but that doesn't catch all cases. In fact, the limited internal precision of PI (66-bit mantissa) guarantees that there wi= ll be cases where fsincos thinks it has hit the target, but it hasn't. So until there's a way to flag inaccurate results reliably, I think the __sincos_finite way is the best option. There is definitely some scope to = look at the implementation of __sin and __cos functions, or even figure out some clever way to get results faster in sincos than just calling __sin and __co= s, but that will need more work. --=20 Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=3Demail ------- You are receiving this mail because: ------- You are on the CC list for the bug. >>From glibc-bugs-return-18507-listarch-glibc-bugs=sources.redhat.com@sourceware.org Mon Apr 29 13:15:07 2013 Return-Path: Delivered-To: listarch-glibc-bugs@sources.redhat.com Received: (qmail 1197 invoked by alias); 29 Apr 2013 13:15:06 -0000 Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org Delivered-To: mailing list glibc-bugs@sourceware.org Received: (qmail 1103 invoked by uid 48); 29 Apr 2013 13:15:03 -0000 From: "markus at trippelsdorf dot de" To: glibc-bugs@sourceware.org Subject: [Bug math/14412] Removal of sysdeps/x86_64/fpu/s_sincos.S causes regressions Date: Mon, 29 Apr 2013 13:15:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: glibc X-Bugzilla-Component: math X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: markus at trippelsdorf dot de X-Bugzilla-Status: NEW X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: 2.18 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 X-SW-Source: 2013-04/txt/msg00214.txt.bz2 Content-length: 1565 http://sourceware.org/bugzilla/show_bug.cgi?id=14412 --- Comment #30 from Markus Trippelsdorf 2013-04-29 13:15:02 UTC --- (In reply to comment #25) > I've posted a patch to implement __sincos_finite: > > http://sourceware.org/ml/libc-alpha/2013-04/msg00720.html > > This should allow you to compile with -ffast-math or -ffinite-math-only to use > this fast implementation of sincos. Your patch doesn't work for me. I've re-build glibc and then re-compiled poppler with "-ffinite-math-only". But I still only see calls to __sin and __cos with "perf top". The poppler code in question can be found here: http://cgit.freedesktop.org/poppler/poppler/tree/poppler/Gfx.cc#n3112 When I just add the following file to glibc: markus@x4 glibc % cat sysdeps/x86_64/fpu/s_sincos.S #include .text ENTRY (__sincos) movsd %xmm0, -8(%rsp) fldl -8(%rsp) fsincos fnstsw %ax testl $0x400,%eax jnz 1f fstpl (%rsi) fstpl (%rdi) retq 1: fldpi fadd %st(0) fxch %st(1) 2: fprem1 fnstsw %ax testl $0x400,%eax jnz 2b fstp %st(1) fsincos fstpl (%rsi) fstpl (%rdi) retq END (__sincos) weak_alias (__sincos,sincos) poppler gets fast again and uses __sincos. -- Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.