MAVILERA GPU Laboratory: documentation
Interactive Microprocessor Architecture Laboratory: Visualize. Execute. Understand.
About the laboratory
The GPU Laboratory runs a small SIMT (single instruction, multiple threads) core in the browser. Its threads are grouped in warps: the threads of a warp share one instruction fetch and run it in lock-step, one thread per lane, each with its own 32 registers. An active mask says which lanes an instruction changes, and a reconvergence stack per warp lets the threads of a warp take different paths and meet again.
Every thread runs the RISC-V base instruction set RV32I, less the few instructions the core does not need. Five
warp-control instructions are added on the custom-0 opcode: tmc, wspawn,
split, join and bar. Their names and their R-type format follow the
Vortex research GPU as its paper describes it.
Why it matters: a graphics processor gets its speed from many simple lanes rather than one clever pipeline, and its programs from code written for one thread. The core shows what that costs: lanes left idle when the threads of a warp branch apart, and the instructions that manage the mask. The Models view adds the ideas around it, and the CPU + GPU system puts the core on the bus of a RISC-V processor.
- Vortex: Extending the RISC-V ISA for GPGPU and 3D-Graphics Research. B. Tine, F. Elsabbagh, K. Yalamarthy, H. Kim. arXiv:2110.10857, 2021. arxiv.org/pdf/2110.10857
The SIMT core and the micro-ISA are MAVILERA's teaching cores. They are not Vortex and not any product's GPU.
Getting started
- Open the application. The editor holds a kernel for two warps of four threads; Sample projects in the toolbar offer the laboratory programs, each with a note at the top on what to try.
- Press Assemble (Ctrl+Enter). The listing shows each instruction's 32-bit word; errors are marked in the editor and explained in the console.
- Press Step (F10). Each step is one clock cycle, in which one warp issues one instruction. Step back (Shift+F10) undoes a cycle; Run (F5) runs to the end or to a breakpoint.
- Choose Core · 2 × 4 at the top to see the same run on the drawing of the core.
The kernel of a new session: each thread writes the absolute value of its element.
.include "simt.inc"
.text
_start: li t0, 2 # two warps
la t1, kernel
wspawn t0, t1 # warp 1 starts at kernel; warp 0 goes on there too
kernel: csrr t0, THREAD_INDEX # i, the thread's index in the block (0 to 7)
slli t0, t0, 2 # the byte offset of x[i] and y[i]
lw t1, x(t0) # t1 := x[i]
slt t2, t1, zero # p := (x[i] < 0)
split t2 # the threads with p = 1 first
beqz t2, 1f # every active thread agrees here: no divergent branch
sub t1, zero, t1 # then: t1 := -x[i]
1: join # first pass: to the other threads; second: reconverge
sw t1, y(t0) # y[i] := |x[i]|
tmc zero # this warp ends
.data # the data memory, from address 0
x: .word 5, -3, 0, -7, 2, -1, 4, -8
y: .space 32
It ends after 28 cycles with y = 5, 3, 0, 7, 2, 1, 4, 8: 28 warp-instructions issued, 92 active lane-slots of 112, a SIMT efficiency of 82.1 %.
The workspace
The page is a workspace of panes, as in a code editor.
- Header: the views; the View menu (show or hide panes, focus and full screen); the theme and projector mode; Help.
- Toolbar: Assemble, Run, Step, Step back, Reset, Run to cursor; Speed; the Architecture menu, which chooses the instruction set and machine (below); Sample projects; Exercise; File.
- Editor with the program, Listing with each word and its fields, the Registers of the core and of each warp, the Counters, the Memory pane with the data memory and the Threads tab (every thread's registers), and the Console.
A one-bit register (done, fault) shows 0 or 1. The register PC (next) is the PC of the warp that
issues in the next cycle.
Two instruction sets
| Architecture menu | Machine | Views |
|---|---|---|
| RISC-V SIMT · 2 warps × 4 lanes | The SIMT core, two warps of four lanes (the default) | Instructions, Core · 2 × 4, Core · 1 × 8, Models, CPU + GPU |
| RISC-V SIMT · 1 warp × 8 lanes | The same core with one warp of eight lanes | as above |
| SIMT core · 4 lanes | The micro-ISA, an introduction: seven instructions, four lanes | Instructions, Masks · 4 lanes, Masks · 8 lanes, Models, CPU + GPU |
| SIMT core · 8 lanes | The micro-ISA with eight lanes | as above |
Changing between the RISC-V SIMT core and the micro-ISA reloads the page after a question in the page itself; each instruction set keeps its own program, view and workspace in the browser.
The RISC-V SIMT core
The machine
- Two warps of four lanes, or one warp of eight lanes. Each warp has a program counter, an active mask, a state (ready, waiting at a barrier, or not running) and a reconvergence stack of four entries.
- Each cycle the scheduler takes the next ready warp after the last one (round-robin) and issues one instruction to it. Every instruction takes one cycle; a load sees an ideal memory.
- An instruction memory of 64 words and a data memory of 256 words (1024 bytes), both from address 0. Every lane has its own port to the data memory; when two lanes store to the same word, the highest lane's value stays.
- A run starts with warp 0 at address 0, every lane active and every register 0. It ends when every warp has ended, or at a fault.
Instructions
Per thread: RV32I without auipc, jalr, byte and half-word loads and stores,
fence, ecall and ebreak. A branch, a jump, a load or a store works as in
RV32I for every active thread; an operand that the warp uses as one value (the mask of tmc, the
operands of wspawn and bar) comes from the lowest active thread.
| Instruction | What it does |
|---|---|
tmc rs1 | The active mask becomes rs1. A zero mask ends the warp. The stack must be empty. |
wspawn rs1, rs2 | In warp 0 only, with no other warp running: starts warps 1 to rs1 − 1 at address rs2, every lane active, registers 0. |
split rs1 | Pushes a reconverge entry with the present mask. If bit 0 of rs1 divides the active threads, it also pushes an else entry (the other threads' mask and the address after split) and continues with the threads whose bit is 1. |
join | Pops the stack: an else entry sends the other threads to its address with their mask; a reconverge entry restores the mask. |
bar rs1, rs2 | The warp waits at barrier rs1 (0 or 1) until rs2 warps have reached it. |
csrr rd, csr | Reads an identity register of the thread (below). |
The five warp-control instructions are R-type words on the custom-0 opcode (0001011), funct7 0, with funct3
0 to 4 for tmc, wspawn, split, join, bar.
| Identity register | Address | Value |
|---|---|---|
THREAD_INDEX | 0xCC0 | warp × lanes + lane: the thread's index in the block |
LANE_ID | 0xCC1 | the lane within the warp |
WARP_ID | 0xCC2 | the warp |
BLOCK_INDEX | 0xCC3 | 0 (a host may set it in the CPU + GPU system) |
BLOCK_SIZE | 0xCC4 | warps × lanes |
KERNEL_ARGS | 0xCC5 | 0 (a host may set it in the CPU + GPU system) |
Faults
The core runs divergent code only between split and join: a conditional branch on
which the active threads disagree is a fault. A fault stops the run with its code and a message.
| Code | Fault |
|---|---|
| 1 | divergent branch |
| 2 | illegal instruction (a word outside the subset) |
| 3 | reconvergence stack overflow (more than two nested divergent splits) |
| 4 | join on an empty stack |
| 5 | tmc with a non-empty stack |
| 6 | warp-control operand error |
| 7 | bad data address (not word-aligned, or past the 256 words) |
Counters
cycles, issued (warp-instructions) and active_slots (the active lanes
summed over the issues). SIMT efficiency = active_slots ÷ (issued × lanes).
MAVILERA's choices
- A faulting instruction counts in the counters and takes one step; nothing else changes.
- When every running warp waits at a barrier that no other warp will reach, the run stops before the cycle with a message; that cycle is not counted.
- Step back keeps the last 200 000 cycles.
Writing kernels
- One instruction per line, with an optional label (
loop:) and a comment after#. Numeric local labels work as in the GNU assembler:1:, then1for1b. .include "simt.inc"gives the names of the identity registers and of the warp-control instructions; it is built in.- The code starts at address 0.
.dataplaces data in the data memory from address 0; a label there can be an offset:lw t1, x(t0). - Every thread runs the whole program. Use
splitbefore a branch on per-thread data, a branch that every active thread then agrees on, andjoinwhere the paths meet; end each warp withtmc zero. - An instruction outside the subset is marked in the editor; loaded as an image, it faults when it runs.
The pattern of an if/else:
slt t2, t1, zero # p := (x < 0), per thread
split t2 # the threads with p = 1 first
beqz t2, else # uniform in each pass
... # then-path
j endif
else: ... # else-path
endif: join # to the other threads, then reconverge
The Core views
Core · 2 × 4 and Core · 1 × 8 draw the core of each machine in this
application's own layout. Each step is one cycle: the drawing shows the coming issue, the warp the scheduler
chooses, its instruction broadcast to the lanes, what each lane computes, and the write gates driven by the
active mask. warp_ctrl and the gates are shown by what they do (masks, stack entries, the address a
join returns to), not by their logic. The warps table under the drawing gives each warp's state, PC,
mask and stack.
| Tab | Contents |
|---|---|
| Issue | The coming issue lane by lane: the mask bit, what the lane computes and whether it is written. |
| Masks | One row per issue, a cell per lane with its mask bit (1 active, 0 idle and shaded). Masks-only count hides warp control, branches and jumps, and each warp's launch and setup (its issues before the instruction that computes the predicate of its first split), and says how many of each it hides. |
| Stack | Each issue of one warp with the active mask and the reconvergence stack after it. |
| Results | Cycles, issued instructions, active lane-slots and SIMT efficiency of this program, and of the laboratory programs run here. |
| Waveforms | done, fault, and each warp's mask and state over the cycles run so far; select a cycle to go to it. |
On a narrow screen the view shows one lane at a time: the mask strip of the coming issue, a button per lane, and what the chosen lane computes and writes. Whole drawing brings the drawing back. The drawing pans and zooms as the other drawings of MAVILERA do; Display exports it as SVG or PNG.
The micro-ISA
An introduction before the RISC-V core: one warp of four or eight lanes, a program memory of sixteen 16-bit words, four registers per lane (r0 holds the lane's index, r1 its input, r2 its output) and a mask stack of two entries. Every instruction takes one cycle.
| Instruction | Each active lane, or the warp |
|---|---|
LDI rd, imm | rd ← imm (eight bits, sign-extended) |
ADD rd, rs, rt | rd ← rs + rt |
SUB rd, rs, rt | rd ← rs − rt |
IFLT rs, rt | push the mask; the lanes with rs < rt (signed) stay active |
ELSE | the other lanes of the pushed mask become active |
ENDIF | pop the mask |
HALT | stop; the output of each lane is its r2 |
The dialect is MAVILERA's: one instruction per line, comments after ; or //, registers
r0 to r3, no labels (there are no branches); .din v0, v1, … gives the lanes' inputs and
.word v places one word. A third nested IFLT, and ELSE or
ENDIF with nothing pushed, stop the run before the instruction. The counters are
cycles and idle_slots.
Its views are Masks · 4 lanes and Masks · 8 lanes, the mask grid of each machine; the Lanes tab of the memory pane shows every lane's registers. The default program, the absolute value of four inputs, ends after 7 cycles with 4 idle lane-slots.
The Models view
Calculators for the ideas around the core. They do not run the program in the editor. Each tab has inputs, a table and a drawing; its i button explains the model.
| Tab | Model |
|---|---|
| Four machines | The additions of c[i] = a[i] + b[i] framed by what one instruction covers on a scalar pipeline, packed SIMD, a vector unit and a SIMT machine, with the instruction counts. |
| Amdahl | S = 1 / ((1 − f) + f / n) and efficiency S / n for a parallel fraction f on n lanes; the ceiling 1 / (1 − f). |
| Strips | A loop strip-mined with a run-time vector length: AVL and vl of each strip, with VLMAX = VLEN / SEW. The rule: vl = AVL when AVL ≤ VLMAX, VLMAX when AVL ≥ 2 VLMAX, else any value from ⌈AVL / 2⌉ to VLMAX. |
| Indexing | A launch over n elements: grid_size = ⌈n / block_size⌉ blocks, thread i = block_index × block_size + thread_index, the warps, the tail and the masks of the warps that are not full; where element i lies. |
| Blocks and SMs | Whole blocks assigned to streaming multiprocessors, in waves, and the warps of one block. |
| Latency | A timeline of W warps that each issue k instructions per load of latency L; the warps needed, (L − 1) / k + 1; and the occupancy a register file allows, with the share of cycles that issue, k W / (k − 1 + L). |
| Coalescing | The aligned blocks one warp's load needs at a stride: transactions, bytes delivered and bytes used. |
| Banks | The banks of a shared memory a warp's access touches; the access takes as many cycles as the busiest bank has distinct words, and a word read by several lanes is broadcast. |
Where a model needs a rule that the idea itself does not fix, the rule is MAVILERA's, stated in the tab's i button: the remainder of packed SIMD is done by scalar instructions; block b goes to SM b mod (number of SMs), a set number at a time; the scheduler stays with a warp until it has issued its load, then takes the next ready warp in turn. None of them is the rule of a product.
The CPU + GPU system
The CPU + GPU view of this laboratory opens the RISC-V Laboratory with the SIMT core (two warps of four lanes) on the bus of its single-cycle processor at 0x5000_1000. A host program copies a kernel into the core's instruction memory and its data into the data memory, writes 1 to CTRL, polls STATUS while the core issues one warp-instruction per clock cycle, and reads the results back. That page's views are ISA, Single-cycle (the datapath with the GPU on the data bus) and GPU (the core's drawing, warps, masks and stack as the host steps, and an Interface tab with the registers and the bus log). It keeps its own program and opens, on a first visit, with its template: the host running the absolute-value kernel.
| Offset | Register | Meaning |
|---|---|---|
| 0x000 | CTRL (write) | Bit 0 starts the kernel: warp 0 at address 0, every lane active, registers and counters 0. Bit 1 clears DONE and FAULT. Both bits: clear, then start. |
| 0x004 | STATUS (read) | Bit 0 BUSY, bit 1 DONE, bit 2 FAULT, bits 11:8 the fault code (1 to 7 the core's; 8 a deadlock at a barrier). |
| 0x008 | ARGS | kernel_args at launch |
| 0x00C | BLOCK | block_index at launch |
| 0x010, 0x014, 0x018 | CYCLES, ISSUED, ACTIVE (read) | The counters of the kernel |
| 0x400 to 0x4FC | IMEM | The instruction memory, 64 words |
| 0x800 to 0xBFC | DMEM | The data memory, 256 words; a read while the GPU is busy gives the word as it is then |
Writes to the GPU while it is busy are ignored, and the bus log marks them; whole words only. This register map is MAVILERA's own design, one way to attach such a core; a laboratory may ask for a design of your own.
The host's RISC-V assembler has no warp-control instructions, so a host program carries its kernel as words. The
CPU + GPU view of this laboratory gives the program in its editor that way, under Kernel for a host: its
instruction words as .word lines, each with its source line as a comment, and its data words, with
Copy and Download .s. Assemble the kernel for RISC-V SIMT · 2 warps × 4 lanes, the
machine on the host's bus.
Walkthroughs
1. The first kernel
- Assemble the kernel of a new session and choose Core · 2 × 4.
- Step three times: warp 0 runs
liand the two instructions ofla; warp 1 has not started yet. The next step issueswspawn; from then on the warps take turns. - Step to the first
splitof warp 0. Its threads hold 5, −3, 0, −7: the Issue tab shows the predicate 0101 (lane 0 first), so the then-path runs with mask 0101 and the stack gets a reconverge entry R 1111 and an else entry for 1010. - Run to the end. The Results tab gives 28 cycles, 92 active lane-slots of 112, 82.1 %.
2. Seeing the cost of divergence
- Open the template An if/else with split and join and open the Masks tab.
- Turn on Masks-only count: the rows left are the work under a mask, and the line below says how many launch, setup, warp-control and branch issues it hides.
- Compare with No divergence: every thread takes the same path, where every row is full.
3. Two warps and a barrier
- Open Reverse an array through a barrier. Step until a warp reaches
bar: its state becomes waiting at bar in the warps table, and only the other warp issues. - When the second warp arrives, both continue. The run ends after 71 cycles with 244 active lane-slots, an efficiency of 85.9 %.
- Open Fault: a divergent branch to see a branch without
splitstop the core with fault 1.
4. The Models view
- In Indexing, set n = 21, block size 8, warp size 4: three blocks, and the last warp runs with mask 1000.
- In Latency, keep W = 4, k = 3, L = 9: an instruction issues in every cycle. Change W to 3: two idle cycles (– in the Issue row) appear before the first warp's second round.
- In Banks, change the stride from 1 to 2, then to 8; then try 9.
5. The CPU + GPU system
- Choose CPU + GPU and Open the CPU + GPU system. The page opens with the host program and its template kernel.
- Assemble and step in the GPU view. The host first copies the 14 kernel words and the 8 inputs into the GPU, then writes 1 to CTRL; from the next cycle the GPU issues one warp-instruction in every cycle while the host polls STATUS.
- Run to the end: the kernel takes 28 cycles, the host program 231, and the Interface tab reads STATUS = DONE. Step back into the run to see both machines at work in the same cycle.
Exercises
File ▸ Exercise… lists practice exercises written for MAVILERA, for the RISC-V SIMT core: Two warps: the difference of two arrays, Clamp to a range with split and join and The sign of each element: a split inside a split. Each opens with a starter program on its machine.
- Pick an exercise and read its task; Load the starter program puts it in the editor.
- Write your kernel in place of the line
# your code, keeping the data labels the task names. - Press the Exercise button, then Run the tests. Each test writes words of the data memory, runs your program until every warp has ended, and compares the words it leaves with the expected values.
No solutions are included. A teacher's exercise file (JSON, with "arch": "gpu" and a profile,
lab or lab-l8) opens with File ▸ Open; its tests write and check data-memory
words. Exercises are not offered with the micro-ISA.
Files, sharing and exports
- Your work is kept in this browser: after a refresh the program, the cursor, breakpoints, watchpoints and the step you had reached come back; each instruction set keeps its own.
- File ▸ Copy share link puts the program, the view and its settings into a link, in the part after
#, which the browser never sends to a server. - File ▸ Save program and settings… writes a
.jsonfile; File ▸ Open reads it back, and also.sfiles.
| Export | Contents |
|---|---|
.hex, .bin | The instruction memory's words, one per line for $readmemh, or raw bytes. Import .hex/.bin… loads one; the data memory then starts as zeros. |
| Listing | Addresses, words and source lines |
| Golden dump | The 256 data-memory words, then cycles, issued, active_slots and the fault code, one word per line in hexadecimal (the micro-ISA: each lane's output, cycles, idle_slots and the final mask) |
| Waveform, VCD | The signals of the Core or Masks views, one clock per cycle |
| Drawing (SVG, PNG) | The core drawing of the present cycle, from the Display menu |
| Trace (JSON lines, CSV) | The micro-ISA only: one record per cycle from reset to the end |
The run exports replay the program from reset to its end; the session you are in is not changed.
Offline use and privacy
- After a first visit, the hosted application opens without a network connection.
- No account, no tracking, no upload: programs, data files and exports never leave the browser.
Keyboard reference
| Keys | Action |
|---|---|
| Ctrl+Enter | Assemble |
| F5 | Run or pause |
| F10 / Shift+F10 | Step / step back (one cycle) |
| Ctrl+F10 | Run to the editor's line |
| Ctrl+F | Find in the editor |
| Esc, then Tab | Leave the editor (inside it, Tab indents) |
| Arrow keys on a divider | Resize panes (Shift for larger steps; Enter restores) |
| Arrow keys on the Models tabs | Move between the models |
| Enter on a drawn element | Open its details |
How the models were checked
- The RISC-V SIMT core runs the eight laboratory programs to their reference golden files: the 256 data-memory words, the three counters and the fault code. Their source assembles to the same words as the GNU assembler's recorded output.
- Every issue of the eight programs was compared with the trace of the laboratory's Python reference model (cycle, warp, PC, mask before and after, stack), and 400 random programs of the subset with the same model: data memory, counters and fault code agree.
- The micro-ISA runs its three reference tests to their recorded outputs, cycles and idle lane-slots, and agrees with an independent interpreter on 3000 random programs.
- The Models view's calculators were checked against worked values: strips 8, 8, 3 for 19 elements and VLMAX 8; four warps with k = 3 and L = 9 issue in every cycle and three leave two idle cycles; 2, 8 and 32 transactions for strides of 1, 4 and 16 words.
- In the CPU + GPU system, each laboratory program run through the GPU device leaves the same data memory and counters as the core's own run.
No comparison with a hardware description of the core is recorded. Agreement between models is evidence about the models, not about any physical chip.
Limits of the model
- The core is a teaching model: one instruction per cycle, an ideal memory without latency, caches, coalescing or banks; up to two warps and eight lanes.
- The Models view's machines are declared models with illustrative numbers, not the timing of any GPU.
- In the CPU + GPU system the GPU is a device of the single-cycle processor only, with MAVILERA's register map.
Licence and notices
© 2026 Sajid Muhaimin Choudhury. MAVILERA and its content (drawings, help texts, this documentation, example programs and exercises) are licensed under the Apache License, Version 2.0. The names and the logo are not licensed as trademarks.
The SIMT core and the micro-ISA are MAVILERA's teaching cores; they are not Vortex and not any product's GPU, and MAVILERA makes no claim about the Vortex hardware or source code and is not affiliated with its authors. RISC-V® is a registered trademark of RISC-V International; MAVILERA uses the name only to identify the instruction set it simulates, uses no RISC-V logo, and is not affiliated with or endorsed by RISC-V International.