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 src/hotspot/cpu/x86/stubGenerator_x86_64_kyber.cpp line 456: > 454: const XMMRegister input1[], const XMMRegister > input2[], > 455: int vector_len, MacroAssembler *_masm) { > 456: int regCnt = 4; nit: should be `const` here and subsequently, where appropriate. src/hotspot/cpu/x86/stubGenerator_x86_64_kyber.cpp line 480: > 478: } > 479: > 480: for (int i = 0; i < 4; i++) { nit: to be consistent, should probably use `regCnt` here and subsequently. src/hotspot/cpu/x86/stubGenerator_x86_64_kyber.cpp line 1236: > 1234: > 1235: XMMRegister _next = xmm2; > 1236: for (int i = 0; i < 8; i++) { nit: should be using `regCnt`. test/jdk/sun/security/provider/pqc/ML_KEM_Intrinsic_Test.java line 33: > 31: > 32: /* > 33: * @test Could you provide summary notation for this and other unit tests? test/jdk/sun/security/provider/pqc/ML_KEM_Intrinsic_Test.java line 147: > 145: rnd.setSeed(seed); > 146: //Note: it might be useful to increase this number during > development of new intrinsics > 147: final int repeat = 100_000; Prior failures with add poly 3 would take ~7k iterations on my M3 Pro, so this more than sufficient for warmup. test/jdk/sun/security/provider/pqc/ML_KEM_Intrinsic_Test.java line 175: > 173: public static void testNtt(short[] coeffs1, short[] coeffs2, > 174: MethodHandle ntt, MethodHandle nttJava, short[] zetas, Random > rnd, > 175: long seed, int i) throws Throwable { nit: arguments should be tabbed at least one farther here and for the other methods. test/jdk/sun/security/provider/pqc/ML_KEM_Intrinsic_Test.java line 229: > 227: + "] Result InverseNtt mismatch: " > 228: + formatOf(coeffs1) + "\n != " + > formatOf(coeffs2)); > 229: } You can cheat and canonicalize here using `barrettReduceJava`, for example, but it's range is [0, q] so you would have to account for that. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/33444#discussion_r4781308607 PR Review Comment: https://git.openjdk.org/jdk/pull/33444#discussion_r4781307417 PR Review Comment: https://git.openjdk.org/jdk/pull/33444#discussion_r4781302722 PR Review Comment: https://git.openjdk.org/jdk/pull/33444#discussion_r4781314913 PR Review Comment: https://git.openjdk.org/jdk/pull/33444#discussion_r4781296635 PR Review Comment: https://git.openjdk.org/jdk/pull/33444#discussion_r4781297677 PR Review Comment: https://git.openjdk.org/jdk/pull/33444#discussion_r4781298766
