-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[D145982] [libc++] Implement std::gcd using the binary version #77648
Comments
I played a little with the benchmark from the Phabricator to test also bigger numbers in gcd. Performance gain is consistent. But I think, we should add random tests to gcd test - 1000 times taking ranom numbers or numbers from a range and comparing with a naive implementation. Just because this implementation is prone to be bugged during a refactor. |
@AdvenamTacet : will do! |
The binary version is four times faster than current implementation in my setup, and generally considered a better implementation. Code inspired by https://en.algorithmica.org/hpc/algorithms/gcd/ which itself is inspired by https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor/ Fix llvm#77648
I looked at the algorithm closer and described a problem with it in PRs comment. I don't think we should change gcd algorithm to that one. If I made a mistake in benchmarks, please let me know. Example of too big performance hit: |
The binary version is four times faster than current implementation in my setup, and generally considered a better implementation. Code inspired by https://en.algorithmica.org/hpc/algorithms/gcd/ which itself is inspired by https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor/ Fix llvm#77648
The binary version is four times faster than current implementation in my setup, and generally considered a better implementation. Code inspired by https://en.algorithmica.org/hpc/algorithms/gcd/ which itself is inspired by https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor/ Hybrid approach and benchmarks inspired by `ylchapuy <https://github.com/ylchapuy>`. Fix llvm#77648
The binary version is four times faster than current implementation in my setup, and generally considered a better implementation. Code inspired by https://en.algorithmica.org/hpc/algorithms/gcd/ which itself is inspired by https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor/ Hybrid approach and benchmarks inspired by `ylchapuy <https://github.com/ylchapuy>`. Fix llvm#77648
The binary version is four times faster than current implementation in my setup, and generally considered a better implementation. Code inspired by https://en.algorithmica.org/hpc/algorithms/gcd/ which itself is inspired by https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor/ Hybrid approach and benchmarks inspired by `ylchapuy <https://github.com/ylchapuy>`. Fix llvm#77648
The binary version is four times faster than current implementation in my setup, and generally considered a better implementation. Code inspired by https://en.algorithmica.org/hpc/algorithms/gcd/ which itself is inspired by https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor/ Hybrid approach and benchmarks inspired by `ylchapuy <https://github.com/ylchapuy>`. Fix llvm#77648
The binary version is four times faster than current implementation in my setup, and generally considered a better implementation. Code inspired by https://en.algorithmica.org/hpc/algorithms/gcd/ which itself is inspired by https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor/ Hybrid approach and benchmarks inspired by `ylchapuy <https://github.com/ylchapuy>`. Fix llvm#77648
The binary version is four times faster than current implementation in my setup, and generally considered a better implementation. Code inspired by https://en.algorithmica.org/hpc/algorithms/gcd/ which itself is inspired by https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor/ Hybrid approach and benchmarks inspired by `ylchapuy <https://github.com/ylchapuy>`. Fix llvm#77648
The binary version is four times faster than current implementation in my setup, and generally considered a better implementation. Code inspired by https://en.algorithmica.org/hpc/algorithms/gcd/ which itself is inspired by https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor/ Hybrid approach and benchmarks inspired by `ylchapuy <https://github.com/ylchapuy>`. Fix llvm#77648
The binary version is four times faster than current implementation in my setup, and generally considered a better implementation. Code inspired by https://en.algorithmica.org/hpc/algorithms/gcd/ which itself is inspired by https://lemire.me/blog/2013/12/26/fastest-way-to-compute-the-greatest-common-divisor/ Fix #77648
This issue tracks picking up https://reviews.llvm.org/D145982 from the Phabricator archive.
The text was updated successfully, but these errors were encountered: