Skip to content
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

Closed
ldionne opened this issue Jan 10, 2024 · 3 comments · Fixed by #77747
Closed

[D145982] [libc++] Implement std::gcd using the binary version #77648

ldionne opened this issue Jan 10, 2024 · 3 comments · Fixed by #77747
Assignees
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. phabricator Related to migration from Phabricator

Comments

@ldionne
Copy link
Member

ldionne commented Jan 10, 2024

This issue tracks picking up https://reviews.llvm.org/D145982 from the Phabricator archive.

@ldionne ldionne added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jan 10, 2024
@ldionne ldionne added awaiting-review Has pending Phabricator review phabricator Related to migration from Phabricator and removed awaiting-review Has pending Phabricator review labels Jan 10, 2024
@AdvenamTacet
Copy link
Member

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.

@serge-sans-paille
Copy link
Collaborator

@AdvenamTacet : will do!

serge-sans-paille added a commit to serge-sans-paille/llvm-project that referenced this issue Jan 12, 2024
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
@AdvenamTacet
Copy link
Member

AdvenamTacet commented Jan 18, 2024

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:
https://quick-bench.com/q/pA3seH2pCZjP7WMeIGnUhUXJmrQ (there is a problem with that benchmark, read the discussion in the PR for details).

serge-sans-paille added a commit to serge-sans-paille/llvm-project that referenced this issue Apr 29, 2024
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
serge-sans-paille added a commit to serge-sans-paille/llvm-project that referenced this issue Apr 29, 2024
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
serge-sans-paille added a commit to serge-sans-paille/llvm-project that referenced this issue May 2, 2024
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
serge-sans-paille added a commit to serge-sans-paille/llvm-project that referenced this issue May 2, 2024
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
serge-sans-paille added a commit to serge-sans-paille/llvm-project that referenced this issue May 3, 2024
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
serge-sans-paille added a commit to serge-sans-paille/llvm-project that referenced this issue May 4, 2024
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
serge-sans-paille added a commit to serge-sans-paille/llvm-project that referenced this issue May 4, 2024
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
serge-sans-paille added a commit to serge-sans-paille/llvm-project that referenced this issue May 4, 2024
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
serge-sans-paille added a commit that referenced this issue May 8, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. phabricator Related to migration from Phabricator
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants