rill_core/math/vector/simd/mod.rs
1//! # SIMD implementations for vector operations
2//!
3//! This module contains platform-dependent SIMD implementations of vector operations.
4//!
5//! ## CPU feature detection
6//! The system automatically determines available SIMD instructions at runtime
7//! and selects the optimal implementation.
8//!
9//! ## Supported architectures
10//! - x86/x86_64: SSE2, SSE4.1, AVX, AVX2, AVX512
11//! - ARM: NEON (AArch64)
12//! - WebAssembly: SIMD128
13//!
14//! ## Usage
15//! Users typically don't interact with this module directly,
16//! but use the high-level abstractions from `vector::traits`.
17
18#![allow(unused_imports)]
19#![allow(dead_code)]
20
21// Cross-platform SIMD implementation via the wide crate (requires simd feature)
22#[cfg(feature = "simd")]
23pub mod wide;
24
25#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
26pub mod x86;
27
28#[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
29pub mod arm;
30
31#[cfg(target_arch = "wasm32")]
32pub mod wasm;
33
34/// SIMD capability detector for the CPU
35pub struct SimdDetector {
36 has_sse2: bool,
37 has_sse4_1: bool,
38 has_avx: bool,
39 has_avx2: bool,
40 has_avx512: bool,
41 has_neon: bool,
42 has_wasm_simd128: bool,
43}
44
45impl Default for SimdDetector {
46 fn default() -> Self {
47 Self::new()
48 }
49}
50
51impl SimdDetector {
52 /// Creates a detector and determines the current CPU's capabilities
53 pub fn new() -> Self {
54 // Temporary stub: always returns false for SIMD extensions
55 // In a real implementation, detection would be done via raw_cpuid or similar libraries
56 Self {
57 has_sse2: false,
58 has_sse4_1: false,
59 has_avx: false,
60 has_avx2: false,
61 has_avx512: false,
62 has_neon: false,
63 has_wasm_simd128: false,
64 }
65 }
66
67 /// Returns the maximum recommended SIMD width for the current platform
68 pub fn recommended_simd_width<T: crate::Transcendental>() -> usize {
69 // Temporary stub: always returns scalar width
70 // In a real implementation, selection logic based on detection would go here
71 1
72 }
73}
74
75// Re-exports
76#[cfg(feature = "simd")]
77pub use wide::*;
78
79// Platform-specific re-exports (not yet implemented)
80// #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
81// pub use x86::*;
82
83// #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
84// pub use arm::*;
85
86// #[cfg(target_arch = "wasm32")]
87// pub use wasm::*;