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: 338881 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 14586140084 for ; Mon, 14 Apr 2014 18:48:30 +1000 (EST) 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=BSI4 kQZsGOGYbd7JtN7zx1L7twT2lC0x0lkJCi1ecMmakEYV4fSMeVTmToeBuRMxAmMh 3O/cvPunNTGegPFB7tshjY7NA6jwMD2wHE8lWuZT3bXEPOw6UhTzCXNMl1bDaUWi ZWD3cIllkQB+u4LCga0z6MJsQ5nAnp05v+T2gpc= 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=n/vk+z9KMhiO7yX8afKo1LrwYjAkAGJEl8CElUIgLs mFWQsy/tqLmecKH9K9Jxdmatpf0TTD+naAgLlB3i4e163tI8ncaD1iQ4UhI57zIe 9UwOlwuBwrdx9VvNY5RYxhPlxsJqhJuruED14/atsMxHPz4BQk5uTqt1w/X8X0WO Y= 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> 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;