From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12207 Path: news.gmane.org!.POSTED!not-for-mail From: Damian McGuckin Newsgroups: gmane.linux.lib.musl.general Subject: Re: remquo - underlying logic Date: Wed, 6 Dec 2017 12:17:40 +1100 (AEDT) Message-ID: References: <20171130185956.GS15263@port70.net> <20171130211713.GT15263@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 1512563080 25959 195.159.176.226 (6 Dec 2017 12:24:40 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 6 Dec 2017 12:24:40 +0000 (UTC) User-Agent: Alpine 2.02 (LRH 1266 2009-07-14) To: musl@lists.openwall.com Original-X-From: musl-return-12223-gllmg-musl=m.gmane.org@lists.openwall.com Wed Dec 06 13:24: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 1eMYka-0006Uh-3I for gllmg-musl@m.gmane.org; Wed, 06 Dec 2017 13:24:32 +0100 Original-Received: (qmail 9939 invoked by uid 550); 6 Dec 2017 01:17:57 -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 9910 invoked from network); 6 Dec 2017 01:17:57 -0000 X-Authentication-Warning: key0.esi.com.au: damianm owned process doing -bs In-Reply-To: <20171130211713.GT15263@port70.net> Xref: news.gmane.org gmane.linux.lib.musl.general:12207 Archived-At: While my exploration with floating point numbers was less than stellar, I did notice that when ex - ey < p (where p is the digits in the significant) you can use the fma routine to compute some appropriately rounded/truncated version of the quotient for both remquo and fmod. And this appears to not loose any precision for the obvious reasons. >From my limited testing, the speed gain for this extremely limited range of exponent difference is huge over the standard routine in MUSL. I will do some more testing and report in detail but it seems to be orders of magnitude. Somebody might want to comment on that sort of approach. In 99% of the floating point work I do, the calculations involve physical stresses and strains and loads and such within digital models. They differ in exponent range between 10^6 through to 10^12 unless I have screwed up in my model. This is a lot less than 2^52 for a double and mostly is still under the 2^23 for a float which is just above 10^6. So, in my sort of calculations, the speed gain can be quite significant. The burden of the extra branch seems to be trivial, even for the cases where the FMA is not used. 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