Use SumsOf8 for AVX2 u8 lane sums - #3242
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
f83aa55 to
f5ce2cd
Compare
|
The GCC-16 AArch64 job was cancelled (timed-out?) during the build without a compiler or test failure. The same PR commit passes AArch64 Clang-22 and the other foreign-architecture jobs. Could someone with repository permissions please re-run this job? |
jan-wassenberg
left a comment
There was a problem hiding this comment.
Nice optimization, thanks :)
Problem
Full-width AVX2
uint8_tSumOfLanesandReduceSumuse the generic shuffle-and-widen reduction despite AVX2 already having a nativeSumsOf8implementation.Root cause
The generic reduction eligibility condition excludes the existing u8x8 and u8x16 specialisations, but not u8x32. There is therefore no overload that routes a 256-bit byte reduction through
SumsOf8.Change
Exclude u8x32 from the generic reduction and add a 256-bit overload that:
SumsOf8to form four exact uint64 partial sums;The low byte preserves the existing modulo-256 uint8 reduction semantics.
Correctness
The existing parameterised reduction tests cover
SumOfLanes,ReduceSum, full and partial vectors, and unsigned wraparound.Performance
Intel Core i9-13905H, WSL2 Debian, static AVX2,
-O3 -march=haswell, pinned to logical CPU 4. Results are medians of 31 interleaved samples with 16,777,216 reductions per sample. Brackets show IQR.The GCC SIMD reduction sequence decreases from 14 vector operations to 7.
Clang shows a comparable reduction.
Regressions
The u8x16 control code generation is unchanged with both GCC and Clang.
The isolated micro-object text size also decreases. No tested target regressed.
Scope
Performance was measured only on AVX2 x86-64. No AVX-512, Arm, RISC-V or Power performance is claimed.