RFR: 8314125: RISC-V: implement Base64 intrinsic - encoding
Hamlin Li
mli at openjdk.org
Mon Jul 1 14:17:44 UTC 2024
Hi,
Can you help to review the patch?
I'm also working a base64 decode instrinsic, but there is some performance regression in some cases, and decode and encode are totally independent with each other, so I will send out review of decode in another pr when I fix the performance regression in it.
Thanks.
## Test
benchmarks run on CanVM-K230
I've tried several implementations, respectively with vector group
* m2+m1
* m2
* m1
The best one is combination of m2+m1, it have best performance in all source size.
###this implementation (m2+m1)
<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 | (maxNumBytes) | Mode | Cnt | Score -intrinsic | Score + instrinsic, m1+m2 | Error | Units | -intrinsic/+intrinsic
-- | -- | -- | -- | -- | -- | -- | -- | --
Base64Encode.testBase64Encode | 1 | avgt | 10 | 86.784 | 86.996 | 0.459 | ns/op | 0.9975631063
Base64Encode.testBase64Encode | 2 | avgt | 10 | 93.603 | 94.026 | 1.081 | ns/op | 0.9955012443
Base64Encode.testBase64Encode | 3 | avgt | 10 | 121.927 | 123.227 | 0.342 | ns/op | 0.989450364
Base64Encode.testBase64Encode | 6 | avgt | 10 | 139.554 | 137.4 | 1.221 | ns/op | 1.015676856
Base64Encode.testBase64Encode | 7 | avgt | 10 | 160.698 | 162.25 | 2.36 | ns/op | 0.9904345146
Base64Encode.testBase64Encode | 9 | avgt | 10 | 161.085 | 153.772 | 1.505 | ns/op | 1.047557423
Base64Encode.testBase64Encode | 10 | avgt | 10 | 187.963 | 174.763 | 1.204 | ns/op | 1.075530862
Base64Encode.testBase64Encode | 48 | avgt | 10 | 405.212 | 199.4 | 6.374 | ns/op | 2.032156469
Base64Encode.testBase64Encode | 512 | avgt | 10 | 3652.555 | 1111.009 | 3.462 | ns/op | 3.287601631
Base64Encode.testBase64Encode | 1000 | avgt | 10 | 7217.187 | 2011.943 | 227.784 | ns/op | 3.587172698
Base64Encode.testBase64Encode | 20000 | avgt | 10 | 135165.706 | 33864.592 | 57.557 | ns/op | 3.991357876
</google-sheets-html-origin>
###vector with only m2
<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 | (maxNumBytes) | Mode | Cnt | Score -intrinsics | Score +intrinsic, m2 | Error | Units | -intrinsic/+intrinsic
-- | -- | -- | -- | -- | -- | -- | -- | --
Base64Encode.testBase64Encode | 1 | avgt | 10 | 86.797 | 86.872 | 0.374 | ns/op | 0.9991366608
Base64Encode.testBase64Encode | 2 | avgt | 10 | 93.971 | 94.203 | 1.918 | ns/op | 0.9975372334
Base64Encode.testBase64Encode | 3 | avgt | 10 | 122.074 | 123.978 | 1.009 | ns/op | 0.9846424366
Base64Encode.testBase64Encode | 6 | avgt | 10 | 138.999 | 138.344 | 2.175 | ns/op | 1.004734575
Base64Encode.testBase64Encode | 7 | avgt | 10 | 160.857 | 157.494 | 1.036 | ns/op | 1.021353194
Base64Encode.testBase64Encode | 9 | avgt | 10 | 161.511 | 154.998 | 1.727 | ns/op | 1.042019897
Base64Encode.testBase64Encode | 10 | avgt | 10 | 186.228 | 175.38 | 0.62 | ns/op | 1.061854259
Base64Encode.testBase64Encode | 48 | avgt | 10 | 408.461 | 349.558 | 15.377 | ns/op | 1.168507086
Base64Encode.testBase64Encode | 512 | avgt | 10 | 3679.283 | 1103.717 | 3.911 | ns/op | 3.333538398
Base64Encode.testBase64Encode | 1000 | avgt | 10 | 7206.265 | 1988.927 | 224.732 | ns/op | 3.623192304
Base64Encode.testBase64Encode | 20000 | avgt | 10 | 135695.875 | 33930.292 | 97.85 | ns/op | 3.99925456
</google-sheets-html-origin>
###vector with only m1
<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 | (maxNumBytes) | Mode | Cnt | Score -intrinsic | Score +intrinsic, m1 | Error | Units | -intrinsic/+intrinsic
-- | -- | -- | -- | -- | -- | -- | -- | --
Base64Encode.testBase64Encode | 1 | avgt | 10 | 86.837 | 87.137 | 0.527 | ns/op | 0.9965571456
Base64Encode.testBase64Encode | 2 | avgt | 10 | 94.723 | 94.125 | 5.122 | ns/op | 1.006353254
Base64Encode.testBase64Encode | 3 | avgt | 10 | 121.51 | 123.082 | 0.854 | ns/op | 0.9872280268
Base64Encode.testBase64Encode | 6 | avgt | 10 | 139.045 | 137.175 | 0.201 | ns/op | 1.013632222
Base64Encode.testBase64Encode | 7 | avgt | 10 | 161.216 | 159.387 | 2.385 | ns/op | 1.011475214
Base64Encode.testBase64Encode | 9 | avgt | 10 | 160.541 | 154.19 | 1.665 | ns/op | 1.041189442
Base64Encode.testBase64Encode | 10 | avgt | 10 | 184.874 | 174.766 | 5.569 | ns/op | 1.057837337
Base64Encode.testBase64Encode | 48 | avgt | 10 | 405.124 | 199.333 | 1.584 | ns/op | 2.032398047
Base64Encode.testBase64Encode | 512 | avgt | 10 | 3659.335 | 1185.626 | 24.686 | ns/op | 3.086415952
Base64Encode.testBase64Encode | 1000 | avgt | 10 | 7239.269 | 2164.709 | 1022.367 | ns/op | 3.344222711
Base64Encode.testBase64Encode | 20000 | avgt | 10 | 135048.828 | 38248.645 | 319.978 | ns/op | 3.530813392
</google-sheets-html-origin>
-------------
Commit messages:
- clean code
- Initial commit
Changes: https://git.openjdk.org/jdk/pull/19973/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19973&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8314125
Stats: 245 lines in 3 files changed: 245 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/19973.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/19973/head:pull/19973
PR: https://git.openjdk.org/jdk/pull/19973
More information about the hotspot-dev
mailing list