On Thu, 5 Nov 2026 03:27:25 GMT, Larry <[email protected]> wrote: >> ### Description >> >> The AVX2 loop in generate_updateBytesAdler32() processed 16 bytes per >> iteration using two vpshufb and four vpaddd instructions, and reduced the >> accumulators with vpmulld followed by a vphaddd chain. >> >> VPHADDD is not a cheap single-µop operation: it decodes to three µops on >> Intel P-cores — two in-lane shuffle µops plus one add — and those shuffle >> µops contend for the shuffle pipes; the AVX forms are also microcoded on AMD >> Zen and Intel E-cores >> ([uops.info](https://uops.info/html-instr/VPHADDD_YMM_YMM_YMM.html)). In a >> hot reduction loop this makes the vphaddd chain throughput-limited by the >> shuffle pipes, hence relatively costly. >> >> This change rewrites the AVX2 loop as a dot product: >> - vpsadbw computes the byte sum for a; >> - vpmaddubsw/vpmaddwd compute the weighted byte sums for b, using two new >> weight tables; >> - the loop processes 64 bytes per iteration with two independent >> accumulators to shorten the dependency chain; >> - the AVX2 horizontal reduction uses 128-bit adds and shuffles instead of >> the vphaddd chain; >> - the 16/32-byte tails are handled with SIMD blocks. >> - the reduction mod BASE (65521) uses the gcc magic multiply (q = (x * >> 2147975281) >> 47) instead of two divl instructions. >> >> ### TEST >> >> - env: Intel Xeon 6980P (Granite Rapids), single socket, 128 cores / 256 >> threads (SMT2), 3 NUMA nodes, 755 GiB RAM, Ubuntu 22.04.4 LTS, glibc 2.35 >> - JMH: test/micro/org/openjdk/bench/java/util/TestAdler32.java; >> - jvmArgs: "-Xms4g -Xmx4g -XX:UseAVX=2" >> - results (ops/ms, mean): >> | size | baseline | patched | delta | >> | ---: | ---: | ---: | ---: | >> | 1 | 104097.5 | 167073.8 | +60.5% | >> | 2 | 101692.6 | 159382.4 | +56.7% | >> | 4 | 94645.6 | 145376.2 | +53.6% | >> | 8 | 84128.9 | 122917.0 | +46.1% | >> | 15 | 69304.3 | 91653.2 | +32.2% | >> | 16 | 66870.0 | 161618.9 | +141.7% | >> | 24 | 56286.5 | 111292.6 | +97.7% | >> | 31 | 50346.7 | 84490.9 | +67.8% | >> | 32 | 56756.3 | 71429.1 | +25.9% | >> | 64 | 52268 | 70605 | +35% | >> | 256 | 30809 | 59958 | +95% | >> | 1024 | 14318 | 33684 | +135% | >> | 4096 | 4475 | 10687 | +139% | >> | 8192 | 2268 | 5487 | +142% | >> | 65536 | 291.3 | 564.9 | +94% | >> >> Sizes below 16 bytes use the scalar loop in both versions; the only relevant >> difference is the final reduction modulo BASE, which baseline performs with >> two divl instructions and the patched version with the magic multiply (q = >> (x * 2147975281) >> 47). These rows therefore isolate the magic-mul... > > Larry has updated the pull request incrementally with one additional commit > since the last revision: > > 8394260: Refine Adler32 AVX2 finalization and tests
Here are the latest changes results on Intel Xeon 6980P (Granite Rapids) Size | Default flags | | | CopyAVX3Threshold=8192 | | -- | -- | -- | -- | -- | -- | -- | baseline | final | delta | baseline | final | delta 1 | 104,280.5 | 175,452.5 | +68.25% | 104,209.5 | 175,251.4 | +68.17% 2 | 101,690.3 | 164,911.1 | +62.17% | 101,624.7 | 164,721.5 | +62.09% 4 | 94,623.0 | 147,755.2 | +56.15% | 94,549.7 | 147,598.0 | +56.11% 8 | 84,119.6 | 123,932.1 | +47.33% | 84,050.9 | 123,733.2 | +47.21% 15 | 69,263.4 | 94,434.6 | +36.34% | 69,218.7 | 94,055.1 | +35.88% 16 | 66,870.7 | 169,928.4 | +154.11% | 66,806.3 | 169,402.1 | +153.57% 24 | 56,275.8 | 113,134.6 | +101.04% | 56,220.3 | 112,784.7 | +100.61% 31 | 50,339.0 | 85,508.8 | +69.87% | 50,236.5 | 85,301.7 | +69.80% 32 | 54,074.2 | 88,050.3 | +62.83% | 54,052.1 | 87,982.7 | +62.77% 64 | 50,027.4 | 88,300.5 | +76.50% | 49,992.7 | 88,189.9 | +76.41% 128 | 44,447.1 | 77,145.1 | +73.57% | 44,355.9 | 77,083.1 | +73.78% 256 | 33,052.9 | 32,659.8 | -1.19% | 30,068.2 | 71,596.0 | +138.11% 512 | 22,978.8 | 21,908.0 | -4.66% | 22,965.1 | 50,952.8 | +121.87% 1024 | 15,097.1 | 15,030.6 | -0.44% | 14,346.3 | 35,904.3 | +150.27% 2048 | 9,360.4 | 9,232.8 | -1.36% | 8,262.7 | 19,982.1 | +141.83% 4096 | 4,953.8 | 4,883.5 | -1.42% | 4,460.5 | 10,686.9 | +139.59% 5012 | 4,058.1 | 4,124.1 | +1.63% | 3,705.8 | 8,760.2 | +136.39% 5552 | 3,641.6 | 3,604.8 | -1.01% | 3,345.5 | 8,111.5 | +142.46% 8192 | 2,489.0 | 2,447.2 | -1.68% | 2,261.7 | 5,479.6 | +142.27% 16384 | 1,278.9 | 1,257.0 | -1.71% | 1,156.5 | 2,821.9 | +144.01% 32768 | 640.5 | 629.6 | -1.70% | 579.5 | 1,419.5 | +144.97% 65536 | 326.4 | 322.2 | -1.27% | 290.4 | 548.9 | +89.01% ------------- PR Comment: https://git.openjdk.org/jdk/pull/33338#issuecomment-6654838003
