-
Notifications
You must be signed in to change notification settings - Fork 332
erasure_code: add prefetch and vsetvli optimization #351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They shouldn't conflict because they are on different branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should include detection of zicbop at both compile time and runtime, rather than adding it directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do ta and ma for vsetvli need to be committed separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are the differences in code path if this instruction is available or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should add macro HAVE_ZICBOP judgment conditions in the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should belong to the third commit, but it's currently in the first commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is currently in third commit. not in first commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is currently in erasure_code: add prefetch optimization.
commit eac4d0f (HEAD -> riscv-optimize, origin/riscv-optimize)
Author: lvshuo [email protected]
Date: Thu Aug 28 16:48:04 2025 +0800
erasure_code: add prefetch optimaztion
Signed-off-by: Shuo Lv <[email protected]>
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks that the picture could not display here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems there is a problem, my local rebase has a conflict
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update.
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newly added ta and ma in vset should use the same spacing as in the first half of the line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit message should include the reason for changing the implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated.
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. |
|
||
vsetvli t0, x0, e8, m1 /* Set vector length to maximum */ | ||
|
||
# vsetvli t0, x0, e8, m1 /* Set vector length to maximum */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
Please add the relevant description. Also, can we change the vsetvli commit subject to indicate adding default values instead? Since there’s no performance optimization involved. |
In "erasure_code: add prefetch optimization", a compile-time check was added, but a runtime check still needs to be implemented. |
reduce one slli instructions and remove the dependence between vle8.v and ld instructions Signed-off-by: Shuo Lv <[email protected]>
e96d047
to
aee9736
Compare
Updated. |
add vsetvli parameter to default values Signed-off-by: Shuo Lv <[email protected]>
aee9736
to
c4bbe99
Compare
Updated. |
runtime check? Do you means getauxval check? |
getauxval or hwprobe, currently ec_riscv64_dispatcher.c only checks for v. |
We can use code like the following to check. int supports_riscv_prefetch() { Then call this C function in assembly. Of course, the check code can also be implemented in assembly, but there are too many instructions. |
According to For the |
hwprobe don't support runtime check for Zicacheop(prefetch) and there is no related macro in kernel head file which confirmed with 350 author yinlenree. |
Yes, at the moment there is only a patch series to add hwprobe support for Zicbop If there is no clear benefit shown on publicly available hardware yet, it might be more Or first add hwprobe support based on the related patch? |
It may not compile successfully in current kernel if add hwprobe support based on the related patch. So I will remove the prefetch patch first. |
There are two ways. One is to add prefetch, which has no side effects and has added compile-time detection. The lack of dynamic detection here is not a very important issue. Later, when the kernel supports it, a patch can be also added. The other is to remove the prefetch patch submission. Which one do you think is suitable? |
@pablodelara hi, Pablo, what do you think? should we merge it or remove the prefetch patch ? |
I think it’s reasonable to either wait until hwprobe is merged before adding prefetch, or to first add prefetch behind a compile-time option (default off) as an experimental feature. If it’s to be merged now, there are some adjustments needed:
|
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). |
Add prefetch and vsetvli support, on some RV real hardware platforms, its performance can be improved by 100%.