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

Use libstdc++ implementation of std::bitset if other standard library is used #517

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

p-senichenkov
Copy link
Collaborator

@p-senichenkov p-senichenkov commented Jan 31, 2025

Copy libstdc++ implementation of std::bitset to use it when project is compiled with libc++ (and possibly other STL implementations). Fixes #516.

Here are macOS Apple Clang run times after this fix:
Снимок экрана_20250201_214626
Снимок экрана_20250201_214756

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 25 out of 32. Check the log or trigger a new build to see more.

src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/tests/test_bitset.cpp Outdated Show resolved Hide resolved
@p-senichenkov p-senichenkov force-pushed the fix-516 branch 3 times, most recently from 40394c1 to 269a744 Compare January 31, 2025 20:20
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 25 out of 32. Check the log or trigger a new build to see more.

src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
src/core/model/types/bitset.h Show resolved Hide resolved
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/tests/test_bitset.cpp Outdated Show resolved Hide resolved
@p-senichenkov p-senichenkov force-pushed the fix-516 branch 2 times, most recently from 691dea7 to cc31c8f Compare January 31, 2025 20:53
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/tests/test_bitset.cpp Outdated Show resolved Hide resolved
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

src/tests/test_bitset.cpp Outdated Show resolved Hide resolved
@p-senichenkov p-senichenkov force-pushed the fix-516 branch 4 times, most recently from 7bb52ce to a02c213 Compare February 1, 2025 18:14
Implement bitset and bitset tests
Use implemented bitset instead of std::bitset in:
- fdep::FDTreeElemend
-     ::FDep
- od::AttributeSet
- dc::Predicate
-   ::CommonClueSetBuilder
Remove src/core/bitset_extensions, because now it's not needed
@p-senichenkov p-senichenkov marked this pull request as ready for review February 1, 2025 19:25
src/core/model/types/bitset.h Outdated Show resolved Hide resolved
Specialize std::hash instead of hash inside of namespace std
to avoid UB
Copy link
Collaborator

@Vdaleke Vdaleke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me, but I can't say with much certainty that using Apache and GPL-3 with our AGPL is fully compatible, as I'm not a lawyer. But if you trust the information on the Internet, then everything seems ok. For example:

https://opensource.stackexchange.com/a/8271

https://en.wikipedia.org/wiki/GNU_Affero_General_Public_License#:~:text=By%20contrast%2C%20the%20GPLv3,combinations.%5B2%5D

P.S. I didn't look a lot at the code in the added bitset.h as I trust that it was copied from gcc and doesn't need review :)

src/core/model/types/bitset.h Outdated Show resolved Hide resolved
FlipAll, Flip, FlipInvalidIndex, ToString, ToStringCustomChars, ToULong,
ToULLong, And, Or, Xor, ToStream, FromStream, FindFirst, FindNext);

using BitsetSizes = ::testing::Types<BitsetSizeParam<8>, BitsetSizeParam<128>>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why exactly these values? Are they used in our algorithms? Is 64 also used? Maybe we should put all our values ​​from all used bitsets there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are just convenient values for testing. 8-bit is a single-word bitset (with most zeros), 128-bit contains at least 2 words on any system. I believe that 64-bit will work fine too, considering these two work.

@p-senichenkov p-senichenkov requested a review from Vdaleke February 9, 2025 10:23
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.

Some tests work very slow on Clang in Debug mode
3 participants