RFR: 8266332: Adler32 intrinsic for x86 64-bit platforms [v2]

Sandhya Viswanathan sviswanathan at openjdk.java.net
Fri Apr 30 20:17:55 UTC 2021


On Fri, 30 Apr 2021 19:57:30 GMT, Xubo Zhang <github.com+58006833+xbzhang99 at openjdk.org> wrote:

>> Implement Adler32 intrinsic for x86 64-bit platform using vector instructions.
>> 
>> For the following benchmark:
>> http://cr.openjdk.java.net/~pli/rfr/8216259/TestAdler32.java
>> 
>> The optimization shows ~5x improvement.
>> 
>> Base:
>> Benchmark (count) Mode Cnt Score Error Units
>> TestAdler32Perf.testAdler32Update 64 avgt 25 0.084 ± 0.001 us/op
>> TestAdler32Perf.testAdler32Update 128 avgt 25 0.104 ± 0.001 us/op
>> TestAdler32Perf.testAdler32Update 256 avgt 25 0.146 ± 0.002 us/op
>> TestAdler32Perf.testAdler32Update 512 avgt 25 0.226 ± 0.002 us/op
>> TestAdler32Perf.testAdler32Update 1024 avgt 25 0.390 ± 0.005 us/op
>> TestAdler32Perf.testAdler32Update 2048 avgt 25 0.714 ± 0.007 us/op
>> TestAdler32Perf.testAdler32Update 4096 avgt 25 1.359 ± 0.014 us/op
>> TestAdler32Perf.testAdler32Update 8192 avgt 25 2.751 ± 0.023 us/op
>> TestAdler32Perf.testAdler32Update 16384 avgt 25 5.494 ± 0.077 us/op
>> TestAdler32Perf.testAdler32Update 32768 avgt 25 11.058 ± 0.160 us/op
>> TestAdler32Perf.testAdler32Update 65536 avgt 25 22.198 ± 0.319 us/op
>> 
>> 
>> With patch:
>> Benchmark (count) Mode Cnt Score Error Units
>> TestAdler32Perf.testAdler32Update 64 avgt 25 0.020 ± 0.001 us/op
>> TestAdler32Perf.testAdler32Update 128 avgt 25 0.025 ± 0.001 us/op
>> TestAdler32Perf.testAdler32Update 256 avgt 25 0.031 ± 0.001 us/op
>> TestAdler32Perf.testAdler32Update 512 avgt 25 0.048 ± 0.001 us/op
>> TestAdler32Perf.testAdler32Update 1024 avgt 25 0.078 ± 0.001 us/op
>> TestAdler32Perf.testAdler32Update 2048 avgt 25 0.139 ± 0.002 us/op
>> TestAdler32Perf.testAdler32Update 4096 avgt 25 0.262 ± 0.004 us/op
>> TestAdler32Perf.testAdler32Update 8192 avgt 25 0.524 ± 0.010 us/op
>> TestAdler32Perf.testAdler32Update 16384 avgt 25 1.017 ± 0.022 us/op
>> TestAdler32Perf.testAdler32Update 32768 avgt 25 2.058 ± 0.052 us/op
>> TestAdler32Perf.testAdler32Update 65536 avgt 25 3.994 ± 0.013 us/op
>
> Xubo Zhang has updated the pull request incrementally with one additional commit since the last revision:
> 
>   refactor adler32 algorithm to a new file x86/macroAssembler_x86_adler.cpp; added a scratch reg to vpmulld, and some other issues

src/hotspot/cpu/x86/macroAssembler_x86.cpp line 3248:

> 3246: 
> 3247: void MacroAssembler::vpmulld(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len, Register scratch_reg) {
> 3248:   // Used in sign-bit flipping with aligned address.

You could remove the spurious comment here.

src/hotspot/cpu/x86/macroAssembler_x86_adler.cpp line 32:

> 30: #include "macroAssembler_x86.hpp"
> 31: 
> 32: 

The updateBytesAdler32 should be under #ifdef _LP64, #endif.

src/hotspot/cpu/x86/stubGenerator_x86_64.cpp line 5824:

> 5822:       __ enter(); // required for proper stackwalking of RuntimeStub frame
> 5823: 
> 5824:       __ vmovdqu(yshuf0, ExternalAddress((address) StubRoutines::x86::_adler32_shuf0_table));

For vmovdqu also it is good to be explicit with scratch register.

src/hotspot/cpu/x86/vm_version_x86.cpp line 901:

> 899:   }
> 900: 
> 901:   if (supports_avx2() && UseAdler32Intrinsics) {

This should be under #ifdef _LP64. 
For 32-bit, UseAdler32Intrinsics should be set to false.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3806


More information about the hotspot-dev mailing list