From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10545 Path: news.gmane.org!.POSTED!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Model specific optimizations? Date: Sat, 1 Oct 2016 11:10:12 -0400 Message-ID: <20161001151012.GN19318@brightrain.aerifal.cx> References: <20160929142126.GB22343@voyager> <20160929152354.GK19318@brightrain.aerifal.cx> <20160929170801.GC22343@voyager> <20160929181336.GL19318@brightrain.aerifal.cx> <20160930045615.GD22343@voyager> <20161001055023.GA24569@brightrain.aerifal.cx> <20161001085214.GE22343@voyager> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: blaine.gmane.org 1475334645 10276 195.159.176.226 (1 Oct 2016 15:10:45 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 1 Oct 2016 15:10:45 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: musl@lists.openwall.com Original-X-From: musl-return-10558-gllmg-musl=m.gmane.org@lists.openwall.com Sat Oct 01 17:10:41 2016 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 1bqLvm-0000VM-Hn for gllmg-musl@m.gmane.org; Sat, 01 Oct 2016 17:10:26 +0200 Original-Received: (qmail 7314 invoked by uid 550); 1 Oct 2016 15:10:26 -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 7296 invoked from network); 1 Oct 2016 15:10:25 -0000 Content-Disposition: inline In-Reply-To: <20161001085214.GE22343@voyager> Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:10545 Archived-At: On Sat, Oct 01, 2016 at 10:52:14AM +0200, Markus Wichmann wrote: > On Sat, Oct 01, 2016 at 01:50:23AM -0400, Rich Felker wrote: > > I don't think this works at all. sqrt() is required to be > > correctly-rounded; that's the whole reason sqrt.c is costly. > > It's an approximation, at least, which was rather my point. > > As I've come to realize over the course of this discussion, the fsqrt > instruction is useless here and pretty much everywhere out there: I don't think that conclusion is correct. It certainly makes sense for libc to use it in targets that have it, assuming it safely produces correct results, and for compilers to generate it in place of a call to sqrt. > - If you are looking for accuracy over speed, the standard C library has > got you covered. Yes. > - If you are looking for speed over accuracy, you can code up the > Babylonian method inside five minutes. You can even tune it to suit > your needs to an extent (mainly, number of rounds and method of first > approximation). This method is also portable to other architectures, and > can be done entirely in C (requiring IEEE floating point, but then, most > serious FP code does that). This is not going to give you speed. If you want fast sqrt approximations, there are lots out there that are actually fast. And if the final result you need is 1/sqrt there are even faster ones. > Also, at least according to Apple, which were the only ones actually > looking at the thing, such as I could find, it was only ever supported > by the 970 and the 970FX cores, released in 2002 and 2004, respectively. > I highly doubt they'll have much relevance. Chalk up my suspicions from > the OP to not having researched enough. Do you mean these are the only non-POWER line models that have fsqrt? > In closing: Nice discussion, but I'm sorry for the noise. I don't think it's noise. It's been informative. And it does suggest that we should add static, compile-time support for using fsqrt on POWER and perhaps on these specific models that have it. That's useful information for making it a better-supported target under musl. Rich