-
Notifications
You must be signed in to change notification settings - Fork 15.9k
ggml: add RISC-V cpu-feats #17461
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
ggml: add RISC-V cpu-feats #17461
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #include "ggml-backend-impl.h" | ||
|
|
||
| #if defined(__riscv) && __riscv_xlen == 64 | ||
| #include <sys/auxv.h> | ||
|
|
||
| //https://github.com/torvalds/linux/blob/master/arch/riscv/include/uapi/asm/hwcap.h#L24 | ||
| #ifndef COMPAT_HWCAP_ISA_V | ||
| #define COMPAT_HWCAP_ISA_V (1 << ('V' - 'A')) | ||
| #endif | ||
|
|
||
| struct riscv64_features { | ||
| bool has_rvv = false; | ||
|
|
||
| riscv64_features() { | ||
| uint32_t hwcap = getauxval(AT_HWCAP); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not be using
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. new PR for fixing this issue : #17567 |
||
|
|
||
| has_rvv = !!(hwcap & COMPAT_HWCAP_ISA_V); | ||
| } | ||
| }; | ||
|
|
||
| static int ggml_backend_cpu_riscv64_score() { | ||
| int score = 1; | ||
| riscv64_features rf; | ||
|
|
||
| #ifdef GGML_USE_RVV | ||
| if (!rf.has_rvv) { return 0; } | ||
| score += 1 << 1; | ||
| #endif | ||
|
|
||
| return score; | ||
| } | ||
|
|
||
| GGML_BACKEND_DL_SCORE_IMPL(ggml_backend_cpu_riscv64_score) | ||
|
|
||
| #endif // __riscv && __riscv_xlen == 64 | ||
Uh oh!
There was an error while loading. Please reload this page.