1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//! wgpu linear-scan backend for GPU k-NN (stub, `gpu_kdtree` feature).
//!
//! This module provides the entry point for a real wgpu / WGSL parallel
//! linear-scan implementation. In the current release the stub unconditionally
//! returns an error so the auto-dispatch layer falls back to the CPU k-d tree
//! path. This matches the established pattern used in other GPU stubs across
//! the SciRS2 codebase.
//!
//! ## Future implementation
//!
//! A real implementation would:
//! 1. Pack all points into a `wgpu::Buffer` as `f32` (or `f64` via
//! `shader_f64` extension where available).
//! 2. Dispatch a WGSL compute shader that, for each query thread, computes
//! distances to all stored points and maintains a small local heap of size k.
//! 3. Download the result buffers back to the host and convert them to
//! `KdQueryResult` values.
//!
//! Because wgpu initialization is async and allocation can fail, the stub
//! returns `Err` immediately to exercise the fallback path in tests.
use ;
use crateInterpolateError;
/// Attempt a GPU linear-scan k-NN via wgpu.
///
/// # Current behavior
///
/// Returns `Err` unconditionally — the GPU backend is not yet implemented.
/// The caller (`knn_auto_dispatch`) silently falls back to the CPU path.