3 ms·
But you haven't demonstrated that the SIMD approach produces a meaningfully different and more accurate approach than the naive method. Just like processor mag
by mywittyname 2y ago
But you haven't demonstrated that the SIMD approach produces a meaningfully different and more accurate approach than the naive method.
Just like processor magic made the theoretically more performant code perform worse, it's possible that the processor has facilities for bucketing the data such that results from such a dataset are the same or more accurate than the naive approach.
This is absolutely a situation that requires empirical testing.
- scaredginger 2y agoYeah, no. If I know what my data look like, I can choose an order of summation that reduces the error. I wouldn't want the compiler by default to assume associativity and introduce bugs. There's a reason this reordering is disabled by default
- Sesse__ 2y agoNot the least that you should get the same result from your code every time, even if you compile it with a different compiler. Doesn't matter if that result is somehow better or worse or “difference is so small that it doesn't matter”; it needs to be exactly the same, every time.
- bee_rider 2y agoI think there’s often a disconnect in these discussions between people that work on libraries and people that work on the application code. If you have written a library, the user will provide some inputs. While the rounding behavior of floating point operations is well defined, for arbitrary user input, you can’t usually guarantee that it’ll go either way. Therefore, you need to do the numerical analysis given users inputs from some range, if you want to be at all rigorous. This will give results with error bounds, not exact bit patterns. If you want exact matches for your tests, maybe identify the bits that are essentially meaningless and write them to some arbitrary value. Edit: that said I don’t think anybody particularly owns rigor on this front, given that most libraries don’t actually do the analysis, lol.
- Dylan16807 2y ago> it's possible that the processor has facilities for bucketing the data such that results from such a dataset are the same or more accurate Not realistically. The processor very much needs to do what you tell it.
- Sesse__ 2y ago> it's possible that the processor has facilities for bucketing the data such that results from such a dataset are the same or more accurate than the naive approach. It absolutely is not. Floating-point addition is completely defined (save for some of the bits in NaN results), and no CPU will start reordering your addition instructions in a way that changes the result. Even if it's an ordering that gives you better accuracy. Having SIMD do four (or more) of them in parallel does not change this.