Homogeneous Fusion on RISC-V for Edge AI: Practical Notes on RVA23
A practical look at homogeneous RISC-V fusion for edge AI, where general-purpose and AI compute share one instruction set and one Linux kernel. The article explains how the RVA23 profile differs from the IME matrix extension, how hardware, memory, and compiler choices affect LLM inference, how Linux scheduling and cgroups manage resources, and how to benchmark a design before adopting it.
1. Introduction: Why Edge Devices Need Two Kinds of Compute
Local large language models and embodied intelligence robots are moving inference workloads onto edge devices. These devices face two requirements. First, the system must run a full Linux distribution reliably, so drivers, libraries, and services stay compatible. Second, the device must run on-device models within an acceptable power budget. Meeting both requirements under tight cost and power limits is difficult.
The traditional approach pairs a general-purpose CPU with a dedicated NPU. This combination offers high peak compute, but it has three common problems. First, each processor has its own runtime and driver, which raises system complexity. Second, the toolchains are fragmented, so model deployment must adapt to several environments. Third, data moves between the two processors, and the copy and synchronization overhead is significant.
Homogeneous fusion is an alternative. Its core idea is to have general-purpose cores and AI compute cores share the same RISC-V instruction set architecture (ISA) and run the same Linux kernel. AI compute capability exists as instruction extensions inside the cores, so AI tasks can be scheduled like ordinary threads. This reduces the driver and runtime layers, but it does not eliminate all overhead. The sections below explain which overheads remain.
2. RVA23 and IME: Understanding the Relationship
RVA23 is a profile for RISC-V application processors. It specifies which instruction extensions an application processor should provide, such as the vector extension and virtualization support. Its purpose is to give chips from different vendors a consistent software foundation. A chip that conforms to RVA23 meets this list, so software can rely on these capabilities without vendor-specific adaptation code.
IME is RISC-V’s matrix extension, which accelerates matrix multiply-accumulate operations. It is not a mandatory part of RVA23. This distinction matters: a chip that conforms to RVA23 does not necessarily support IME. When selecting hardware, check the chip manual or datasheet to confirm the IME version, the supported data types, and whether the vendor’s compiler and kernel support it.
This distinction directly affects engineering decisions. If your goal is to run standard Linux applications and general-purpose computing, RVA23 is a clear baseline. If your goal is on-device large model inference, the presence and maturity of IME determine whether operators can be accelerated. Evaluate the two separately.
3. Division of Labor and Boundaries Between Clusters
A homogeneous fusion design typically includes two types of clusters.
The general-purpose compute cluster consists of standard RISC-V cores. It runs the operating system, control logic, and conventional scalar workloads. Its design priorities are compatibility, predictable control paths, and maintenance cost.
The AI-CPU cluster adds a matrix extension, such as IME, on top of standard cores. These cores are still general-purpose. They run the same programs, with an additional set of instructions and registers for accelerating matrix operations.
The boundary between the two clusters comes from hardware design, not software convention. The matrix register state added to AI-CPU cores must be saved and restored. If the kernel does not save this state during context switches, matrix data can contaminate other processes. The kernel must therefore provide state management for this extension, and user space must request its use through the correct mechanism. This is a prerequisite for stable operation and must not be overlooked.
4. Hardware-Software Co-Design for LLM Inference
On edge devices, the bottleneck for running large models is usually memory bandwidth rather than peak compute. The attention and feed-forward layers of a Transformer contain many matrix multiplications, and weight reads and KV-cache updates access memory frequently.
4.1 Hardware: Matrix Extensions Increase Work per Instruction
IME allows one instruction to complete the computation of a small matrix block. It does not make individual scalar operations faster. Actual throughput depends on tile size, data type, and pipeline design. Matrix computation is generally tiled: a large matrix is split into smaller blocks, and intermediate results stay in matrix registers to reduce repeated memory access. The benefit therefore depends on the operator’s data layout and tiling strategy. It cannot be summarized as “completed in a single cycle.”
4.2 Memory: Shared Address Space Reduces Copies but Does Not Remove Synchronization
In a homogeneous fusion architecture, general-purpose cores and AI-CPU cores share one address space. AI tasks therefore do not need separate device memory mapping or extra DMA transfers. This removes part of the copy overhead.
Shared memory still has costs. The cache coherence protocol must keep data consistent across the caches of multiple cores, which adds latency. Inter-core communication and task synchronization still require locks or atomic operations. When data is exchanged frequently between the two types of cores, this overhead can offset the time saved by avoiding copies. The actual benefit must be determined by measurement.
4.3 Software: The Compiler Determines Whether Matrix Extensions Are Used
To use the matrix extension, a compiler must map high-level operators to the corresponding instructions. The common path is a backend based on Triton, MLIR, or a vendor compiler. Support for IME across the RISC-V ecosystem varies widely today. Some backends cover only some operators, while others require hand-written inline assembly or intrinsics. Before adopting a solution, confirm the supported operator list, the compiler version, and whether public benchmark results are available.
Compiler optimization results also depend on operator shape, data type, and memory layout. Under specific conditions, the compiler can bring an operator to high hardware utilization. This result cannot be generalized to all models.
5. Unified Scheduling and Resource Control on Linux
One main benefit of homogeneous fusion is unified scheduling. AI workloads can run as user-space threads managed by the Linux scheduler, such as CFS or a real-time scheduling class. This is simpler than maintaining a separate scheduling path for heterogeneous devices.
The code below shows one calling pattern. It is for illustration only. You must implement the preprocessing, matrix computation, and postprocessing functions yourself. The code cannot be compiled and run as-is.
```c
define _GNU_SOURCE
include
include
include
define AI_CPU_ID 4
typedef struct {
int cpu_id;
const float weights;
const float input;
float *output;
size_t n;
int ret;
} ai_job_t;
/ Implement this: call the IME matrix kernel. Return 0 on success. /
int run_matmul_kernel(const float w, const float in, float out, size_t n);
/ Implement this: preprocessing and postprocessing on the general-purpose cores. /
void preprocess_data(const float in);
void postprocess_data(float *out);
static void ai_worker(void arg)
{
ai_job_t *job = arg;
job->ret = run_matmul_kernel(job->weights, job->input, job->output, job->n);
return NULL;
}
int run_edge_ai_task(const float w, const float in, float *out, size_t n)
{
pthread_attr_t attr;
pthread_t tid;
cpu_set_t set;
ai_job_t job = { .cpu_id = AI_CPU_ID, .weights = w, .input = in
