Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove uses of INLINE_YL2X from std.math #3310

Closed
wants to merge 1 commit into from

Conversation

ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented May 23, 2015

To initially get std.math bootstrapped onto being pure @trusted nothrow, yl2x did have a purpose.

Now though, its role is meaningless as we have long since had proper pure @trusted nothrow implementations. And if anything, it's now harmful since the introduction of dlang/dmd#4012 as it leaves it open to misuse.

I'm not against having these functions as CTFE-able. I'm just against library maintainers leveraging (unwittingly, as it's not actually their fault if code seems to work for them) non-portable CTFE builtins.

@ibuclaw
Copy link
Member Author

ibuclaw commented May 23, 2015

I need the autotester to report feedback, as it works for me locally. @braddr

@WalterBright
Copy link
Member

Due to whitespace and reformatting changes, this is nearly impossible to review. I can't tell what is substantive and what isn't without spending a great deal of time.

@yebblies
Copy link
Member

@WalterBright Github can hide the whitespace changes from the diff, making review much easier. I don't think it's exposed in the UI anywhere, but you can enable it by adding &w=1 to the url.

Link for this pull: https://github.com/D-Programming-Language/phobos/pull/3310/files?w=1

@ibuclaw
Copy link
Member Author

ibuclaw commented May 24, 2015

Regardless of &w=1 - what part of "Removes INLINE_YL2X" is not understood here? I'm no Kenji or Igor. I don't have time (nor care) about micro re-formatting every line I come across and include it in PRs that have nothing to do with said reformat (that's not to say I haven't undone reformatting done by one or the other though).

@WalterBright
Copy link
Member

@yebblies you're right, thanks for the link, that's much better.

@ibuclaw the part where there are 285 lines of changes, including blocks of test numbers that would have to be compared one digit at a time to ensure they did not change.

@WalterBright
Copy link
Member

So, does the non-INLINE_YL2X branch generate the same code as the INLINE_YL2X branch with dmd?

@ibuclaw
Copy link
Member Author

ibuclaw commented May 26, 2015

So, does the non-INLINE_YL2X branch generate the same code as the INLINE_YL2X branch with dmd?

If you are asking, does the non-INLINE-YL2X branch compile down to the same assembly? Answer no. If you are asking performance? That will need to be tested.

A brief look at an instruction reference manual tells me that the INLINE_YL2X branches will execute at least 63 ops and has a latency of at least 158 (clock ticks or cycles is not specified) [edit: could be substantially more depending on the CPU].

As for the non-INLINE_YL2X branch, that is difficult to say. Someone will need to find the most common path and work out if the accululated fsub/fadd/fmul/fdiv's account for less or more than a single fyl2x instruction.

But rather than being too bogged down on such matters though, instead, you should be asking about comparison of results. Is non-INLINE_YL2X less or more accurate than INLINE_YL2X?

@ibuclaw
Copy link
Member Author

ibuclaw commented May 26, 2015

Autotester can't test these unless this is pulled in: #3309

@ibuclaw
Copy link
Member Author

ibuclaw commented Jun 7, 2015

Until you fix Phobos builds, this is blocked.

@9il
Copy link
Member

9il commented Jul 20, 2015

Probably we need relax gamma function unittests?

@9il
Copy link
Member

9il commented Jul 20, 2015

#3309 was merged, however unittests fails.

@ibuclaw
Copy link
Member Author

ibuclaw commented Jul 21, 2015

I have the same test passing with gdc. Could be that dmd is using an inline assembly code path that is producing subtly a different result from the generic version. But that is just speculation...

@DmitryOlshansky
Copy link
Member

Until you fix Phobos builds, this is blocked.

Guess now it's unblocked. @WalterBright

@quickfur
Copy link
Member

ping @WalterBright
It has been a while. What's the status with dmd on this PR?

@ibuclaw
Copy link
Member Author

ibuclaw commented Feb 20, 2016

Who's idea was it to add FP magic with dmd to the list of phobos labels?

@9il
Copy link
Member

9il commented Feb 20, 2016

my

@ibuclaw
Copy link
Member Author

ibuclaw commented Feb 20, 2016

Assuming that the line of failure reported by the auto-tester is correct. https://github.com/D-Programming-Language/phobos/blob/b2f1987cb3ec2d34739a02e55bff19e4443c0b36/std/internal/math/gammafunction.d#L540

GDC does not have this problem, which could indicate an issue with DMD codegen. But then again, maybe not if the inline assembler is involved in producing one of the answers.

@DmitryOlshansky
Copy link
Member

Seems like it started to pass

@9il
Copy link
Member

9il commented Nov 12, 2016

@ibuclaw rebase please

@ibuclaw
Copy link
Member Author

ibuclaw commented Jan 20, 2017

From what I recall, spoke to Don about this and I think we uncovered a problem with the asm implementation of exp2, where it was less accurate than the generic version if it fell into the slow branch. I suspect that it's not helped by y2lx not being a very accurate instruction either.

@MetaLang
Copy link
Member

MetaLang commented Aug 6, 2017

@ibuclaw what's the status of this?

@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 6, 2017

I'll mark it as blocked until the non-asm implementations become ctfe-able.

In the meantime, someone should look at why the asm implementation for exp2 is less accurate. And remove / fix tests that check for this inaccuracy.

@ibuclaw
Copy link
Member Author

ibuclaw commented Apr 16, 2021

Superseded by #7668

@ibuclaw ibuclaw closed this Apr 16, 2021
@ibuclaw ibuclaw deleted the inlineyl2x branch April 16, 2021 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants