From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12213 Path: news.gmane.org!.POSTED!not-for-mail From: Damian McGuckin Newsgroups: gmane.linux.lib.musl.general Subject: Re: remquo - underlying logic Date: Thu, 7 Dec 2017 12:09:23 +1100 (AEDT) Message-ID: References: <20171130185956.GS15263@port70.net> <20171130211713.GT15263@port70.net> <20171206103708.GA15263@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1512608983 4836 195.159.176.226 (7 Dec 2017 01:09:43 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 7 Dec 2017 01:09:43 +0000 (UTC) User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) To: musl@lists.openwall.com Original-X-From: musl-return-12229-gllmg-musl=m.gmane.org@lists.openwall.com Thu Dec 07 02:09:36 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1eMkgx-00016z-MW for gllmg-musl@m.gmane.org; Thu, 07 Dec 2017 02:09:35 +0100 Original-Received: (qmail 24489 invoked by uid 550); 7 Dec 2017 01:09:40 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 24471 invoked from network); 7 Dec 2017 01:09:39 -0000 X-Authentication-Warning: key0.esi.com.au: damianm owned process doing -bs In-Reply-To: <20171206103708.GA15263@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:12213 Archived-At: On Wed, 6 Dec 2017, Szabolcs Nagy wrote: > it's not clear to me how you use fma (x-(int)(x/y)*y ?), but efficient > fma instruction is not available on all targets and the software > implementation can be very slow. and i suspect such approach would break > fenv correctness. Quite likely. Besides, my testing was flawed and FMA is NOT the answer I thought it was. > (musl is compiled with -std=c99 so x*y+z is not contracted to fma(x,y,z) > automatically when the instruction is available, you have to add > -ffp-contract=fast if that's what you want, but it might break some code > in musl that relies on exact arithmetics, most math code should work > either way though.) For a lot of reasons, FMA is not the answer. That said, over that range, I am experimenting using a simplistic form of double-double arithmetic for that calculation. Would you agree that when (int) (x / y) < 2^52 the computation (int) (x / y) is accurate to within epsilon, i.e. if it should be at most be incorrect by +/- 1.? If so, and using the same sort of logic that log.c uses to split the calculation of k * log(2.0) into a high and low component, or maybe into 4 components, would you agree that it is possible to come up with an accurate computation of x - y * (int) (x / y) It should be much quicker than long division. Regards - Damian Pacific Engineering Systems International, 277-279 Broadway, Glebe NSW 2037 Ph:+61-2-8571-0847 .. Fx:+61-2-9692-9623 | unsolicited email not wanted here Views & opinions here are mine and not those of any past or present employer