[WIP] Add intel simd #1703

pull Raimo33 wants to merge 1 commits into bitcoin-core:master from Raimo33:simd changing 12 files +1551 −202
  1. Raimo33 commented at 11:26 am on July 18, 2025: none

    This adds sse2 and avx2 support to the library in general, as discussed in #1700, wherever it yields an improvement as per the benchmarks.

    arm has different SIMD instruction set; it would be nice to have a separate PR implementing that as well. Maybe after this is merged…

    Tasks:

    • Add 2 CI/CD flows with permutations of -msse2, -mno-sse2 when building for amd32
    • Add 4 CI/CD flows with permutations of -mavx2, -msse2, -mno-avx2, -mno-sse2 when building for amd64
    • Precompute vectors at startup (the ones marked with TODO: precompute )

    Test & Benchmark

    To reproduce the following results I temporarily added 3 scripts for building, testing, benchmarking as well as a jupyter notebook to visualize results. You can verify yourself by running: ./simd-build.sh && ./simd-test.sh && ./simd-bench.sh and executing the notebook as is.

    Results

  2. Raimo33 renamed this:
    Add simd
    Add intel simd
    on Jul 18, 2025
  3. Raimo33 commented at 3:18 pm on July 18, 2025: none

    To precompute simd constants at the start, the best solution I found was doing something like this:

    0#ifdef __SSE2__
    1  static __m128i _128_vec_ones;
    2#endif
    3
    4CONSTRUCTOR void simd_init(void)
    5{
    6#ifdef __SSE2__
    7  _128_vec_ones   = _mm_set1_epi8('1');
    8#endif
    9}
    

    where CONSTRUCTOR is __attribute__((constructor))

  4. Raimo33 commented at 5:00 pm on July 18, 2025: none

    I’m constantly getting these warnings. Apparently they’re harmless since I always use loadu and storeu, but for some reason the compiler doesn’t like them.

    0warning: cast increases required alignment of target type [-Wcast-align]
    1  653 |         _mm256_storeu_si256((__m256i *)r->v, out);
    

    The only fixes I found are:

    1. aligning everything to 64bytes (impossible, breaks even some of my avx logic)
    2. suppress the warning globally
    3. suppress the warning inline each time
  5. Raimo33 force-pushed on Aug 1, 2025
  6. Raimo33 renamed this:
    Add intel simd
    [WIP] Add intel simd
    on Aug 23, 2025
  7. Raimo33 force-pushed on Aug 27, 2025
  8. Raimo33 force-pushed on Aug 27, 2025
  9. Raimo33 force-pushed on Aug 28, 2025
  10. Raimo33 force-pushed on Aug 28, 2025
  11. Raimo33 force-pushed on Aug 30, 2025
  12. Raimo33 force-pushed on Aug 30, 2025
  13. Raimo33 force-pushed on Aug 30, 2025
  14. Add intel simd [skip ci] 2fe10e8801
  15. Raimo33 force-pushed on Aug 30, 2025


Raimo33


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/secp256k1. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-08-31 00:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me