use cetana::{backend::DeviceManager, MlResult}; fn main() -> MlResult<()> { cetana::log::init().expect("Failed to initialize logger"); println!("Device Features Example\n"); // Initialize device manager and select device let device_manager = DeviceManager::global(); println!( "Available devices: {:?}\n", device_manager.available_devices() ); // Get the default device let device = device_manager.select_device(None)?; DeviceManager::set_default_device(device)?; println!("Selected device: {}\n", DeviceManager::get_default_device()); // Get device features let features = device_manager.get_features(); println!("Supported Features:"); println!("------------------"); // Check specific features println!("CPU Features:"); println!( "AVX: {}", if features.is_supported("avx") { "✓" } else { "✗" } ); println!( "AVX2: {}", if features.is_supported("avx2") { "✓" } else { "✗" } ); println!( "AVX-512F: {}", if features.is_supported("avx512f") { "✓" } else { "✗" } ); println!("\nGPU Features:"); println!( "FP32: {}", if features.is_supported("fp32") { "✓" } else { "✗" } ); println!( "FP16: {}", if features.is_supported("fp16") { "✓" } else { "✗" } ); println!( "Tensor Cores: {}", if features.is_supported("tensor_cores") { "✓" } else { "✗" } ); // Example of checking specific features for optimization decisions println!("\nOptimization Paths:"); println!("------------------"); if features.is_supported("avx2") { println!("Using AVX2 optimized path"); } else if features.is_supported("avx") { println!("Using AVX optimized path"); } else { println!("Using fallback path"); } if features.is_supported("fp16") { println!("Half-precision operations available"); } if features.is_supported("tensor_cores") { println!("Tensor Cores acceleration available"); } Ok(()) }