Name and Version
version: 8683 (d0a6dfe)
built with Clang 20.9.0 for Linux riscv64
Operating systems
Linux
Which llama.cpp modules do you know to be affected?
llama-cli
Command line
Problem description & steps to reproduce
Summary
The llama.cpp codebase incorrectly uses __riscv_v_intrinsic for conditional compilation to separate RISC-V Vector (RVV) implementation from scalar code. According to the official RISC-V "V" Vector Extension Intrinsic specification, __riscv_v should be used instead.
The Issue
According to the RISC-V "V" Vector Extension Intrinsic Document, section on predefined macros:
__riscv_v_intrinsic: Version number macro for the intrinsic API
This macro should be defined even if the vector extension is not enabled.
__riscv_v: RVV extension detection macro
Only defined when the vector extension is actually enabled. This is the correct macro for RVV/scalar code separation
Current State in llama.cpp
The codebase has inconsistent usage:
- Correct usage (older code):
- Incorrect usage (newer code)
|
#if defined __riscv_v_intrinsic |
Impact
Using __riscv_v_intrinsic instead of __riscv_v for RVV separation can lead to runtime crashes, vector instructions executed on hardware without vector support.
First Bad Commit
No response
Relevant log output
Logs
Name and Version
version: 8683 (d0a6dfe)
built with Clang 20.9.0 for Linux riscv64
Operating systems
Linux
Which llama.cpp modules do you know to be affected?
llama-cli
Command line
Problem description & steps to reproduce
Summary
The llama.cpp codebase incorrectly uses
__riscv_v_intrinsicfor conditional compilation to separate RISC-V Vector (RVV) implementation from scalar code. According to the official RISC-V "V" Vector Extension Intrinsic specification,__riscv_vshould be used instead.The Issue
According to the RISC-V "V" Vector Extension Intrinsic Document, section on predefined macros:
__riscv_v_intrinsic: Version number macro for the intrinsic APIThis macro should be defined even if the vector extension is not enabled.
__riscv_v: RVV extension detection macroOnly defined when the vector extension is actually enabled. This is the correct macro for RVV/scalar code separation
Current State in llama.cpp
The codebase has inconsistent usage:
llama.cpp/ggml/src/ggml-cpu/arch/riscv/quants.c
Line 39 in 81df3f7
llama.cpp/ggml/src/ggml-cpu/arch/riscv/quants.c
Line 2061 in 81df3f7
Impact
Using
__riscv_v_intrinsicinstead of__riscv_vfor RVV separation can lead to runtime crashes, vector instructions executed on hardware without vector support.First Bad Commit
No response
Relevant log output
Logs