rivi-loader

Latest version Docs LICENSE

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.

Example

```Rust fn main() { let a: Vec = vec![1.0, 2.0]; let b: Vec = vec![3.0, 4.0]; let input = &vec![vec![a, b]]; let mut output = vec![0.0f32; 2];

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).

Features

Current limitations (to be addressed)

Installation

  1. Make sure Rust is installed, if not, consider rustup
  2. Make sure Vulkan is installed, if not, consider LunarG and the installation instructions found on ash
  3. Run an example. Recommended: simple vector addition cargo run --release --example repl. For random forest prediction (see: haavisto2021vulkan) run cargo run --release --example rf (this may crash your computer).

Example descriptions

The library

To understand what is happening in the lib.rs, consider a blog post series about graphics applications.

Periferia Labs

Periferia Labs is an ad-hoc group of friends tinkering with GPGPU. See our other projects: