Expand description
§Riri
A Miri-style undefined-behaviour detector for Rust GPU kernels.
Riri runs a SIMT kernel on the CPU: every GPU thread becomes a simulated thread, and a deterministic, seeded scheduler interleaves them one instrumented operation at a time. Every memory access goes through shadow memory, so Riri can report:
- data races on global and shared memory (happens-before via
sync_threadsbarriers within a block and full-mask warp collectives within a warp; no ordering across blocks), - barrier divergence (some threads of a block wait at a barrier that other threads of the same block never reach),
- warp divergence at a collective: a lane named by a shuffle’s member
mask never reaches it, so the warp can never reconverge (see
warp), - mismatched member masks and shuffles from a non-member lane,
- uninitialised shared-memory reads,
- out-of-bounds accesses and kernel panics (reported as traps).
No GPU is required, so Riri runs in ordinary cargo test and CI.
use riri::{launch, GlobalBuf, LaunchConfig};
let a = GlobalBuf::new("a", vec![1.0f32; 64]);
let b = GlobalBuf::new("b", vec![2.0f32; 64]);
let c = GlobalBuf::new("c", vec![0.0f32; 64]);
let report = launch(&LaunchConfig::new(2, 32).seed(7), |t| {
let i = t.global_linear();
c.write(t, i, a.read(t, i) + b.read(t, i));
});
report.assert_clean();
assert!(c.to_vec().iter().all(|&x| x == 3.0));Modules§
- oxide
- A
cuda_device-shaped surface, so a kernel written for cuda-oxide can be checked by Riri without being rewritten. - warp
- Warp-level collectives, with convergence checking.
Structs§
- Access
- One recorded memory access.
- Dim3
- A CUDA-style three-dimensional extent or index.
- ElemMut
- A borrowed element of an instrumented buffer, held for as long as the caller keeps it.
- Exploration
- The result of searching across schedules.
- Explore
- Searches across schedules for one that finds a problem.
- Failure
- The first failing schedule an exploration found.
- Global
Buf - A buffer in simulated global (device) memory.
- Launch
Config - Grid and block shape, warp width, and the scheduler seed.
- Report
- The result of one kernel launch under Riri.
- Schedule
- A recorded sequence of scheduling decisions, replayable with
replay. - Shared
Array - A block-wide
__shared__array. Obtain one withThreadCtx::shared. - Thread
Ctx - Per-thread view of a running kernel: the equivalent of CUDA’s built-in
threadIdx,blockIdx,blockDim,gridDim, plus__syncthreads()and__shared__allocation.
Enums§
- Access
Kind - What kind of memory operation an access was.
- Diagnostic
- A problem Riri found while executing a kernel.
- Lane
Problem - Ways a lane can name the wrong threads in a warp collective.
- MemSpace
- Which memory an access touched.
- Ordering
- How an atomic access or a fence orders the operations around it.
- Shrink
- Why a failing schedule is or is not available in shrunk form.
Constants§
- MAX_
THREADS - Simulated threads are real OS threads, so a wave has to stay test-sized.