Repository navigation
igzip/riscv64: Optimize deflate performance with vectorized assembly implementation of compare258 - #431
igzip/riscv64: Optimize deflate performance with vectorized assembly implementation of compare258#431zl523856 wants to merge 1 commit into
Conversation
ae87cb7 to
ba4272d
Compare
|
I have pulled the zte-riscv:optimize-deflate2 branch locally and run ./tools/test_checks.sh on a Spacemit(R) X100. The test passed successfully. Could the maintainer please trigger the CI again? Thanks! @pablodelara |
|
Tested on a BPI-F3 (K1) and the CI failure reproduces reliably. This looks like a misaligned access issue. |
Thank you for the guidance. I've successfully reproduced the error and am currently working on a fix. |
ba4272d to
64a118c
Compare
|
I think we'd better fix the root cause rather than work around it. The problem is the vlse64 in igzip/riscv64/igzip_deflate_hash_rvv.S; it may be solvable by switching to vle8 or similar. More importantly, these hash computations often end up slower than the scalar code. Did you benchmark igzip/riscv64/igzip_deflate_hash_rvv.S on its own? If it's slower, maybe it's better to |
I haven't tested it individually yet. I'll run some additional verification and fix the unaligned access issue in igzip_deflate_hash_rvv.S on the K1 environment. |
64a118c to
665d81f
Compare
|
The igzip_deflate_hash_riscv64.S has been updated to a scalar implementation. Could the reviewer please re-trigger the CI and review? Thank you! @pablodelara @sunyuechi |
665d81f to
9a575bf
Compare
There was a problem hiding this comment.
All the _rvv.c files need to be guarded with #if HAVE_RVV, otherwise the
build will fail when V is not supported.
There was a problem hiding this comment.
Several of the newly added files are missing a copyright header, would you
like to add those as well?
| #include "unaligned.h" | ||
|
|
||
| extern uint32_t | ||
| compare258_rvv(const uint8_t *str1, const uint8_t *str2, uint32_t max_length); |
There was a problem hiding this comment.
The extern declarations in these rvv files could be dropped and add
into huffman_riscv64.h, which would be easier to maintain.
| lbu t6, 2(a3); slli t6, t6, 16; or t2, t2, t6 | ||
| lbu t6, 3(a3); slli t6, t6, 24; or t2, t2, t6 | ||
|
|
||
| .loop_start: |
There was a problem hiding this comment.
The labels in this file could use the .L prefix, like the other .S files do.
afbb956 to
c20fd90
Compare
|
The review comments have been addressed. Could the reviewer please re-trigger the CI and review? Thank you! @pablodelara @sunyuechi |
|
@tkanteck can review this from now on, but @sunyuechi, could you review again? |
|
Only the four _rvv.c files under igzip/riscv64 still lack a license header |
The newly added rvv.c is derived from existing functions within the library (which currently lack copyright headers). Therefore, I haven't added a copyright notice to this new file either. |
|
LGTM |
|
Hi @tkanteck, just a gentle ping — this PR has been open for a while. Would you be able to take a look when you get a chance? Happy to address any changes or add more details if needed. Thanks! |
Thanks for the ping and apologies for the delay. Let me have a look into it. |
tkanteck
left a comment
There was a problem hiding this comment.
There are a few files that have no copyright/license header. Could you address it please?
| @@ -0,0 +1,62 @@ | |||
| #if HAVE_RVV | |||
There was a problem hiding this comment.
no copyright / license header here
The four new rvv.c files are derived from existing functions in igzip/igzip_base.c, igzip/igzip_icf_base.c, and igzip/igzip_icf_body.c. As the original files contain no copyright notice, I omitted a copyright header. Could you please advise whether this is acceptable, or whether I should add "Copyright (c) 2011-2016 Intel Corporation All rights reserved"? |
If existing files are re-used then original headers should be preserved. If additional changes are introduced to the files then extra copyright line can be added, next to the Intel one. |
…implementation of compare258 The hot functions in the three parts—icf_body, deflate_body, and update_histogram—are centered around compare258. By implementing a reusable vectorized assembly version of compare258 (i.e., compare258_rvv) using RISC-V vector extensions, while keeping the original C control flow in the outer layers, we can improve deflate performance. This optimization has been validated with igzip_perf on the Spacemit(R) X100 platform: igzip_perf -f 0 -y 0 -b 1024 silesia.tar (6% performance improvement) new:isal_stateful_deflate-> runtime = 4342565 usecs, bandwidth 423 MB in 4.3426 sec = 97.62 MB/s old:isal_stateful_deflate-> runtime = 4616307 usecs, bandwidth 423 MB in 4.6163 sec = 91.83 MB/s igzip_perf -f 0 -y 1 -b 1024 silesia.tar (9% performance improvement) new:isal_stateful_deflate-> runtime = 3975344 usecs, bandwidth 423 MB in 3.9753 sec = 106.64 MB/s old:isal_stateful_deflate-> runtime = 4322878 usecs, bandwidth 423 MB in 4.3229 sec = 98.06 MB/s igzip_perf -f 1 -y 0 -b 1024 silesia.tar (10% performance improvement) new:isal_stateful_deflate-> runtime = 4233799 usecs, bandwidth 423 MB in 4.2338 sec = 100.13 MB/s old:isal_stateful_deflate-> runtime = 4656209 usecs, bandwidth 423 MB in 4.6562 sec = 91.04 MB/s igzip_perf -f 1 -y 1 -b 1024 silesia.tar (6% performance improvement) new:isal_stateful_deflate-> runtime = 5723116 usecs, bandwidth 211 MB in 5.7231 sec = 37.04 MB/s old:isal_stateful_deflate-> runtime = 6045445 usecs, bandwidth 211 MB in 6.0454 sec = 35.06 MB/s All tests successful: PASS: igzip/igzip_rand_test Signed-off-by: zhoulu <zhou.lu1@zte.com.cn>
c20fd90 to
7d4f906
Compare
I've made the requested changes. Could you please review again when you get a chance? Thank you! |
|
Thanks. It's merged now e1838d4 |
The hot functions in the three parts—icf_body, deflate_body, and update_histogram—are centered around compare258. By implementing a reusable vectorized assembly version of compare258 (i.e., compare258_rvv) using RISC-V vector extensions, while keeping the original C control flow in the outer layers, we can improve deflate performance.
This optimization has been validated with igzip_perf on the Spacemit(R) X100 platform:
igzip_perf -f 0 -y 0 -b 1024 silesia.tar (6% performance improvement)
new:isal_stateful_deflate-> runtime = 4342565 usecs, bandwidth 423 MB in 4.3426 sec = 97.62 MB/s
old:isal_stateful_deflate-> runtime = 4616307 usecs, bandwidth 423 MB in 4.6163 sec = 91.83 MB/s
igzip_perf -f 0 -y 1 -b 1024 silesia.tar (9% performance improvement)
new:isal_stateful_deflate-> runtime = 3975344 usecs, bandwidth 423 MB in 3.9753 sec = 106.64 MB/s
old:isal_stateful_deflate-> runtime = 4322878 usecs, bandwidth 423 MB in 4.3229 sec = 98.06 MB/s
igzip_perf -f 1 -y 0 -b 1024 silesia.tar (10% performance improvement)
new:isal_stateful_deflate-> runtime = 4233799 usecs, bandwidth 423 MB in 4.2338 sec = 100.13 MB/s
old:isal_stateful_deflate-> runtime = 4656209 usecs, bandwidth 423 MB in 4.6562 sec = 91.04 MB/s
igzip_perf -f 1 -y 1 -b 1024 silesia.tar (6% performance improvement)
new:isal_stateful_deflate-> runtime = 5723116 usecs, bandwidth 211 MB in 5.7231 sec = 37.04 MB/s
old:isal_stateful_deflate-> runtime = 6045445 usecs, bandwidth 211 MB in 6.0454 sec = 35.06 MB/s
All tests successful:
PASS: igzip/igzip_rand_test