Bitcoin full node and query server

Dec 6, 2024

View in context in the libbitcoin Slack #general mirror.

evoskuil14:44
The AMD Ryzen 9 7950X has shani as well as sse4, avx2, and avx512. I haven't been able to perf test with avx512 yet but it's implemented.
18 replies · neillm, evoskuil · last Dec 06, 2024
neillm15:33
Ah, that would explain why I'm seeing a build error with avx512 enabled! Here for reference:
... snip ...
                 from ./include/bitcoin/system/settings.hpp:22,
                 from ./include/bitcoin/system.hpp:29,
                 from examples/main.cpp:21:
./include/bitcoin/system/intrinsics/xcpu/functional_512.hpp: In function 'libbitcoin::system::xint512_t libbitcoin::system::add(xint512_t, xint512_t)':
./include/bitcoin/system/intrinsics/xcpu/functional_512.hpp:163:31: error: cannot convert 'libbitcoin::system::xint512_t' {aka '__m512i'} to '__m256i'
  163 |         return mm256_add_epi8(a, b);
      |                               ^
      |                               |
      |                               libbitcoin::system::xint512_t {aka __m512i}
./include/bitcoin/system/intrinsics/xcpu/defines.hpp:224:61: note: in definition of macro 'mm256_add_epi8'
  224 |     #define mm256_add_epi8(a, b)            _mm256_add_epi8(a, b)
      |                                                             ^
In file included from /usr/lib/gcc/x86_64-linux-gnu/14/include/immintrin.h:53,
                 from /mnt/ssd1/libbitcoin/master/install/include/boost/multiprecision/cpp_int/intel_intrinsics.hpp:83,
                 from /mnt/ssd1/libbitcoin/master/install/include/boost/multiprecision/cpp_int/add_unsigned.hpp:10,
                 from /mnt/ssd1/libbitcoin/master/install/include/boost/multiprecision/cpp_int/add.hpp:12,
                 from /mnt/ssd1/libbitcoin/master/install/include/boost/multiprecision/cpp_int.hpp:2284,
                 from ./include/bitcoin/system/boost.hpp:54,
                 from ./include/bitcoin/system/exceptions.hpp:26,
                 from ./include/bitcoin/system/arena.hpp:22,
                 from ./include/bitcoin/system/allocator.hpp:28,
                 from ./include/bitcoin/system.hpp:17:
/usr/lib/gcc/x86_64-linux-gnu/14/include/avx2intrin.h:105:26: note:   initializing argument 1 of '__m256i _mm256_add_epi8(__m256i, __m256i)'
  105 | _mm256_add_epi8 (__m256i __A, __m256i __B)
      |                  ~~~~~~~~^~~
./include/bitcoin/system/intrinsics/xcpu/functional_512.hpp:165:32: error: cannot convert 'libbitcoin::system::xint512_t' {aka '__m512i'} to '__m256i'
  165 |         return mm256_add_epi16(a, b);
      |                                ^
      |                                |
      |                                libbitcoin::system::xint512_t {aka __m512i}
./include/bitcoin/system/intrinsics/xcpu/defines.hpp:225:62: note: in definition of macro 'mm256_add_epi16'
  225 |     #define mm256_add_epi16(a, b)           _mm256_add_epi16(a, b)
      |                                                              ^
/usr/lib/gcc/x86_64-linux-gnu/14/include/avx2intrin.h:112:27: note:   initializing argument 1 of '__m256i _mm256_add_epi16(__m256i, __m256i)'
  112 | _mm256_add_epi16 (__m256i __A, __m256i __B)
      |                   ~~~~~~~~^~~
./include/bitcoin/system/intrinsics/xcpu/functional_512.hpp:167:32: error: cannot convert 'libbitcoin::system::xint512_t' {aka '__m512i'} to '__m256i'
  167 |         return mm256_add_epi32(a, b);
      |                                ^
      |                                |
      |                                libbitcoin::system::xint512_t {aka __m512i}
./include/bitcoin/system/intrinsics/xcpu/defines.hpp:226:62: note: in definition of macro 'mm256_add_epi32'
  226 |     #define mm256_add_epi32(a, b)           _mm256_add_epi32(a, b)
      |                                                              ^
/usr/lib/gcc/x86_64-linux-gnu/14/include/avx2intrin.h:119:27: note:   initializing argument 1 of '__m256i _mm256_add_epi32(__m256i, __m256i)'
  119 | _mm256_add_epi32 (__m256i __A, __m256i __B)
      |                   ~~~~~~~~^~~
./include/bitcoin/system/intrinsics/xcpu/functional_512.hpp:169:32: error: cannot convert 'libbitcoin::system::xint512_t' {aka '__m512i'} to '__m256i'
  169 |         return mm256_add_epi64(a, b);
      |                                ^
      |                                |
      |                                libbitcoin::system::xint512_t {aka __m512i}
./include/bitcoin/system/intrinsics/xcpu/defines.hpp:227:62: note: in definition of macro 'mm256_add_epi64'
  227 |     #define mm256_add_epi64(a, b)           _mm256_add_epi64(a, b)
      |                                                              ^
/usr/lib/gcc/x86_64-linux-gnu/14/include/avx2intrin.h:126:27: note:   initializing argument 1 of '__m256i _mm256_add_epi64(__m256i, __m256i)'
  126 | _mm256_add_epi64 (__m256i __A, __m256i __B)
      |                   ~~~~~~~~^~~
make: *** [Makefile:4993: examples/libbitcoin_system_examples-main.o] Error 1
neillm15:35
For now I'm going to disable that, but can help test at some point
evoskuil15:36
AVX512 builds and runs, we execute it in our CI tests. How did you enable it?
(edited)
neillm15:38
Clang or Gcc? Everything builds and runs fine with that option disabled
neillm15:39
With it disabled (run just now):
./configure --with-tests --with-examples --with-pkgconfigdir=/mnt/ssd1/libbitcoin/master/install/lib/pkgconfig --prefix=/mnt/ssd1/libbitcoin/master/install --with-boost=/mnt/ssd1/libbitcoin/master/install --with-zmq --with-zlib --with-icu --with-qrencode --with-png --enable-static --disable-shared --enable-avx2 --enable-shani --enable-sse41
neillm15:39
I'm using gcc-14
neillm15:40
checking --with-pkgconfigdir option... /mnt/ssd1/libbitcoin/master/install/lib/pkgconfig
checking --with-tests option... yes
checking --with-examples option... yes
checking --with-icu option... yes
checking --enable-avx2 option... yes
checking --enable-avx512 option... no
checking --enable-sse41 option... yes
checking --enable-shani option... yes
checking --enable-ndebug option... yes
checking --enable-isystem option... no
evoskuil15:41
There’s no option for zlib, qrencode, png or zmq.
neillm15:41
Yeah, this was generated from a build script I use
neillm15:41
It passes more info than needed (and is also old)
evoskuil15:48
Above is a recent regression (yesterday). I guess we aren't running avx512 on CI unless there's an available platform. I know the tests used to pass that detected it. I'll patch now.
🙏 1
evoskuil15:50
Done
neillm15:51
Thanks, will try!
🕺🏻 1
neillm15:52
Yep, that did it 🔥
👍🏻 1
evoskuil15:55
These tests are just Merkle with and without vectorization. They don't include shani. The interesting avx512 test is the ratio of the vector tests to non-vector here. it's about 21% with avx2. I'm expected about 10% with avx512.
evoskuil15:57
The disabled tests below are non-merkle. You can set up sha256a_comp (shani) and sha256a_both (shani and vectorization) to get the shani stuff. base_sha256a is the Core baseline.
(edited)
evoskuil15:58
You can do the same for the Merkle tests if you want. There's still several places where shani isn't fully incorporated though. It doesn't currently benefit Merkle.