Bit functions: refactoring, extension, and optimisation - #23
Open
synesissoftware wants to merge 13 commits into
Open
synesissoftware wants to merge 13 commits into
synesissoftware wants to merge 13 commits into
Conversation
Replace the short separator above each namespace close with the long section banner, and drop the short separator that precedes the include-guard close: - Refresh **Updated:** to 24th September 2026 and extend the Synesis Information Systems copyright through 2026; - Bump each header **EDIT** counter;
Expand **test.unit.stlsoft.util.bit_functions** so every public C++ overload is called for each supported width, plus `count_bits(int)` for signedness; - Add Kernighan and 8-bit-table cases for **uint64_t**; - Add **count_bits** for **uint32_t**, **uint64_t**, and **int**; - Add **find_highest_bit** for **uint8_t** and **uint16_t**; - Add **calculate_xor_over_range** for 16-, 32-, and 64-bit ranges; - Remove in-unit stopwatch timing;
Add **test.performance.stlsoft.bit_functions** under a nested **stlsoft/** performance tree, with an aligned width × function timing table covering every public bit-function overload; - Wire **test/performance/CMakeLists.txt** → **stlsoft** → **bit_functions**; - Time Kernighan and 8-bit-table popcount, **count_bits**, **find_highest_bit**, and **calculate_xor_over_range**;
…Kernighan` is defined
Extend **test.performance.stlsoft.bit_functions** with denser popcount workloads so Kernighan vs 8-bit-table can be compared beyond the sparse sequential-i series; - Add /~i (bitwise-not), /ones (volatile all-ones), and /ones^1 (all-ones with one rotating bit cleared); - Widen the function-name column for the longer row labels;
Stop importing stlsoft::uint64_t into the global namespace: it conflicts with ::uint64_t from <cstdint> (pulled in via std_chrono_hrc_stopwatch) and made 64-bit overloads ambiguous on Linux GCC. - Use stlsoft::ss_uintN_t aliases for variables and casts; keep column headers as uintN_t labels;
Time each row as one discarded warmup plus five samples and print the median. Accumulate the anchor in ss_uint64_t. Print STLSOFT_COMPILER_VERSION_STRING, whether optimisation is size, speed, or off, and whether this is a release or debug-asserts build.
Zero-initialise the local sorted[] buffer in median_sample, guard empty n, and clamp n to NUM_SAMPLES so GCC -Werror=maybe-uninitialized no longer fails the performance harness on CI.
GarthJL1965
approved these changes
Sep 24, 2026
Add volatile-zero, rotating-bit, and both-halves-live rows for popcount and find_highest_bit, so the 64-bit high half is exercised. Print ns/call on the same line as the loop time, ns/element for XOR, and the anchor last. Honor SIS_PERFTESTS_GROUPGAPS with a blank line between operation and input-pattern groups.
Keep the 8-bit table as the default for count_bits(). Apple Clang rewrites Kernighan into a hardware popcount; Linux and Windows compilers execute the source loop and the table is faster there.
Add unselected `count_bits_by_intrinsic()` / `find_highest_bit_by_intrinsic()`, with external/internal bitfns detection (GCC/Clang builtins preferred over MSVC), 8/16-bit count overloads, Clang `STLSOFT_CLANG_VER`, unit and performance coverage, and strategy notes that keep the 8-bit table as the `count_bits()` default;
Cast MSVC `__popcnt64` through `STLSOFT_C_CAST(int, …)` so `/WX` builds stop on C4244. Export `SIS_PERFTESTS_GROUPGAPS=1` for the performance job and only print the harness banner when that env is truey. Quiet getenv C4996 and narrow `~` promotions on uint8/16 ones patterns. Record Linux GCC 13.3 (~3.1 ns soft popcount vs table) and Apple Clang 21 CI findings in `strategy/BIT_FUNCTIONS.md`.
mwsis
approved these changes
Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.