Skip to content

Replaces hypotenuses length calculation by hypot() call#195

Open
denizzzka wants to merge 5 commits intogecko0307:masterfrom
denizzzka:dista_impr
Open

Replaces hypotenuses length calculation by hypot() call#195
denizzzka wants to merge 5 commits intogecko0307:masterfrom
denizzzka:dista_impr

Conversation

@denizzzka
Copy link
Contributor

Hypotenuse calculation is used in many places in the code and can be sped up (but not right now, see: dlang/phobos#10906)

I made it into separate commits to make it easier to check and roll back if I screwed up somewhere

@denizzzka denizzzka marked this pull request as draft November 29, 2025 23:05
@gecko0307 gecko0307 marked this pull request as ready for review November 30, 2025 15:26
@gecko0307
Copy link
Owner

gecko0307 commented Nov 30, 2025

Tested this with some Dagon demos, and at least basic logics in the engine didn't break. Right now I'm not sure yet how justified such a change is. Performance-wise, it needs proper benchmarking, ideally against different implementations of hypot and sqrt, including LDC intrinsics. llvm_sqrt is already almost free, for instance.
I'm working on a faster math library for dcore, which will be the basis for dlib 2.0, and I think it's better to postpone this until dlib.math is ported to dcore.math.

@denizzzka
Copy link
Contributor Author

llvm_sqrt is already almost free

Someone on internet write that the SIMD version of hypot() works 2-8 times faster than naive implementation, especially for three-argument

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants