From owner-freebsd-hackers@freebsd.org Tue May 29 20:39:48 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E97B9F7434D for ; Tue, 29 May 2018 20:39:47 +0000 (UTC) (envelope-from adhemerval.zanella@linaro.org) Received: from mail-qt0-x22b.google.com (mail-qt0-x22b.google.com [IPv6:2607:f8b0:400d:c0d::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6ABC67DB94 for ; Tue, 29 May 2018 20:39:47 +0000 (UTC) (envelope-from adhemerval.zanella@linaro.org) Received: by mail-qt0-x22b.google.com with SMTP id h2-v6so20461968qtp.7 for ; Tue, 29 May 2018 13:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=bVfN8sdbc3hBKoh+A4dpxgR5c/3qoIptLy+l6ytoGtQ=; b=eam/P1tIvBcLxe7Iqkvorng7yYQ0DS3/uV+9pyUcqlrmn9aghhFR6vpi8M+Xql9XYZ oWdl1x8Z1elvd0878M4ttiaJA1dahaQUGeDw2qF8QQttrsIzEUzrJ7ZRcMoTwJgboAfa 5Zzu4Bhd/iFTUZksTIZJ3vTyp0R4jQghjXX/4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:openpgp:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=bVfN8sdbc3hBKoh+A4dpxgR5c/3qoIptLy+l6ytoGtQ=; b=lwLuXZiW2ALRH1teeC3HVYzzu1UP/kj+eF5nUVmkG4tp939StQ/ZDeVsOoyq6Di1+U nhjCyqujfbaXeDGLUlkusdxGm9k9S1F7aQr5XGLrRQT+5QWfBkEnpjFSoi/E6IdEsLTl TKK3S7yfSfRyrAiH/3IHa3SUZdN7ZxtqWi+4nOjViWz0qGyEz96bsS0PnbM4Ibn6gyn+ 9YHLUO1OsW4Y7AxWsDGeoSGAE6KYaeSVp3vIvLg1GRf3erE83hIcn9D/fQxkNzG2eRyK 5oVqHpmfIgxPfWYxBTDmUMdR79SN2SPBm2H9byAZ+mHzrfNiMvSUsSz7l83c1NknTmgk VrAQ== X-Gm-Message-State: ALKqPwffhp+Rs0I/iAtp/69L8rHbgv7ZB7OCG03knKKJG7e582Uzmf3s u6UVV34rY/d9PdH0L53W63HnYQ== X-Google-Smtp-Source: ADUXVKJx8ebHALKFgwysWItRXrI9B+XWWDBpajylt5S26S5HJf3X08tuT+WljfVPPM7Nq9WnbkWR+w== X-Received: by 2002:aed:2725:: with SMTP id n34-v6mr18502931qtd.36.1527626386819; Tue, 29 May 2018 13:39:46 -0700 (PDT) Received: from [10.0.0.105] ([179.159.11.160]) by smtp.googlemail.com with ESMTPSA id f22-v6sm23149275qke.94.2018.05.29.13.39.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 13:39:46 -0700 (PDT) Subject: Re: Code with apache-2 on /usr/src To: sgk@troutmask.apl.washington.edu Cc: Konstantin Belousov , freebsd-hackers@freebsd.org, emaste@freebsd.org References: <20180528190444.GE3789@kib.kiev.ua> <20180528193506.GA76705@troutmask.apl.washington.edu> <1c09023e-9bf5-d23a-dedc-1c4f4706bbde@linaro.org> <20180528202117.GA77184@troutmask.apl.washington.edu> <72101038-9e89-3f23-ab67-1c97b2a89803@linaro.org> <20180528210907.GA77475@troutmask.apl.washington.edu> <20180528221819.GA77894@troutmask.apl.washington.edu> <05943b3c-e2c6-4c03-93d9-5c2553e5865a@linaro.org> <20180529173224.GA96547@troutmask.apl.washington.edu> From: Adhemerval Zanella Openpgp: preference=signencrypt Autocrypt: addr=adhemerval.zanella@linaro.org; prefer-encrypt=mutual; keydata= xsFNBFcVGkoBEADiQU2x/cBBmAVf5C2d1xgz6zCnlCefbqaflUBw4hB/bEME40QsrVzWZ5Nq 8kxkEczZzAOKkkvv4pRVLlLn/zDtFXhlcvQRJ3yFMGqzBjofucOrmdYkOGo0uCaoJKPT186L NWp53SACXguFJpnw4ODI64ziInzXQs/rUJqrFoVIlrPDmNv/LUv1OVPKz20ETjgfpg8MNwG6 iMizMefCl+RbtXbIEZ3TE/IaDT/jcOirjv96lBKrc/pAL0h/O71Kwbbp43fimW80GhjiaN2y WGByepnkAVP7FyNarhdDpJhoDmUk9yfwNuIuESaCQtfd3vgKKuo6grcKZ8bHy7IXX1XJj2X/ BgRVhVgMHAnDPFIkXtP+SiarkUaLjGzCz7XkUn4XAGDskBNfbizFqYUQCaL2FdbW3DeZqNIa nSzKAZK7Dm9+0VVSRZXP89w71Y7JUV56xL/PlOE+YKKFdEw+gQjQi0e+DZILAtFjJLoCrkEX w4LluMhYX/X8XP6/C3xW0yOZhvHYyn72sV4yJ1uyc/qz3OY32CRy+bwPzAMAkhdwcORA3JPb kPTlimhQqVgvca8m+MQ/JFZ6D+K7QPyvEv7bQ7M+IzFmTkOCwCJ3xqOD6GjX3aphk8Sr0dq3 4Awlf5xFDAG8dn8Uuutb7naGBd/fEv6t8dfkNyzj6yvc4jpVxwARAQABzUlBZGhlbWVydmFs IFphbmVsbGEgTmV0dG8gKExpbmFybyBWUE4gS2V5KSA8YWRoZW1lcnZhbC56YW5lbGxhQGxp bmFyby5vcmc+wsF3BBMBCAAhBQJXFRpKAhsDBQsJCAcDBRUKCQgLBRYCAwEAAh4BAheAAAoJ EKqx7BSnlIjv0e8P/1YOYoNkvJ+AJcNUaM5a2SA9oAKjSJ/M/EN4Id5Ow41ZJS4lUA0apSXW NjQg3VeVc2RiHab2LIB4MxdJh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gREidHLLqEb/otuwt1aoMPg97iUgDV5mlNef77lWE8vxmlY0FBWIXuZ yv0XYxf1WF6dRizwFFbxvUZzIJp3spAao7jLsQj1DbD2s5+S1BW09A0mI/1DjB6EhNN+4bDB SJCOv/ReK3tFJXuj/HbyDrOdoMt8aIFbe7YFLEExHpSk+HgN05Lg5TyTro8oW7TSMTk+8a5M kzaH4UGXTTBDP/g5cfL3RFPl79ubXwARAQABwsFfBBgBCAAJBQJXFRpKAhsMAAoJEKqx7BSn lIjvI/8P/jg0jl4Tbvg3B5kT6PxJOXHYu9OoyaHLcay6Cd+ZrOd1VQQCbOcgLFbf4Yr+rE9l mYsY67AUgq2QKmVVbn9pjvGsEaz8UmfDnz5epUhDxC6yRRvY4hreMXZhPZ1pbMa6A0a/WOSt AgFj5V6Z4dXGTM/lNManr0HjXxbUYv2WfbNt3/07Db9T+GZkpUotC6iknsTA4rJi6u2ls0W9 1UIvW4o01vb4nZRCj4rni0g6eWoQCGoVDk/xFfy7ZliR5B+3Z3EWRJcQskip/QAHjbLa3pml xAZ484fVxgeESOoaeC9TiBIp0NfH8akWOI0HpBCiBD5xaCTvR7ujUWMvhsX2n881r/hNlR9g fcE6q00qHSPAEgGr1bnFv74/1vbKtjeXLCcRKk3Ulw0bY1OoDxWQr86T2fZGJ/HIZuVVBf3+ gaYJF92GXFynHnea14nFFuFgOni0Mi1zDxYH/8yGGBXvo14KWd8JOW0NJPaCDFJkdS5hu0VY 7vJwKcyHJGxsCLU+Et0mryX8qZwqibJIzu7kUJQdQDljbRPDFd/xmGUFCQiQAncSilYOcxNU EMVCXPAQTteqkvA+gNqSaK1NM9tY0eQ4iJpo+aoX8HAcn4sZzt2pfUB9vQMTBJ2d4+m/qO6+ cFTAceXmIoFsN8+gFN3i8Is3u12u8xGudcBPvpoy4OoG Message-ID: Date: Tue, 29 May 2018 17:39:40 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180529173224.GA96547@troutmask.apl.washington.edu> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2018 20:39:48 -0000 On 29/05/2018 14:32, Steve Kargl wrote: > On Tue, May 29, 2018 at 09:37:07AM -0300, Adhemerval Zanella wrote: >> >> >> On 28/05/2018 19:18, Steve Kargl wrote: >>> On Mon, May 28, 2018 at 06:12:13PM -0300, Adhemerval Zanella wrote: >>>> >>>>>> And is having a different algorithm for single and double prevision >>>>>> a blocker for a future patch proposal? >>>>> >>>>> No. Given the comment in sinf.c that max ULP is 0.56072, I do note that >>>>> the current implementation of sinf in lib/msun is more accurate (for >>>>> interesting values of x). I also looked at single/s_sincosf.c. It is >>>>> rather dubious to have 80+ digit numerical constants for a float, which >>>>> at most has 9 relevant digits. >>>>> >>>> >>>> Also keep in mind my initial idea is to propose patches only to expf, powf, >>>> logf, expf2, and log2f. >>> >>> OK, so I peeked at expf. Comment claims max ulp of 0.502. >>> Exhaustive testing for normal numbers in relevent range for >>> the current implementation of expf(x) shows >>> >>> Interval tested: [-18,88.72] >>> ULP: 0.90951, x = -5.19804668e+00f, /* 0xc0a65666 */ >>> flt = 5.52735012e-03f, /* 0x3bb51ec6 */ >>> dbl = 5.5273505437686398e-03, /* 0x3f76a3d8, 0xdd1aae8e */ >>> >>> But, then one looks at implementation details. msun's current >>> implementation is written in terms of single precision; while >>> the routine you're suggesting is written in terms of double_t. >>> So, achieving 0.502 ULP is due to having 53-bits in intermediate >>> results. It appears that the algorithm of the suggested code >>> cannot easily be generalized to double and long double without >>> implementing a multiple-precision routines. >> >> This is indeed true for the default implementation, although the same repo >> has alternative implementation that uses only float for expf, powf, and >> logf. However, as far as I could evaluated, the optimized expf and powf >> single version does not yield any gain over current FreeBSD version, only >> for the logf I see some gains. >> >> Do you see any issue about current approach of using intermediary double_t >> for internal calculations? >> > > No. The kernels for sinf and cosf (ie., k_sinf.c and k_cosf.c) > use double for its intermediate computations. But, the main > code in s_sin[fl].c and s_cos[f].c have the same internal structure: > > 1) Split argument into integer parts > 2) Filter special values (+-inf, NaN) > 3) Split into intervals > a) for small x no range reduction is needed. > b) do range reduction into [0,pi/4] > 4) In (3a) deal with subnormal numbers with care to avoid spurious > underflow. > 5) In (3b), use polynomial approximations. > > Because the internal structure is similar for all precision, it > makes maintenance easier. For maintenance and the importance of > having the same structure, see the history of s_erff.c: > > https://svnweb.freebsd.org/base/head/lib/msun/src/s_erff.c?view=log > >>> Note, years ago, I submitted implementations for expf, exp, >>> ld80/expl, ld128/expl, logf, log, ld80/logl, and ld128/logl >>> based on papers by PTP Tang [1,2]. My versions for single >>> and double precision were not adopted even though these had >>> better accuracy. Either Bruce Evans improved or with Bruce's >>> help I improved the ld80 and ld128 routines, which were added >>> to msun. I know Bruce fixed minor issues with the single >>> and double precision routines, but he has not submitted patches. >>> >>> 1. PTP Tang, "Table-driven implementation of the exponential >>> function in IEEE floating-point arithmetic," ACM Trans. Math. >>> Soft., 15, 144-157 (1989). >>> >>> 2. PTP Tang, "Table-driven implementation of the logarithm >>> function in IEEE floating-point arithmetic," ACM Trans. Math. >>> Soft., 16, 378-400 (1990). >> >> Thanks for the links, do you recall why exactly your implementations were >> not adopted? Do you think a similar proposal based on the arm repo would >> be also rejected? > > Mostly due to issues on my part. Bruce was/is the only person interested > in reviewing patches to libm. At the time I submitted that code, his > comments and suggestions could be characterized as drinking from a fire > hose. When I had a commit bit, I finally gave up on the pursuit of > perfect code and simply committed s_expl.c. Later, David Das committed > s_logl.c. > Thanks for the feedback so far, it was valuable. The only missing bit is the original question, do you know if using apache-2 on /usr/src is allowed?