On Sunday, December 18, 2016 at 4:19:12 PM UTC+2, Robert Eachus wrote:
> On Sunday, December 18, 2016 at 5:09:55 AM UTC-5,
already...@yahoo.com wrote:
>
> > Such implementations are common, due the hype created by sensationalists.
> > But, for reasons stated above, I personally consider them as disservice for
> > overwhelming majority of users that would be served much better by using x87
> > implementation "as is".
>
> I am one of those other users.
What do you mean?
Are you one of 99.9999% that will be better served by fptan instructions 'as is' or one of 0.0001% that can benefit from more precise range reduction?
> In paricular tangents near Pi/4 (90 degrees)
pi/2
> have very large swings for small errors. A bad value of Pi can result in a very large negative value for the tangent instead of a very large positive value.
How do you calculate argument of tangent?
Is it result of addition/subtraction? In this case you are crying over spilled milk, because addition/subtraction already killed the precision of the argument and precision of evaluation of tangent is already irrelevant.
Or is it a result of multiplication by PI? Then you are using wrong function. You should use tanPi(). Well I know, easier said than done. tanPi() is a part of IEEE standard for more than decade, but it is still not part of standard libraries for majority of popular languages.
So, what should you do if you want to calculate tan(x*pi) for value of x very close to 0.5 and tanPi() is not available?
The answer is obvious - calculate 1/tan((0.5-x)*pi).
Anyway, more precise argument reduction for tan() is not something that can help your case.
>
> > I think that you have some misconception about x87 in long mode.
> > FYI, as far as hardware and popular x64 OSes (Windows/Linux/BSD, I suppose MAC OS/X too, although I don't know it for sure) goes, x87 in long mode just works.
>
> For now, maybe:
>
> "Early reports claimed that the operating system scheduler would not save and restore the x87 FPU machine state across thread context switches. Observed behavior shows that this is not the case: the x87 state is saved and restored, except for kernel mode-only threads (a limitation that exists in the 32-bit version as well). The most recent documentation available from Microsoft states that the x87/MMX/3DNow! instructions may be used in long mode, but that they are deprecated and may cause compatibility problems in the future." (From Wikipedia)
Sounds like political bullshit.
Neither Microsoft nor other major OS vendors will ever stop saving/restoring x87 state on task switch on x64 platform. Because disadvantages of doing so are too big and *technical* (as opposed to political) advantages are almost non-existing.
They (Microsoft) surely want to maximize similarity between x64 and other platforms, esp aarch64, and they surely would like to kill x87 because of that, but they simply can't do it.
>
> Obviously, a package which results in garbage if some other thread running on the same CPU core is using MMX or x87 instructions is not something I want my name attached to. That means that I have to either figure out a test* which guarantees that the x87 registers are saved and restored correctly, or mark the package as 32-bit compatibility code.
It is always saved/restored. It will continue to be saved/restored for as long as x64 platform is supported.
>
> By the way, you may want to check which mode of code your compiler puts out. For (AMD and Intel) x64 CPUs there are three: Legacy, Compatibility, and Long modes. Long mode uses 64-bit addressing throughout. Compatibility mode allows users a 32-bit (4 Gigbyte) virtual address space per program/application. A program can mix long and compatibility mode sections, and in practice most libraries are compatibility mode.
I don't understand what are you talking about.
In-process libraries, like those that we discuss, always run in the same mode as the rest of the process. At least that's how it works on Windows/Linux/*BSD on x64.
I heard that IBM z/OS works differently, but in context of x87 that particular bit trivia does not appear relevant.