std.math performance (SSE vs. real)

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 29 15:20:23 PDT 2014


On Sun, Jun 29, 2014 at 08:54:49AM +0100, Iain Buclaw via Digitalmars-d wrote:
> On 29 Jun 2014 05:48, "H. S. Teoh via Digitalmars-d" <
> digitalmars-d at puremagic.com> wrote:
> >
> > On Sat, Jun 28, 2014 at 08:41:24PM -0700, Andrei Alexandrescu via
> Digitalmars-d wrote:
> > > On 6/28/14, 6:02 PM, Tofu Ninja wrote:
> > [...]
> > > >I think this thread needs to refocus on the main point, getting
> > > >math overloads for float and double and how to mitigate any
> > > >problems that might arise from that.
> > >
> > > Yes please. -- Andrei
> >
> > Let's see the PR!
> >
> 
> I've already raised one (already linked in this thread).

Are you talking about #2274? Interesting that your implementation is
basically identical to my own idea for fixing std.math -- using unions
instead of pointer casting. However, without compiler support for
repainting scalars in a union, I couldn't get what I needed to work. I'm
trying to make atan2 CTFE-able, but it in turn uses isInfinity, isNaN,
signbit, and possibly one or two others, and while I managed to hack
isInfinity and isNaN, signbit defeated me due to the signedness of NaNs,
which cannot be extracted in any other way.


> More to come!

Are you going to implement repainting unions in CTFE? That would be
*awesome*.


[...]
> > Perhaps we can introduce some intrinsics for implementing these
> > functions so that they work both in CTFE and at runtime?
> >
> >         https://issues.dlang.org/show_bug.cgi?id=3749
> >
> 
> CTFE support for accessing basic types in unions - as in painting
> between all kinds of scalar types, with special support for static
> arrays (via vectors) should be all that is required.

I thought as much. Currently, unions don't support repainting in CTFE,
so it doesn't work. I think that's the last hurdle needed, since with
repainting everything else can be done in code.


> Once CTFE supports that, it won't be difficult to get std.math to be
> CTFE-certified. :)
[...]

Looking forward to that!


T

-- 
Why ask rhetorical questions? -- JC


More information about the Digitalmars-d mailing list