RFR: 8339738: RISC-V: Vectorize crc32 intrinsic

Hamlin Li mli at openjdk.org
Mon Sep 9 10:33:15 UTC 2024


Hi,
Can you help to review this patch?
Thanks.

This improvement is based on java.base/share/native/libzip/zlib/zcrc32.c, I made some modification to N (to 16) related code, then re-generate the tables needed, finally vectorize the code (original implementation in zcrc32.c is just scalar code).

## Test
test/hotspot/jtreg/compiler/intrinsics/zip/TestCRC32.java, 
test/jdk/java/util/zip/TestCRC32.java

## Performance

tested on bananapi

### with patch
data
<google-sheets-html-origin style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
Benchmark -with patch | (count) | Mode | Cnt | Score | Error | Units
-- | -- | -- | -- | -- | -- | --
TestCRC32.testCRC32Update | 64 | avgt | 10 | 220.884 | 0.03 | ns/op
TestCRC32.testCRC32Update | 128 | avgt | 10 | 401.122 | 0.309 | ns/op
TestCRC32.testCRC32Update | 256 | avgt | 10 | 680.168 | 0.032 | ns/op
TestCRC32.testCRC32Update | 512 | avgt | 10 | 1062.426 | 0.401 | ns/op
TestCRC32.testCRC32Update | 2048 | avgt | 10 | 3308.361 | 0.176 | ns/op
TestCRC32.testCRC32Update | 16384 | avgt | 10 | 24403.231 | 20.248 | ns/op
TestCRC32.testCRC32Update | 65536 | avgt | 10 | 103463.735 | 4.245 | ns/op

</google-sheets-html-origin>

### without patch
data
<google-sheets-html-origin style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">
Benchmark -without patch | (count) | Mode | Cnt | Score | Error | Units
-- | -- | -- | -- | -- | -- | --
TestCRC32.testCRC32Update | 64 | avgt | 10 | 220.942 | 0.224 | ns/op
TestCRC32.testCRC32Update | 128 | avgt | 10 | 364.159 | 0.019 | ns/op
TestCRC32.testCRC32Update | 256 | avgt | 10 | 686.106 | 0.1 | ns/op
TestCRC32.testCRC32Update | 512 | avgt | 10 | 1328.962 | 0.073 | ns/op
TestCRC32.testCRC32Update | 2048 | avgt | 10 | 5191.116 | 0.189 | ns/op
TestCRC32.testCRC32Update | 16384 | avgt | 10 | 41286.858 | 4.53 | ns/op
TestCRC32.testCRC32Update | 65536 | avgt | 10 | 172340.099 | 11.004 | ns/op

</google-sheets-html-origin>

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

Commit messages:
 - fix space
 - Initial commit

Changes: https://git.openjdk.org/jdk/pull/20910/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20910&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8339738
  Stats: 348 lines in 3 files changed: 332 ins; 10 del; 6 mod
  Patch: https://git.openjdk.org/jdk/pull/20910.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/20910/head:pull/20910

PR: https://git.openjdk.org/jdk/pull/20910


More information about the hotspot-dev mailing list