-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Updated cumsum to use K-B-N summation for float arrays. #1257
Conversation
There was some discussion about not doing KBN by default for summation since it was found to be slower than standard summation by quite a bit on some machines. But since I believe we're doing KBN in sum by default, we should definitely do it here as well. |
I can't find that conversation about KBN performance now, but unless I'm hallucinating, it did happen. @JeffBezanson, @ViralBShah: thoughts? Also, can you find that thread? |
Right! Thanks, Tim. |
Yeah, we definitely need some kind of decision here. Question is which one... |
Why, the right one, of course! ;-) (...as opposed to the left one...) |
I picked this because I found it about 20% slower on my machine. Turns out it is 2x slower for some people. I would have decided differently if I had seen a 2x slowdown. Every other environment seems to use naive summation, and I suspect that compensated summation is not so important for real-world data. Naive summation also has the advantage of behaving the same as |
Can we do a more systematic benchmark? 20% is certainly ok, but 2x is certainly a deal-breaker. Given that most real world uses do not care about KBN summation, it would be nice to have a |
Well, I don't have a good handle on the "real world" part of it. KBN always gives a better answer, but a few ulps better is less important than the drastic differences you see in synthetic test cases. Maybe we should consider whether people "expect" naive summation. Is |
Although julia gives the correct answer |
Defining "correct" is the problem! |
Correctness is well defined, in my opinion. It is acceptability that has to be defined. |
I think "correct" in quotations means "acceptable". But, yes, I agree, the correct answer exists and is not up for debate in these cases. I do, however, wonder if people don't actually expect naïve summation. There's also the issue that the KBN algorithm is not guaranteed to give a correct answer — it's just better than naïve. |
Since we're currently using KBN for summation, I'm merging this so that sum and cumsum match each other. |
Updated cumsum to use K-B-N summation for float arrays.
Just a reminder of #1258: sum is not consistent in using KBN. |
Yeah, absolutely. I hadn't forgotten, but at least we're a little bit closer to consistency... |
No description provided.