]> git.sesse.net Git - stockfish/commit
Optimize FT activation and affine transform for NEON.
authorTomasz Sobczyk <tomasz.sobczyk1997@gmail.com>
Thu, 2 Dec 2021 11:29:11 +0000 (12:29 +0100)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Tue, 7 Dec 2021 17:08:54 +0000 (18:08 +0100)
commit4766dfc3956f78d853c5e0c4636d6f90fd93df9a
tree3ba34c6b25c41d0c54d75ccb907798239e5f6fc9
parentb82d93ece484f833c994b40d9eddd959ba20ef92
Optimize FT activation and affine transform for NEON.

This patch optimizes the NEON implementation in two ways.

    The activation layer after the feature transformer is rewritten to make it easier for the compiler to see through dependencies and unroll. This in itself is a minimal, but a positive improvement. Other architectures could benefit from this too in the future. This is not an algorithmic change.
    The affine transform for large matrices (first layer after FT) on NEON now utilizes the same optimized code path as >=SSSE3, which makes the memory accesses more sequential and makes better use of the available registers, which allows for code that has longer dependency chains.

Benchmarks from Redshift#161, profile-build with apple clang

george@Georges-MacBook-Air nets % ./stockfish-b82d93 bench 2>&1 | tail -4 (current master)
===========================
Total time (ms) : 2167
Nodes searched  : 4667742
Nodes/second    : 2154011
george@Georges-MacBook-Air nets % ./stockfish-7377b8 bench 2>&1 | tail -4 (this patch)
===========================
Total time (ms) : 1842
Nodes searched  : 4667742
Nodes/second    : 2534061

This is a solid 18% improvement overall, larger in a bench with NNUE-only, not mixed.

Improvement is also observed on armv7-neon (Raspberry Pi, and older phones), around 5% speedup.

No changes for architectures other than NEON.

closes https://github.com/official-stockfish/Stockfish/pull/3837

No functional changes.
src/Makefile
src/nnue/layers/affine_transform.h
src/nnue/nnue_feature_transformer.h
src/simd.h