Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/kleene

crates/kleene-cubecl/src/lib.rs

//! The kleene-sparse backend on GPUs, through CubeCL's wgpu runtime (Vulkan via SPIR-V).
//!
//! [`GpuBackend`] implements [`kleene_sparse::SparseBackend`] with its vectors and masks
//! on the GPU ([`GpuVector`], [`GpuMask`]) and its matrices uploaded once and cached by the
//! [`GpuDevice`]: products, accumulation, the push and pull steps of a breadth-first
//! search, masks, assignment and counts run as GPU kernels, so an algorithm written over
//! the trait (a search, a propagation) keeps its rounds on the GPU and only counts come
//! back. It also implements [`kleene_graph::GraphBackend`] with whole algorithms on the
//! GPU: weak components (Afforest union-find), strong components (trim, colour, search
//! back), shortest paths (delta-stepping), source sets and PageRank (GAP's pull rounds),
//! and the computed split's round (`split_votes`: per node the part of the most
//! neighbours weighted by room, the same list as the CPU kernel's bit for bit).
//! Answers are the CPU backend's: the same components, distances, parents and sets, and
//! PageRank's rounds with `f32` scores within [`PAGERANK_L1`] of the CPU's (the GPU sums a
//! long row in another order); the tests compare them.
//!
//! Making a [`GpuDevice`] does not open a GPU; the first kernel does.
//!
//! Below measured edge counts ([`CpuBelow`]) each whole algorithm runs on the CPU, by the
//! adapter's kind: an integrated GPU leaves every algorithm to the CPU but the source sets
//! ([`CpuBelow::INTEGRATED`]); a discrete GPU takes the crossovers measured on one RTX 5080,
//! which a small discrete card (an RTX A2000) needs set higher
//! ([`GpuDevice::set_cpu_below`]). A deep, narrow breadth-first search moves its levels to
//! the CPU and back as its frontier shrinks and grows ([`CpuBelow::bfs_frontier`],
//! [`CpuBelow::bfs_depth`]).

mod algo;
mod backend;
mod dev;
mod kernels;

pub use algo::PAGERANK_L1;
pub use backend::{GpuBackend, GpuWorkspace};
pub use dev::{CpuBelow, GpuDevice, GpuKind, GpuMask, GpuMatrix, GpuVector};

/// The README's example, run as a doctest.
#[cfg(doctest)]
#[doc = include_str!("../README.md")]
struct ReadmeDoctests;