From patchwork Fri Jan 31 12:32:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Tocar X-Patchwork-Id: 315574 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 D37552C00C8 for ; Fri, 31 Jan 2014 23:33:14 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=qIl2YLmBA3Ve6Z3Z5 vA45mYAe+Jb9CH+tsDZoHB1Bbk1Qa0gj+3PDsRIwidK43lVYb9GBfmFmCnCyw3SV AuMHwExUULeIkrkkrgwBNXmMOiOleWu2/QI8MaYX7zGQrAY+Rfjo2ngsniozeu9i y+sN1XeimAzhkyGyklgMWefrnI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=JrH/XB3LHOUWI+GAiSh++3x uWf8=; b=WECDECLZsIz8zZQq+XzmJadp5+H4NxMd3LO/y61K8cbIov2T334X431 x8kY7TNc8SBkjS12qWe9erQuAWSf4qG7/X6O2hjPLEAbU9LB61ddJtRuzfAMVlGn nJhDXff9hH4+2OVTTnHz152qcUE4NyUBcLhF8eN/2eKGi+aqjfrE= Received: (qmail 9029 invoked by alias); 31 Jan 2014 12:33:07 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 9011 invoked by uid 89); 31 Jan 2014 12:33:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f49.google.com Received: from mail-pa0-f49.google.com (HELO mail-pa0-f49.google.com) (209.85.220.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 31 Jan 2014 12:33:03 +0000 Received: by mail-pa0-f49.google.com with SMTP id hz1so4359562pad.22 for ; Fri, 31 Jan 2014 04:33:01 -0800 (PST) X-Received: by 10.66.187.11 with SMTP id fo11mr20584480pac.47.1391171581761; Fri, 31 Jan 2014 04:33:01 -0800 (PST) Received: from msticlxl7.ims.intel.com (jfdmzpr05-ext.jf.intel.com. [134.134.139.74]) by mx.google.com with ESMTPSA id nm5sm27214202pbc.29.2014.01.31.04.32.59 for (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 31 Jan 2014 04:33:01 -0800 (PST) Date: Fri, 31 Jan 2014 16:32:55 +0400 From: Ilya Tocar To: Uros Bizjak Cc: gcc-patches , Kirill Yukhin Subject: Re: [PATCH][testsuite] Avoid division by zero. Message-ID: <20140131123255.GB67972@msticlxl7.ims.intel.com> References: <20140130164102.GA55091@msticlxl7.ims.intel.com> <20140131100005.GA67972@msticlxl7.ims.intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes > >> We won't get zero from exponential function, so expecting zero result > >> is flawed anyway. > >> > >> If we would like to introduce universal epsilon comparisons into the > >> testsuite, then please read [1]. Being overly pedantic, the definition > >> should be "|(v[i] - u.a[i]) / v[i]|", as stated in [2]. > >> > >> [1] http://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/ > >> [2] http://en.wikipedia.org/wiki/Relative_error > >> > > > > We get zero from testing zero-masking. Currently we produce 0/0 = NaN. > > Comparison with NaN is always false, so tests pass. But I think that > > this should be fixed to avoid division by zero. As for being more > > pedantic about comparison, I doubt that its useful, when we use > > 0.0001 as eps. > > In this case, please add simple check for zero, with the above > comment. We don't test exp function, but masking. > Something like this? --- gcc/testsuite/gcc.target/i386/m512-check.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gcc/testsuite/gcc.target/i386/m512-check.h b/gcc/testsuite/gcc.target/i386/m512-check.h index 3209039..a96a103 100644 --- a/gcc/testsuite/gcc.target/i386/m512-check.h +++ b/gcc/testsuite/gcc.target/i386/m512-check.h @@ -58,6 +58,16 @@ check_rough_##UINON_TYPE (UINON_TYPE u, const VALUE_TYPE *v, \ \ for (i = 0; i < ARRAY_SIZE (u.a); i++) \ { \ + /* We will always have v[i] == 0 == u.a[i] for some i, \ + when we test zero-masking. */ \ + if (v[i] == 0.0 && u.a[i] == 0.0) \ + continue; \ + if (v[i] == 0.0 && u.a[i] != 0.0) \ + { \ + err++; \ + PRINTF ("%i: " FMT " != " FMT "\n", \ + i, v[i], u.a[i]); \ + } \ VALUE_TYPE rel_err = (u.a[i] - v[i]) / v[i]; \ if (((rel_err < 0) ? -rel_err : rel_err) > eps) \ { \