#[cfg(feature = "gpu")]
#[path = "gpu/helpers.rs"]
mod helpers;
#[cfg(feature = "gpu")]
#[path = "gpu/gpu_backend.rs"]
mod gpu_backend;
#[cfg(all(test, feature = "gpu"))]
#[path = "gpu/gpu_backend_tests.rs"]
mod gpu_backend_tests;
#[cfg(all(test, feature = "gpu"))]
#[path = "gpu/gpu_csr_tests.rs"]
mod gpu_csr_extended_tests;
#[cfg(feature = "gpu")]
#[path = "gpu/pq_gpu.rs"]
pub mod pq_gpu;
#[cfg(feature = "gpu")]
#[path = "gpu/gpu_csr.rs"]
pub mod gpu_csr;
#[cfg(feature = "gpu")]
#[path = "gpu/gpu_traversal_buffers.rs"]
mod gpu_traversal_buffers;
#[cfg(feature = "gpu")]
#[path = "gpu/gpu_traversal_pipelines.rs"]
mod gpu_traversal_pipelines;
#[cfg(feature = "gpu")]
#[path = "gpu/gpu_traversal.rs"]
pub mod gpu_traversal;
#[cfg(feature = "gpu")]
pub use gpu_backend::GpuAccelerator;
#[cfg(feature = "gpu")]
pub use gpu_traversal::{should_traverse_gpu, GpuTraversalContext, GpuTraversalStats};
#[cfg(feature = "gpu")]
pub use pq_gpu::{gpu_kmeans_assign, should_use_gpu, PqGpuContext};
#[cfg(not(feature = "gpu"))]
#[must_use]
pub fn should_use_gpu(_n: usize, _k: usize, _subspace_dim: usize) -> bool {
false
}
#[cfg(not(feature = "gpu"))]
#[must_use]
pub fn should_traverse_gpu(_num_vectors: usize, _dimension: usize) -> bool {
false
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[allow(dead_code)] pub(crate) enum ComputeBackend {
#[default]
Simd,
#[cfg(feature = "gpu")]
Gpu,
}
#[allow(dead_code)] impl ComputeBackend {
#[must_use]
pub fn best_available() -> Self {
#[cfg(feature = "gpu")]
{
if gpu_backend::GpuAccelerator::is_available() {
return Self::Gpu;
}
}
Self::Simd
}
#[must_use]
pub fn gpu_available() -> bool {
#[cfg(feature = "gpu")]
{
gpu_backend::GpuAccelerator::is_available()
}
#[cfg(not(feature = "gpu"))]
{
false
}
}
}