Skip to main content

qualia_core_db/query/graph_accel/
mod.rs

1//! Graph acceleration: GPU-first integer kernels over NQuins / u64 keys, with
2//! a CPU radix / scan / sort-merge floor that always works.
3//!
4//! Chain: **GPU (shared wgpu) → CPU**. NPU is a reserved [`AccelPath`] slot;
5//! `platform::npu_ffi` today is wgpu (`sieve.wgsl`), not a third backend.
6//!
7//! Override: `QUALIA_GRAPH_ACCEL=cpu|gpu|auto` (default auto).
8
9mod cpu;
10#[cfg(feature = "gpu-runtime")]
11mod gpu;
12/// CPU-floor stubs so sort/sieve keep compiling when wgpu graph kernels are off.
13#[cfg(not(feature = "gpu-runtime"))]
14mod gpu {
15    use super::cpu::QuinField;
16    use crate::NQuin;
17
18    /// `?::radix_sort_u64_indices_gpu`.
19    pub fn radix_sort_u64_indices_gpu(_keys: &[u64]) -> Option<Vec<u32>> {
20        None
21    }
22
23    /// GPU sieve of equality indices.
24    pub fn sieve_eq_indices_gpu(
25        _quins: &[NQuin],
26        _field: QuinField,
27        _needle: u64,
28    ) -> Option<Vec<u32>> {
29        None
30    }
31}
32mod join;
33mod path;
34// Q42 volume files use the native mmap-backed reader. Browser builds work on
35// caller-provided Quin frames and must not pull that filesystem surface in.
36#[cfg(not(target_arch = "wasm32"))]
37mod segment;
38mod sieve;
39mod sort;
40
41pub use cpu::QuinField;
42pub use join::{hash_join_u64, hash_join_u64_cpu, JoinOutcome};
43pub use path::{
44    gpu_available, npu_available, AccelPath, AccelPolicy, GPU_JOIN_MIN, GPU_SIEVE_MIN, GPU_SORT_MIN,
45};
46#[cfg(not(target_arch = "wasm32"))]
47pub use segment::sieve_volume_file;
48pub use sieve::{sieve_eq, sieve_eq_indices, SieveOutcome};
49pub use sort::{
50    sort_quins_by_object, sort_quins_by_object_cpu_only, sort_u64_indices, SortOutcome,
51};
52
53#[cfg(feature = "gpu-runtime")]
54pub use etalon_nquin::{GpuNQuinSieve, GpuQuinSieve, GpuRadixSorter, NQuinWire};
55
56#[cfg(test)]
57mod tests;