From patchwork Mon Apr 14 08:47:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 531 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx21.g.dreamhost.com (peon2454.g.dreamhost.com [208.113.200.127]) by wilcox.dreamhost.com (Postfix) with ESMTP id 6A1B236005B for ; Mon, 14 Apr 2014 01:48:27 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14307373) id 1527812A1144; Mon, 14 Apr 2014 01:48:27 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx21.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx21.g.dreamhost.com (Postfix) with ESMTPS id D80231283F8E for ; Mon, 14 Apr 2014 01:48:26 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:date:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=x5G/ YrWsFT7ELXJ22cS88XpNJ+Nzmb4adWO8tpiLWlEVAU9H9DL3Hp+gLNVgKIV8+zjm 58BQkoVQ4o7xJNPmNMyaM9hQKHaMhRy1aBOmIIksoFL/WokMpm00HKksnIRK57Oo pZYZ1sgvZmXOLMiZTsnv4XkKYMbGbestV+iDTVI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:date:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=CGTS1UaSDc afM8wLRxL8eGTM55I=; b=kSMFe/hSWKGcx9fmgZP7RLFvdNzHIOuvMCi8QUnCV0 Cj5AS+BJILAqxi+U/twGKiC/h6wym8IydC7LDdvqyPOkX0+tO+WxkiN2goP66xU/ oHFvOUPeJO3UEBWIo0xgSKtdWo2go42lQl4I4VZa+fhz5HesoAstMdPk9+cyAxS4 o= Received: (qmail 18536 invoked by alias); 14 Apr 2014 08:48:24 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 18523 invoked by uid 89); 14 Apr 2014 08:48:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: plane.gmane.org To: libc-alpha@sourceware.org From: Stefan Liebler Subject: Re: [PATCH][BZ #16824] Fix failing y1 due to too large ulps in downward/upward rounding mode. Date: Mon, 14 Apr 2014 10:47:59 +0200 Lines: 89 Message-ID: References: <5347E50F.7000906@linux.vnet.ibm.com> Mime-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 In-Reply-To: <5347E50F.7000906@linux.vnet.ibm.com> X-DH-Original-To: glibc@patchwork.siddhesh.in Thanks for the hint with SET_RESTORE_ROUND macro. Here is the updated version. Tested on s390/s390x. Ok for commit? Bye --- 2014-04-14 Stefan Liebler [BZ #16824] * sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_y1l): Set round-to-nearest internally to reduce error accumulation. --- On 04/11/2014 02:50 PM, Adhemerval Zanella wrote: > On 11-04-2014 08:56, Stefan Liebler wrote: >> Hi, >> >> on s390 the y1 tests for long double fails due to too large ulps in downward / upward rounding mode (See Bug 16824). >> According to Joseph Myers patch comment >> (https://sourceware.org/ml/libc-alpha/2014-03/msg00620.html), >> round-to-nearest is used internally to reduce error accumulation. >> Tests on s390/s390x shows following ulps: >> y1: 2 >> y1_downward: 4 >> y1_towardzero: 2 >> y1_upward: 5 >> >> Is this okay? On other architectures too? >> >> Bye >> --- >> 2014-04-11 Stefan Liebler >> >> [BZ #16824] >> * sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_y1l): >> Set round-to-nearest internally to reduce error accumulation. >> --- >> >> diff --git a/sysdeps/ieee754/ldbl-128/e_j1l.c b/sysdeps/ieee754/ldbl-128/e_j1l.c >> index 70a1c86..db96c94 100644 >> --- a/sysdeps/ieee754/ldbl-128/e_j1l.c >> +++ b/sysdeps/ieee754/ldbl-128/e_j1l.c >> @@ -855,11 +855,14 @@ __ieee754_y1l (long double x) >> return -TWOOPI / x; >> if (xx <= 2.0L) >> { >> + int save_round = fegetround (); >> + libc_fesetround (FE_TONEAREST); >> /* 0 <= x <= 2 */ >> z = xx * xx; >> p = xx * neval (z, Y0_2N, NY0_2N) / deval (z, Y0_2D, NY0_2D); >> p = -TWOOPI / xx + p; >> p = TWOOPI * __ieee754_logl (x) * __ieee754_j1l (x) + p; >> + libc_fesetround (save_round); >> return p; >> } > > Although s390 does not implemented the optimization to set/restore rounding mode only > when needed (check the x86_64 and powerpc fenv_private.h), the way to set/reset > rounding mode should using SET_RESTORE_ROUND. > > diff --git a/sysdeps/ieee754/ldbl-128/e_j1l.c b/sysdeps/ieee754/ldbl-128/e_j1l.c index 70a1c86..1264c95 100644 --- a/sysdeps/ieee754/ldbl-128/e_j1l.c +++ b/sysdeps/ieee754/ldbl-128/e_j1l.c @@ -856,6 +856,7 @@ __ieee754_y1l (long double x) if (xx <= 2.0L) { /* 0 <= x <= 2 */ + SET_RESTORE_ROUNDL (FE_TONEAREST); z = xx * xx; p = xx * neval (z, Y0_2N, NY0_2N) / deval (z, Y0_2D, NY0_2D); p = -TWOOPI / xx + p;