Skip to content

Bit functions: refactoring, extension, and optimisation - #23

Open
synesissoftware wants to merge 13 commits into
devfrom
bit-functions
Open

synesissoftware wants to merge 13 commits into
devfrom
bit-functions

Conversation

@synesissoftware

Copy link
Copy Markdown
Owner

No description provided.

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**;
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.
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`.
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.

3 participants