Expand description
CPU-backed scaffold for future GPU acceleration of spatial algorithms
This module is a placeholder/scaffold for GPU-accelerated spatial algorithms. GPU compute is not yet implemented: every compute method in this module currently runs on the crate’s optimized CPU SIMD fallback and returns correct results — none of them dispatch any work to a graphics card.
The cuda, rocm, and vulkan Cargo features, when enabled, currently
gate only GPU capability detection (probing nvidia-smi, rocm-smi, and
vulkaninfo). They do not unlock any GPU compute path; the methods
below always delegate to the CPU SIMD implementations regardless.
A future release may add a real GPU backend (for example via the COOLJAPAN
oxicuda-* ecosystem). Until then, for production GPU-free work the CPU
equivalents in this crate are what actually run — see the simd_distance
module and the AdvancedSimdKMeans / AdvancedSimdNearestNeighbors types.
§Planned backends (scaffold — not yet functional)
These are the intended targets once a real GPU path lands; none of them perform GPU compute today:
- NVIDIA GPUs (CUDA backend)
- AMD GPUs (ROCm/HIP backend)
- Intel GPUs (Level Zero backend)
- Vulkan compute for cross-platform support
§Examples
The example uses the GPU-named API, but the computation transparently runs on the CPU SIMD fallback today — no GPU is required or used.
use scirs2_spatial::gpu_accel::{GpuDistanceMatrix, GpuKMeans};
use scirs2_core::ndarray::array;
// Distance matrix computation (runs on the CPU SIMD fallback)
let points = array![[0.0, 0.0], [1.0, 0.0], [0.0, 1.0], [1.0, 1.0]];
let gpu_matrix = GpuDistanceMatrix::new()?;
let distances = gpu_matrix.compute_parallel(&points.view()).await?;
println!("GPU distance matrix: {:?}", distances);
// K-means clustering (runs on the CPU SIMD fallback)
let gpu_kmeans = GpuKMeans::new(2)?;
let (centroids, assignments) = gpu_kmeans.fit(&points.view()).await?;
println!("GPU centroids: {:?}", centroids);Structs§
- GpuCapabilities
- GPU device capabilities and information
- GpuDevice
- GPU device management and capability detection
- GpuDistance
Matrix - GPU-accelerated distance matrix computation
- GpuK
Means - GPU-accelerated K-means clustering
- GpuNearest
Neighbors - GPU-accelerated nearest neighbor search
- Hybrid
Processor - Hybrid CPU-GPU workload distribution
Enums§
- GpuBackend
- Supported GPU backends
- Processing
Strategy - Processing strategy for workload distribution
Functions§
- get_
gpu_ capabilities - Get GPU capabilities
- global_
gpu_ device - Get the global GPU device instance
- is_
gpu_ acceleration_ available - Check if GPU acceleration is available globally
- report_
gpu_ status - Report GPU acceleration status