The Sparsr processing system is a high-performance heterogeneous computing platform designed to accelerate sparse matrix compression, decompression, and wide bitwise logical operations. It combines an x86/x64 host CPU with a custom 4096-bit soft-processor core deployed on an FPGA (e.g., AWS EC2 FPGA instances).
The system architecture is divided into two execution domains separated by a PCI Express (PCIe) bus: the Host CPU Domain and the FPGA Hardware Domain.
sparsr_kernel_init(), sparsr_load_batch_from_bin(), sparsr_execute_batch(), sparsr_read_status(), sparsr_write_data_cmem(), sparsr_read_data_cmem()).See Memory Model (CMEM & DMEM) for the geometry, addressing rules, and compression format of DMEM and CMEM.
Communication between the Host Application and the Sparsr IP core occurs in 256-word (32-bit word) command bursts over PCIe. The host CPU acts as the master, and the FPGA acts as the responder. High-level host applications interact with the protocol via the C library header interface (sparsr.h), which dispatches commands to the runtime execution backend (softemu, fpgasim, or fpgaf2 selected via SPARSR_BACKEND).
| Command Name | CMD Encoding | Corresponding sparsr.h API Function |
Target Destination / Action | Description |
|---|---|---|---|---|
| LoadBatch | 1 |
sparsr_load_batch_from_bin(char[30], uint32_t) |
IMEM | Uploads compiled kernel instruction streams (.spex) to Instruction Memory starting at start_address. |
| WriteData_CMEM | 2 |
sparsr_write_data_cmem(uint8_t*, uint32_t) |
CMEM | Writes wide sparse/dense matrix data buffer from host RAM into On-FPGA High-Bandwidth CMEM at target address. |
| WriteData_DMEM | 3 |
sparsr_write_data_dmem(uint32_t*, uint32_t, uint32_t) |
DMEM | Writes 32-bit scalar data into On-FPGA Data Memory. |
| ReadData_CMEM | 4 |
sparsr_read_data_cmem(uint32_t) |
CMEM | Reads wide vector/matrix outputs from CMEM block at address back to Host System RAM. |
| ReadData_DMEM | 5 |
sparsr_read_data_dmem(uint32_t, uint32_t) |
DMEM | Reads scalar output values from DMEM back to Host System RAM. |
| ExecuteBatch | 6 |
sparsr_execute_batch(uint32_t) |
Processor Pipeline | Initiates kernel execution on the active backend from start_address. |
| ReadStatus | 7 |
sparsr_read_status() |
Control Unit | Polls execution status register (0 = not completed / running, 1 = completed). |
Backend Initialization & Selection: Before issuing command bursts, host applications invoke
sparsr_kernel_init()to initialize the execution backend. The active backend is configured via the environment variableSPARSR_BACKEND_ENV_VAR("SPARSR_BACKEND"), supporting"softemu"(default),"fpgasim", and"fpgaf2".Burst Payload Structure: Every 256-word burst contains 1 command word, payload length, start address, and up to 253 data words. If a transfer exceeds 253 words, it is sent across sequential command bursts.
The Sparsr processor contains two distinct register files (groups of CPU registers) operating in parallel within Stage 2 (Instruction Decode / Register Fetch) of the pipeline.
$0 to $31).$0 ($zero): Hardwired to constant 0.PC (Program Counter): 32-bit instruction pointer.HI / LO: 32-bit multiply/divide target registers.ADD, SUB, AND, OR, XOR, LB, LW, SB, SW, BEQ, BNE, J, JAL).WAND $wrd, $wrs, $wrt — 4096-bit bitwise AND: $wrd = $wrs & $wrt (Encoding 18, Format WR).WOR $wrd, $wrs, $wrt — 4096-bit bitwise OR: $wrd = $wrs | $wrt (Encoding 19, Format WR).WXOR $wrd, $wrs, $wrt — 4096-bit bitwise XOR: $wrd = $wrs ^ $wrt (Encoding 20, Format WR).WL $wrd, CMem[$addr] — Wide Load from CMEM into $wrd (Encoding 21, Format WI).WS CMem[$addr], $wrd — Wide Store from $wrd into CMEM (Encoding 22, Format WI).AIC CMem[$addr], $wrd — Compress $wrd vector and store to CMEM (Encoding 23, Format WI).AID $wrd, CMem[$addr] — Decompress CMEM entry into wide register $wrd (Encoding 28, Format WI).The Sparsr system utilizes a segmented memory architecture separating host RAM from on-chip FPGA memory banks.
| Memory Space | Location | Access Width | Primary Purpose | Pipeline Stage |
|---|---|---|---|---|
| Host System RAM | Off-Chip (Host PC) | 64-bit / System bus | Storing host application data, raw matrices, and driver buffers. | N/A |
| IMEM | On-FPGA (BRAM) | 32-bit | Stores assembled Sparsr/MIPS kernel machine code. | Stage 1 (Fetch) |
| DMEM | On-FPGA (BRAM) | 32-bit | Stores scalar data, indices, pointers, and loop counters. | Stage 4 (Memory) |
| CMEM | On-FPGA (BRAM) | 4096-bit / Variable | High-bandwidth storage for wide vectors, binary sparse matrices, and compressed streams. | Stage 4 (Memory) |
CMEM serves as the high-bandwidth memory block for vector and matrix operations:
wA, wB) to read or write full bitvectors without bottlenecks.AIC / AID):
AIC): Takes a full 4096-bit vector from wide register $wrd, extracts non-zero bit indices/runs, and writes the compressed representation directly into CMEM.AID): Reads a compressed entry from CMEM, expands it in hardware into a full 4096-bit sparse representation, and loads it into wide register $wrd.