erasure_code: add prefetch and vsetvli optimization#351
erasure_code: add prefetch and vsetvli optimization#351lvshuo2016 wants to merge 2 commits intointel:masterfrom
Conversation
configure.ac
Outdated
| if test "x$rvv" = "xyes"; then | ||
| CFLAGS+=" -march=rv64gcv" | ||
| CCASFLAGS+=" -march=rv64gcv" | ||
| CFLAGS+=" -march=rv64gcv_zicbop" |
There was a problem hiding this comment.
It looks like this is going to be in conflict with CFLAGS+=" -march=rv64gcv_zbc_zvbc_zvbb" in https://github.com/intel/isa-l/pull/350/files.
There was a problem hiding this comment.
They shouldn't conflict because they are on different branches.
There was a problem hiding this comment.
I know, but what I meant is that the flags are different. Which one will stay? Or will it be a combination of both? I don't quite understand RISC-V flags
There was a problem hiding this comment.
I do a simple compiler test, -march=rv64gcv_zicbop_zbc_zvbc_zvbb,the flags combine both. It compiler successfully.
There was a problem hiding this comment.
It should include detection of zicbop at both compile time and runtime, rather than adding it directly.
|
Can you sign off the commit? Thanks! |
3b900a8 to
54339a6
Compare
Updated. Thanks. |
|
Similarly, https://github.com/ChristopherHX/github-act-runner/ encountered a panic and is currently under investigation... |
54339a6 to
41fa113
Compare
|
do you have comments? If have i can fix it. |
configure.ac
Outdated
| if test "x$rvv" = "xyes"; then | ||
| CFLAGS+=" -march=rv64gcv" | ||
| CCASFLAGS+=" -march=rv64gcv" | ||
| CFLAGS+=" -march=rv64gcv_zicbop" |
There was a problem hiding this comment.
It should include detection of zicbop at both compile time and runtime, rather than adding it directly.
|
|
||
| vsetvli a5, x0, e8, m1 /* Set vector length to maximum */ | ||
|
|
||
| vsetvli a5, x0, e8, m1,ta,ma /* Set vector length to maximum */ |
There was a problem hiding this comment.
Please split the commits — the addition of ta and ma for vsetvli should be in a separate commit.
There was a problem hiding this comment.
Why do ta and ma for vsetvli need to be committed separately?
There was a problem hiding this comment.
The prefetch part and filling in the default ta and ma for vset are two unrelated matters, and they should generally not be combined in a single commit, as doing so makes the commit appear confusing.
There was a problem hiding this comment.
Vsetvli is just a one-line modification, and the function is very clear. Is it necessary to make a separate commit?
There was a problem hiding this comment.
The purpose of splitting is to make things simpler — as long as the functionalities are separate, this applies whether it’s a single line or a single word.
Such split commits are actually a necessary requirement in most open-source projects. However, for isa-l specifically, it might be better to let pablodelara decide. I don’t want to say it must be done in a certain way.
There was a problem hiding this comment.
I agree with @sunyuechi, even if it is one line. And especially if it is only one line, it should be easy to split into two commits.
41fa113 to
64e23f0
Compare
64e23f0 to
339b646
Compare
configure.ac
Outdated
| ".insn i 0x0F, 0, x0, x0, 0x010" ::: "memory" | ||
| ); | ||
| ])], | ||
| [AC_DEFINE([HAVE_ZICBOP], [1], [Enable Zicbop instructions]) |
There was a problem hiding this comment.
What are the differences in code path if this instruction is available or not?
There was a problem hiding this comment.
It should add macro HAVE_ZICBOP judgment conditions in the code.
Specifically, which hardware is it? |
|
The commits need to be reorganized; roughly three commits are needed: For example, this change and other unrelated logic changes should be moved out of the prefetch commit: The HAVE_ZICBOP macro should be merged into the prefetch commit. |
87ab99c to
be89c37
Compare
Updated. |
|
Could this PR be merged? |
configure.ac
Outdated
| [AC_DEFINE([HAVE_ZICBOP], [0], [Disable Zicbop instructions]) | ||
| AM_CONDITIONAL([HAVE_ZICBOP], [false]) zicbop=no] | ||
| ) | ||
| AC_MSG_RESULT([$zicbop]) |
There was a problem hiding this comment.
This should belong to the third commit, but it's currently in the first commit.
There was a problem hiding this comment.
It is currently in third commit. not in first commit.
There was a problem hiding this comment.
It is currently in third commit. not in first commit.
+ AC_MSG_RESULT([$zicbop])
is in erasure_code: add optimization implementation, but I think it should be in erasure_code: add prefetch optimization.
There was a problem hiding this comment.
It is currently in erasure_code: add prefetch optimization.
commit eac4d0f (HEAD -> riscv-optimize, origin/riscv-optimize)
Author: lvshuo lv.shuo@sanechips.com.cn
Date: Thu Aug 28 16:48:04 2025 +0800
erasure_code: add prefetch optimaztion
Signed-off-by: Shuo Lv <lv.shuo@sanechips.com.cn>
diff --git a/configure.ac b/configure.ac
index 1a1476a..e89d660 100644
--- a/configure.ac
+++ b/configure.ac
@@ -38,6 +38,7 @@ AM_CONDITIONAL([CPU_PPC64LE], [test "$CPU" = "ppc64le"])
AM_CONDITIONAL([CPU_RISCV64], [test "$CPU" = "riscv64"])
AM_CONDITIONAL([CPU_UNDEFINED], [test "x$CPU" = "x"])
AM_CONDITIONAL([HAVE_RVV], [false])
+AM_CONDITIONAL([HAVE_ZICBOP], [false])
Check for programs
AC_PROG_CC_STDC
@@ -70,10 +71,28 @@ case "${CPU}" in
[AC_DEFINE([HAVE_RVV], [0], [Disable RVV instructions])
AM_CONDITIONAL([HAVE_RVV], [false]) rvv=no]
)
-
AC_MSG_CHECKING([Zicbop support]) -
AC_COMPILE_IFELSE( -
[AC_LANG_PROGRAM([], [ -
__asm__ volatile( -
".option arch, +zicbop\n" -
".insn i 0x0F, 0, x0, x0, 0x010" ::: "memory" -
); -
])], -
[AC_DEFINE([HAVE_ZICBOP], [1], [Enable Zicbop instructions]) -
AM_CONDITIONAL([HAVE_ZICBOP], [true]) zicbop=yes], -
[AC_DEFINE([HAVE_ZICBOP], [0], [Disable Zicbop instructions]) -
AM_CONDITIONAL([HAVE_ZICBOP], [false]) zicbop=no] -
) AC_MSG_RESULT([$zicbop])
There was a problem hiding this comment.
It looks that the picture could not display here.
There was a problem hiding this comment.
I used
gh pr checkout 351
git show bbbbf6c
and saw that it’s still in this commit.
There was a problem hiding this comment.
It seems there is a problem, my local rebase has a conflict
|
|
||
| vsetvli a5, x0, e8, m1 /* Set vector length to maximum */ | ||
|
|
||
| vsetvli a5, x0, e8, m1,ta,ma /* Set vector length to maximum */ |
There was a problem hiding this comment.
The newly added ta and ma in vset should use the same spacing as in the first half of the line.
| slli t_offset, x_vec, 5 | ||
| slli x_vec, x_vec, 3 | ||
|
|
||
| slli t_offset, x_vec, 2 |
There was a problem hiding this comment.
The commit message should include the reason for changing the implementation.
6a8fa6c to
eac4d0f
Compare
|
All is update. |
Please try to explain the situation and/or describe the test environment in the commit message. |
2f626d5 to
99d5360
Compare
|
All is updated. |
|
Could this PR be merged? |
|
@sunyuechi what do you think of the latest code? |
|
@lvshuo2016 one more comment. Could you review your commit messages? There are typos and also the "Signed-off-by" line should be at the end of message always. |
When you say wait until hwprobe is merged, do you mean https://lkml.org/lkml/2025/9/11/849? |
|
@pablodelara Yes, I’m okay with either merging quickly or waiting until hwprobe is merged — it mainly depends on how the author decides to adjust the patch. |
Up to you both. I'm OK merging it if you are OK with it, with the changes required. |
c4bbe99 to
2e5b5e1
Compare
I remove the prefetch patch,the current code could be merge. I will create a new pull request to track prefetch(include runtime check). |
|
The title contains an extra space. The commit message is redundant with the title; you can keep only the title.
In |
|
|
||
| /* calc for next */ | ||
| addi x_vec_i, x_vec_i, 8 /* move x_vec_i to next */ | ||
| add a6,x_src,x_vec_i |
There was a problem hiding this comment.
As with the other parts, please add a space after the comma (the other files also have this instruction followed by a space).
There was a problem hiding this comment.
Please also check other parts, for example in this file the line add x_ptr,x_ptr,x_pos still has this formatting issue.
There was a problem hiding this comment.
Please also check other parts, for example in this file the line add x_ptr,x_ptr,x_pos still has this formatting issue.
Here the code which you see is old code. I have updated all related formatting issue.
There was a problem hiding this comment.
I used “gh pr checkout 351” to download the latest code, but line 102 is still like this.
There was a problem hiding this comment.
I used “gh pr checkout 351” to download the latest code, but line 102 is still like this.
It is updated in commit fd94836.
There was a problem hiding this comment.
m your prev
Updated.
There was a problem hiding this comment.
You can use this command grep -rPn '\,\S' erasure_code/riscv64 to find such formatting issues. It looks like there are still more than 30 places missing a space.
./gf_7vect_dot_prod_rvv.S:163: add x_ptr,x_ptr,x_pos
./gf_7vect_dot_prod_rvv.S:262: add x_dest1,x_dest1, t0
./gf_7vect_dot_prod_rvv.S:263: add x_dest2,x_dest2, t0
./gf_7vect_dot_prod_rvv.S:264: add x_dest3,x_dest3, t0
./gf_7vect_dot_prod_rvv.S:265: add x_dest4,x_dest4, t0
./gf_7vect_dot_prod_rvv.S:266: add x_dest5,x_dest5, t0
./gf_7vect_dot_prod_rvv.S:267: add x_dest6,x_dest6, t0
./gf_7vect_dot_prod_rvv.S:268: add x_dest7,x_dest7, t0
./gf_4vect_dot_prod_rvv.S:130: add x_ptr,x_ptr,x_pos
...
210efde to
3d159c3
Compare
Updated. In |
|
Is gf5 the same case? From a code quality perspective, it might be better to modify gf5 and gf7 to use a consistent implementation, so that the test code logic is aligned with the production code. Otherwise, if they are not modified, at least the commit message should explain why they remain inconsistent. |
reduce one slli instructions and remove the dependence between vle8.v and ld instructions gf5 and gf7 are not modified, +5 and +7 are not used in actual scenarios. Signed-off-by: Shuo Lv <lv.shuo@sanechips.com.cn>
3d159c3 to
9f09b4a
Compare
the commit message is added. |
|
It looks like an environmental issue for the last build failure. |
|
All is updated. Could it be merged now? |
| vle8.v v_gft7_hi, (x_tbl7) | ||
| addi x_tbl7, x_tbl7, 16 | ||
|
|
||
|
|
There was a problem hiding this comment.
You can also remove other consecutive blank lines, for example:
gf_3vect_dot_prod_rvv.S:60
gf_5vect_dot_prod_rvv.S:206
gf_6vect_dot_prod_rvv.S:153
gf_7vect_dot_prod_rvv.S:97
gf_7vect_dot_prod_rvv.S:244
gf_vect_dot_prod_rvv.S:30
4d428aa to
33da77d
Compare
|
ALL is updated. |
33da77d to
757020a
Compare
|
LGTM |
| @@ -92,16 +93,13 @@ gf_2vect_dot_prod_rvv: | |||
|
|
|||
| /* gf_tbl base = (x_tbl + dest_idx * x_vec * 32) */ | |||
There was a problem hiding this comment.
Should this 32 be 4 now, since you are shifting left 2 instead of 5 bits?
There was a problem hiding this comment.
Totally it need shift left 5, slli x_vec, x_vec, 3 + slli t6, x_vec, 2. You are right, here 32 in comments should be 4, we could add extra comments.
Signed-off-by: Shuo Lv <lv.shuo@sanechips.com.cn>
757020a to
918e305
Compare
|
Could it be merged now? |
We will merge this PR shortly, thanks. |
|
This is merged now, thanks. |
Add prefetch and vsetvli support, on some RV real hardware platforms, its performance can be improved by 100%.