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/README.md

kleene-cubecl

The kleene-sparse backend on GPUs, through CubeCL's wgpu runtime: Vulkan (SPIR-V) on Linux and Windows, Metal on macOS. GpuBackend implements kleene_sparse::SparseBackend with vectors and masks kept on the GPU and matrices uploaded once, so an algorithm written over the trait 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, strong components, shortest paths, source sets and PageRank, and the round of the computed split (split_votes, under kleene_graph::computed_split: a unit per node with its K counters in hand, a cube of 256 per node of more than 512 edges; the graph's patterns cached, the part per node up and the wanted part down each round). The answers are the CPU backend's (the split's list bit for bit; PageRank's f32 scores within PAGERANK_L1 of them, summed in another order); the tests compare them.

Below measured edge counts (CpuBelow) each whole algorithm runs on the CPU instead, by the adapter's kind. An integrated GPU leaves every algorithm (and the split's round) to the CPU but the source sets (from 2000000 edges; measured on a Radeon 660M and an Intel UHD). A discrete GPU takes the crossovers measured on one RTX 5080; a small discrete card needs higher ones (GpuDevice::set_cpu_below). A breadth-first search (and Datalog reach) runs on the CPU below 4194304 edges (on an integrated GPU always), and a deep one moves its levels to the CPU past 16 levels while its frontier is under 16384 vertices, back at four times that (CpuBelow::bfs_frontier, bfs_depth; road2048 on an RTX 5080: 1002 to 2142 ms before, 200 to 204 ms after). Measured on a laptop's RTX A2000 against 8 threads, GPU forced, kleene CPU ms / GPU ms:

graph edges cc scc sssp-hops sssp-weighted sets64 pagerank
rmat14 119806 0.312 / 0.308 0.760 / 2.110 0.394 / 1.915 1.175 / 4.232 0.893 / 1.522 3.243 / 2.521
rmat16 494438 0.582 / 0.557 1.766 / 3.111 0.589 / 2.998 2.582 / 7.836 4.147 / 3.152 4.977 / 3.867
rmat18 2017227 1.031 / 3.582 6.351 / 17.284 1.766 / 20.051 10.147 / 55.368 19.655 / 25.680 16.493 / 10.897
rmat20 8175389 4.970 / 5.551 27.146 / 33.365 7.202 / 72.592 34.937 / 47.478 39.664 / 103.087 69.705 / 28.394
rmat22 32988662 20.228 / 12.688 114.527 / 129.254 26.773 / 66.500 162.414 / 128.009 147.445 / 223.222 345.443 / 139.785
road1024 2513276 4.644 / 5.600 50.258 / 2404.228 22.845 / 512.344 77.851 / 1255.454 49.195 / 510.923 59.975 / 14.655

Making a GpuDevice opens no GPU; the first kernel does. The crate builds and documents on a machine without one. Part of kleene.

,no_run
use kleene_cubecl::{GpuBackend, GpuDevice};
use kleene_graph::components;
use kleene_sparse::{BoolOrAnd, CpuDevice, Csr};

// Two weak components: {0, 1, 2} and {3, 4}.
let a = Csr::from_edges(5, 5, &[0, 1, 3], &[1, 2, 4], None, BoolOrAnd)?;
let gpu = GpuDevice::with_cpu(CpuDevice::new(4));
let c = components::<GpuBackend>(&a, &gpu)?;
assert_eq!(c.count(), 2);
# Ok::<(), Box<dyn std::error::Error>>(())

Licence

MIT or Apache-2.0, at your option.