-
-
Notifications
You must be signed in to change notification settings - Fork 668
Deprecate imaginary and complex types #7640
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
Conversation
|
Thanks for your pull request, @wilzbach! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
|
Okay after looking a bit into this (see dlang/phobos#6014) I found the following problems:
So usage of
For example: |
|
Could help by removing all tests using complex and imaginary types? |
Do you mean for Phobos? Yep, that's one idea, but I guess improving this deprecation check to check whether's in a |
|
Yeah, should be simple. Pass the Then do a cheeky copy-pasto: Lines 312 to 326 in c22cba2
|
src/dmd/mars.d
Outdated
| params.bug10378 = true; | ||
| break; | ||
| case 14488: | ||
| printf("-transition=14488 is no longer needed.\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use global.stdmsg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have seen printf being used here a couple of times, but sure global.stdmsg looks cleaner.
9694227 to
ec37791
Compare
ec37791 to
a722019
Compare
a722019 to
76d3dc9
Compare
Its just the cost of copying to and from xmm registers and the stack whenever you use or modify the struct type. I see no inlining problems of all the trivial operators, particularly if the stuct type is templated. |
You mean, how is it passed? And on which target? |
|
@ibuclaw I wonder if _Complex would be compatible with a struct layout. |
|
So, The layout is the same, they just live in different places (depending on target). |
|
Just for comparison. LDC's functions were taken from @9il 's post, and were compiled using the following flags. GDC's functions were taken from explore.dgnu.org and compiled using the following flags. Native Multiplication. LDC: GDC: std.complex Multiplication. LDC: GDC: Native Divide. LDC: GDC: std.complex Divide. LDC: GDC: |
|
Notable observations / tl;dr.
|
|
I can not discus this more. Sorry. My arguments still valid. |
In what sense though? Just to paraphrase your argument into a digestible format (I hope that I stay true to the meaning in doing so):
Whereas from what I can see based on your examples, points 1 and 2 are simply not true (see codegen of GDC). It is not outside the capability of a D compiler to generate the most optimal code using std.complex. And so rather than point 3, it looks like only minor improvements to std.complex to encourage better codegen is needed in some places of phobos. I can comb through this later. |
I'm not sure what do you mean by that, but what I would agree that this should not be deprecated until there is some certainty that the alternative is ready to fully replace the deprecated functionality. There is no point in deprecating something when the alternative is half done, because then you let the user in a wasteland where you either get spurious deprecation messages or you have to start using a half-baked alternative. |
|
Functionality has been there for years in std.complex. I wouldn't call it half done, but increased use/reliance on it will bring into sharp focus areas that could be improved, either at compile or runtime. Both are not blockers per say, but it will reflect on std.complex positively as far as performance goes. Only open question I see that has not been discussed is what a hypothetical core.complex would look like and why, and what precisely would be exposed by the compiler @andralex. |
Intuitively programs should be able to use the complex type, at least the basics (layout and fundamental operations) without needing the standard library. |
We ship the standard library with all releases - it's after all the standard library, so I think you were referring to "usable in -betterC". As mentioned before by @ibuclaw nearly all methods are already templates and thus can be used in |
|
@kinke you wanted to know some examples, here is one. |
As long as we don't pull the switch here, people will use the built-in complex types and not
Yes, but the implementation of complex numbers in DMD isn't well tested because not so many people use it and hence people run into bugs: https://issues.dlang.org/show_bug.cgi?id=18464 I don't think that finding all the places in DMD which need to be special-cased for complex number isn't time well spent either.
Why does it need to be in DRuntime then? Can't we just ensure that the basics work with Also we have made a lot of bad experiences with adding modules to druntime and phobos + the interest of using complex numbers without Phobos seems to be limited to math libraries like mir, so why couldn't this be a DUB package? |
Well, if you are a maintainer of a specialization library geared towards math, you probably won't use half of what's available in std anyway. I still think the only outstanding thing here is ABI compatibility with C. We already have |
|
Hello, I'm upgrading to 2.079 and I see builtin complexes continue their descent into deprecation. Many functions in std.math have been deprecated. Please reconsider, builtin complexes are extremely useful. I use builtin complex types heavily for signal processing, where they are both more readable and faster. BENCHMARK: Key takeaway:
I use builtin complex originally because they are faster (in that I've also found what @9il has found) but also the syntax is an improvement over just a struct. I think this realization will be found by anyone doing heavy number crunching with D. |
And just for balance, I use std.complex because I found the opposite to be true. :-) I've already stated here that std.complex is not inherently slow, and the compiler can generate performant code with it. |
|
@ibuclaw In your comment you showed that (at least in GDC), builtin complex division and multiplication jump to a library, but there are no measurements that it's faster or slower that way. (EDIT: I see that did measure with the https://issues.dlang.org/show_bug.cgi?id=18627 example, interesting data point) Builtin complexes are the thing that is being replaced. It's the baseline. From the user point of view I don't care if they are kept or not, I only care that the replacement is at least as fast guaranteed. Else it's a performance regression, and when using DMD this performance regression is (currently) guaranteed. I get it. Most people don't need complex numbers at all. So everyone want them dead, and assume noone is using them (again without asking since 6 years). But some of us are. I've become increasingly admirative of their design since doing a bit of math. It's not like they were added for no reason. Complex numbers are used thoughout numerical programming. Mostly I trust the inliner, but using LDC there is nothing to trust or not being that builtin complexes are always inlined. Not having to trust > trust. |
With this argument, we wouldn't be allowed to use ranges. They are usually 2-3x slower than their naive loop replacement in DMD.
That's what |
|
Well, I certainly don't use any range in sensitive numerical processing functions. That's just basic de-risking to me. If you optimize you just can't assume "zero-cost-abstractions" are zero-cost because of their name. |
|
@ibuclaw has taken this over, so I think we can close this. |
Turn the complex deprecation on by default.
Follow-up to #7081
This might need some work, depending on what Jenkins tells us.