From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10546 Path: news.gmane.org!.POSTED!not-for-mail From: Markus Wichmann Newsgroups: gmane.linux.lib.musl.general Subject: Re: Model specific optimizations? Date: Sat, 1 Oct 2016 21:53:04 +0200 Message-ID: <20161001195304.GF22343@voyager> 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> <20161001151012.GN19318@brightrain.aerifal.cx> 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 1475351619 6852 195.159.176.226 (1 Oct 2016 19:53:39 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 1 Oct 2016 19:53:39 +0000 (UTC) User-Agent: Mutt/1.5.23 (2014-03-12) To: musl@lists.openwall.com Original-X-From: musl-return-10559-gllmg-musl=m.gmane.org@lists.openwall.com Sat Oct 01 21:53:35 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 1bqQLe-0000Kw-HE for gllmg-musl@m.gmane.org; Sat, 01 Oct 2016 21:53:26 +0200 Original-Received: (qmail 27781 invoked by uid 550); 1 Oct 2016 19:53: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 27763 invoked from network); 1 Oct 2016 19:53:25 -0000 Content-Disposition: inline In-Reply-To: <20161001151012.GN19318@brightrain.aerifal.cx> X-Provags-ID: V03:K0:ayygpsqTKlZRyIYSTqsu94bIGfHNekf2xMiBJoW2Z6NFRBgccHV PpONKphpptLpVROnnA6flyqQHBo4pv5t4XkNLEcUykDXAXROYMyx8rtriP0UNoBRbVwDh46 zc9sBhmoe1BXB4ABp/H0RdlWtqTG1yOWiesYkA4oh2ugRKZVJlffLaPl/qeq5OKDzbYpX8l sYJF25TsWB661+yeqYisw== X-UI-Out-Filterresults: notjunk:1;V01:K0:sCTm5WTalgc=:qFtYhWCAueBdMq7FppBh5t YgYHWfRJajuRWP42X0Vdq4nYUNp/Mk8/N98NnD+CKbc8TFQnct38X/SkfiuH63P8Aa4FRBiLu b2dWo8Gqq6KDx+IEYcogHopGajAxko0DSjylXLOeep8bC7OCWk7Ka+L3Us40P3sni+dNp7Z32 TUHoum3mstz9+tyxEtt0rnKcNjpuy06mbRsgGCzfPzSpjs4z2P6JXDuxQ/pqq+FNLadOXhstB THmU5wflKHSrf+x14Ru+i3eC2B3ohS3TJx3PvStv5xQGjLp1byD+qc3r1wn0n2JkyP/y0VJWz MKW88uAPGn/e3IAH8h8yY30n5IrQwd14lZOp18zZDGvryWYvgigdCvZnQ1pfvuiMkq7X8lAB+ K+EAeBKbg7szG7jBnlKdxp38oXOU/+EdC20Y2f2Mjqxn+tnzINxn9W5nSVzK+cK7UhUsUzHK/ UoCWY9/8+5H79up2qDUv2M/uQ7NlAh59sGhx95lw/Kh41pF0Z3kqCY68YcehtZyEaGu1MmH7H bZtX6LGhgFx29Oj7jQFnjMCstnQCiTJvXgzSj4YjfPukJD/le8epvQ8IKn9JNOCUf1fNEvGak 2d8Mg86oazC2vGukfkXiKtkMAb9zX6bvqNcu7XhXipLvPUPm4X34e5sPHhLjStBjnmBKjERae /MXVr11j5znrn+dVd0VDpxB4iCsPuSjo2o8tiUhwTHjQ+eg2IXaNEGJ9TXu0ksln5XY0e7LWY GtGZn98bNt4o5HklpaG2TlKl9hzOZhQMiRkr8slcjW3ZoCNQPcdRWqoUW9Doi8cjlvtn0KSt Xref: news.gmane.org gmane.linux.lib.musl.general:10546 Archived-At: On Sat, Oct 01, 2016 at 11:10:12AM -0400, Rich Felker wrote: > 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. > But again, that requires the appropriate flags. > > 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? > The more I research this, the more confused I get! So, I was looking for real-world users of fsqrt, do look at how they determine availability. The first such user I found was Apple's libm. Tracing back to where they set their feature flags, I found this file http://opensource.apple.com/source/xnu/xnu-1456.1.26/osfmk/ppc/start.s If you search for _cpu_capabilities, around line 180 you'll find a comment saying the feature flags in this file are only defaults and may be changed by initialization code. But I couldn't find anything setting more flags, if anything, flags got removed. And the only models that have the flag kHasFsqrt are the 970 and the 970FX. But then I noticed that their processor list is kind of small, so I continued the search. I found this e-mail claiming the 604 supports the instruction: http://aps.anl.gov/epics/tech-talk/2011/msg01247.php But if you look at datasheets of the 604, they say nothing either way. But alright, the 604 is and old model (intrduced in 1994), maybe fsqrt wasn't defined then. I personally work with the e300 (at my day job), and at least their datasheet makes it clear that fsqrt is not supported. Actually, apparently Freescale aren't big fans of this instruction at all, according to this comment: https://github.com/ibmruntimes/v8ppc/issues/119#issuecomment-72705975 Wikipedia claims, however, that it wasn't until the 620 that the square root instruction was put into hardware. I tried to find a 620 datasheet, but no luck so far. Next family on the list would be the 4xx. 403 can be discounted immediately as it lacks an FPU. Since the 401 is stripped down even further, it also has no FPU. From the 405 onward it get's dicey as they went the way of the x87: You could connect an external FPU if desired. I found one for 405 here: http://www.xilinx.com/support/documentation/ip_documentation/apu_fpu.pdf That one doesn't support fsqrt, at least not enough for our purposes, but it does support fsqrts (that's the single precision variant). That's a whole new level of weird. As for the rest: I hope, Apple got it right, because afer the 970, nothing more is listed in Wikipedia. So, as you can see, the whole thing is a mess. > Rich Ciao, Markus