Machdep

Engineering across the hardware–kernel boundary.
PCB systems and FreeBSD kernel expertise, unified into reliable embedded platforms.

RISC-V Vector (RVV) extension support for FreeBSD

Bringing parallel computation to RISC-V Systems

RVV is a scalable SIMD (Single Instruction, Multiple Data) extension designed to accelerate data-intensive workload such as AI, machine-learning and DSP.

RVV exposes vector-length agnostic (VLA) execution and programming model, with implementation defined vector register file size, dynamic vector length selection, flexible register grouping, and rich instruction semantics, serving as the foundation for portable, high-throughput data-parallel acceleration.

RVV extends a base scalar RISC-V ISA with 32 vector registers and seven unprivileged control-status registers (CSRs) to control the engine. Each vector register could be up to 2^16 bits in length, depending on implementation.

Links

Ratified specification v1.0

Kernel work

The work is very similar to the Floating Point extension support that we developed for FreeBSD/RISC-V several years ago.

  • Detect the extension during boot time ("v" letter in the ISA string)
  • Implement RVV management code in the machine-dependent interfaces that handle CPU and thread state
  • Add memory-management code for vector state save area. The allocation for save area in thread's PCBs has to be dynamic as the length of registers varies across implementations
  • Save and restore RVV state on context-switch, fork(), scheduler entry
  • Enable the extension usage on the first instruction trap from userspace ("lazy" enable)
  • Support for ucontext_t

This project is under active development. Stay tuned for the review!