On Wed, 18 Nov 2026 23:33:22 GMT, Volodymyr Paprotski <[email protected]> wrote:
>> This provides AVX2 intrinsics for MLKEM operations. I also refactored AVX512 >> for code sharing. (A lot of this is similar to the MLDSA refactoring I did, >> and general shape follows that design) >> >> Performance: >> - KEMBench.MLKEM.(en|de)capsulate on AVX2 got 50-80% faster (depending on >> keysize and operation) >> - On AVX512, the intrinsics themselves were ~10-30% faster, but it doesnt >> really show on the top-level KEMBench.MLKEM.(en|de)capsulate (other parts of >> the benchmark take over, eg SHA3 which we optimized previously) >> >> --------- >> - [X] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Volodymyr Paprotski has updated the pull request incrementally with one > additional commit since the last revision: > > comments from Sandhya The benchmarks for AVX-512 on my AMD Ryzen 9 9900X Granite Ridge AM5 4.4GHz 12-Core came back nominal, +0.8% across all ML-KEM benchmarks, as expected. However, the AVX-2 results were impressive on the same machine with +60% throughput across all ML-KEM benchmarks! test/jdk/sun/security/provider/pqc/ML_KEM_Intrinsic_Test.java line 299: > 297: addPolyJava.invoke(sum2, a, b, c); > 298: > 299: if (!Arrays.equals(sum1, sum2)) { These sums will not be equal on AArch64 systems if intrinsics is used given that only `q` is added to the result, whereas in Java `2*q` is added. The sums will still be congruent modulo `q` if we want to check for that instead. Secondly, with the broader ranges used by this test suite intrinsics could also generate a `-q`. During subsequent Barrett reduction this would be reduced to `q`, which would deviate from mlKemAddPoly()'s comments where the resulting output is in the range of [0, q). This boundary case would not occur in production call paths but is possible and reproducible with the test suite's broader input ranges. I'm leaning towards aligning AArch64 intrinsic with current Java behavior. I'll file a bug for this shortly. ------------- PR Comment: https://git.openjdk.org/jdk/pull/33444#issuecomment-7330595069 PR Review Comment: https://git.openjdk.org/jdk/pull/33444#discussion_r4765203010
