toml
[dependencies]
rivi-loader = "0.1.4"
rivi-loader is a Vulkan-based program loader for GPGPU applications. It builds on the Rust-based Vulkan wrapper ash. The project is a part of research agenda of interoperable GPU computing, that is, an effort to evaluate how Vulkan could be utilized to replace GLSL and CUDA accelerated programs with Vulkan.
```Rust
fn main() {
let a: Vec
let vk = rivi_loader::new(DebugOption::None).unwrap();
let mut cursor = std::io::Cursor::new(&include_bytes!("./repl/shader/sum.spv")[..]);
let shader = vk.load_shader(&mut cursor).unwrap();
vk.compute(input, &mut output, &shader).unwrap();
println!("Result: {:?}", output);
assert_eq!(output, vec![4.0, 6.0]);
} ```
The project aims to highlight performance optimizations available by using Vulkan with hand-written SPIR-V code. Various recent features of Vulkan, such as variable storage buffer pointers, dedicated memory allocations, subgroup operations, and asynchronous queue family usage are all relevant parts of the effort.
Thanks to Vulkan, the example programs run on both discrete and integrated graphics cards and across various operating systems. Testing on discrete cards has primarily been done on Windows 10 and Linux (Arch and Ubuntu LTS using proprietary drivers) using AMD and Nvidia cards, with both AMD and Intel CPUs on computers with single and multiple GPUs. Integrated cards that have been tested include Apple M1, Raspberry Pi 4, and Nvidia Jetson TX2.
The project is aimed as an example repository from which motivated people can use to start to tip their toes into GPGPU. In particular, the examples/repl.rs
should be a good starting point to see what can be abstracted away. At the moment, programming your own application requires SPIR-V know-how, but one of the primary goals of the effort is eventually integrating a flavor of APL as the user-interfacing language (see: haavisto2021vulkan and hal-03155647).
cargo run --release --example repl
. For random forest prediction (see: haavisto2021vulkan) run cargo run --release --example rf
(this may crash your computer).repl
a rough translation of WebGPU-based laskin.live on Vulkanrf
a random forest prediction algorithm translated from scikit (proof-of-concept of variable pointers feature and performance comparison against Cython)To understand what is happening in the lib.rs
, consider a blog post series about graphics applications.
Periferia Labs is an ad-hoc group of friends tinkering with GPGPU. See our other projects: