Home / Learn / Processor Architecture / RISC-V Vector Extension (RVV) Explained

On this pageWhat vector processing isHow RVV differs from fixed-width SIMDThe key mechanismMain featuresWhy it suits a range of hardwareWhat it is used forStatusCosts and trade-offsRVV and dedicated acceleratorsWhere it fits in RISC-VCommon questionsRelated guidesRelated guides

RISC-V Vector Extension (RVV) Explained

The RISC-V Vector Extension, known as RVV, lets a single instruction operate on many data values at once. It is the part of RISC-V designed for workloads with large amounts of regular data: AI, scientific computing, signal processing and media. Its defining feature is that it is vector-length agnostic. The same compiled software runs on processors with short vectors or long ones and automatically uses whatever the hardware provides.

What vector processing is

An ordinary processor instruction works on one or two values. Adding two arrays of a thousand numbers means running the add instruction a thousand times.

A vector instruction works on a whole group of values together. If the hardware can hold sixteen numbers in a vector register, one instruction adds sixteen pairs. The same loop finishes in a fraction of the steps.

This style of computing is called data parallelism. Many important workloads consist largely of it.

How RVV differs from fixed-width SIMD

Other architectures have long had vector-style instructions, usually called SIMD, for single instruction, multiple data. Most were designed with a fixed register width, such as 128, 256 or 512 bits. Each time the width grew, a new set of instructions was introduced, and software had to be rewritten or recompiled to use it.

RVV takes a different route. The instructions do not state a width. The hardware designer chooses the vector register length to suit the processor, and software discovers and adapts to it while running.

Fixed-width SIMDRVV
Vector widthSet by the instruction setChosen by the hardware designer
New wider hardwareNeeds new instructions and recompiled codeRuns existing code unchanged
Loop remaindersNeed separate handlingHandled by the same loop
Instruction countGrows with each widthOne set for all widths

The key mechanism

At the start of a vector loop, the program runs a configuration instruction. It tells the processor how many elements remain to be processed and what type they are. The processor replies with the number it will handle in this pass, which is the smaller of what remains and what fits in its vector registers.

The loop then processes that many elements and repeats until none are left. On a processor with long vectors, each pass does more and the loop runs fewer times. On the final pass, the count simply comes out smaller, so no separate clean-up code is needed for leftover elements.

Main features

  • Thirty-two vector registers, whose length is fixed by the hardware.
  • Configurable element width, from 8-bit to 64-bit values, set at run time.
  • Register grouping. Several registers can be combined to act as one longer vector, or a fraction of a register can be used, which helps when mixing data of different sizes.
  • Masking. A mask selects which elements an operation applies to, so that code with conditions can still be vectorized.
  • A broad set of operations, including integer and floating-point arithmetic, comparisons, memory access with regular or irregular patterns, and reductions that combine a vector into a single value.
  • Fault-tolerant loads, which make it possible to vectorize loops whose length is not known in advance, such as scanning for the end of a string.

Why it suits a range of hardware

Because the vector length is a hardware choice, the same extension serves very different processors.

  • A small embedded core might implement short vectors to save area.
  • An application processor might use 128-bit or 256-bit vectors.
  • A processor aimed at scientific computing or AI might use much longer ones.

Software written once runs on all of them. A library optimized with RVV does not need a separate version for each.

What it is used for

  • AI and machine learning. Matrix and tensor arithmetic are naturally data-parallel.
  • Scientific and high-performance computing.
  • Signal processing, including audio, radio and radar.
  • Image and video processing.
  • Cryptography, with dedicated vector cryptography extensions.
  • Everyday software. Routines for copying memory and handling strings are much faster when vectorized.

Status

Version 1.0 of the vector extension was ratified by RISC-V International in 2021 and is frozen. It has since been made a mandatory part of the RVA23 application profile, which signals that general-purpose RISC-V software can begin to assume it is present.

Mainstream compilers can automatically vectorize code for RVV, and programmers can also use it directly through standardized functions. Processors implementing it are available from several suppliers, and optimized libraries continue to be developed.

Costs and trade-offs

  • Hardware area. Vector registers and the arithmetic units that serve them are large, particularly at long vector lengths.
  • Design complexity. Implementing the full extension efficiently in a high-performance processor is demanding.
  • State to save. An operating system has to save and restore vector registers when switching between programs, which takes time if they are large.
  • Software maturity. Compiler support and optimized libraries are improving but are younger than those of longer-established vector instruction sets.
  • Tuning. Vector-length-agnostic code is portable, though hand-tuning for a specific length can sometimes run faster.

RVV and dedicated accelerators

A vector extension makes a general-purpose processor much better at data-parallel work. It does not turn it into a GPU or a dedicated AI accelerator, which devote far more hardware to parallel arithmetic.

The two are complementary. RVV handles moderate workloads directly and the parts of a larger workload that do not go to an accelerator. Some AI chips also use RISC-V cores with vector support as the programmable element around specialized compute blocks.

Where it fits in RISC-V

RVV is one of RISC-V’s standard optional extensions, identified by the letter V. It builds on the base integer instructions and, for floating-point vectors, on the floating-point extensions.

Common questions

What does vector-length agnostic mean?

It means software does not assume a particular vector size. The program asks the processor how many elements it can handle and adapts, so the same code runs on hardware with different vector lengths.

Is RVV the same as SIMD?

It serves the same purpose, operating on multiple data values with one instruction. It differs in not fixing the vector width in the instruction set, which most earlier SIMD designs did.

Do all RISC-V processors have vector support?

No. It is an optional extension. Small embedded cores often leave it out. Application processors conforming to the RVA23 profile are required to include it.

Related guides

Related guides in other topics