use chrono::{DateTime, Local}; use furiosa_smi_rs::SmiResult; use furiosa_smi_rs::{driver_info, list_devices}; fn main() -> SmiResult<()> { let devices = list_devices()?; match driver_info() { Ok(version_info) => { println!("Driver Version: {}", version_info); } Err(_) => { println!("Error: Failed to retrieve driver information.") } } for device in devices.iter() { let device_info = device.device_info()?; println!("Device Info"); println!("\t\tDevice Index: {:?}", device_info.index()); println!("\t\tDevice Arch: {:?}", device_info.arch()); println!("\t\tDevice Cores: {:?}", device_info.core_num()); println!("\t\tDevice NUMA Node: {:?}", device_info.numa_node()); println!("\t\tDevice Name: {:?}", device_info.name()); println!("\t\tDevice Serial: {:?}", device_info.serial()); println!("\t\tDevice UUID: {:?}", device_info.uuid()); println!("\t\tDevice BDF: {:?}", device_info.bdf()); println!("\t\tDevice Major: {:?}", device_info.major()); println!("\t\tDevice Minor: {:?}", device_info.minor()); println!( "\t\tDevice Firmware Version: {}", device_info.firmware_version() ); let device_file = device.device_files()?; println!("Device Files"); for file in device_file.iter() { println!("\t\tDevice File Cores: {:?}", file.cores()); println!("\t\tDevice File Path: {:?}", file.path()); } //core status let core_status = device.core_status()?; println!("Core Status"); for (core_id, status) in core_status.iter() { println!("\t\tCore ID: {:?}", core_id); println!("\t\tCore Status: {:?}", status); } //error info let error_info = device.device_error_info()?; println!("Device Error Info"); println!( "\t\tDevice axi post error count: {:?}", error_info.axi_doorbell_error_count() ); println!( "\t\tDevice axi fetch error count: {:?}", error_info.axi_fetch_error_count() ); println!( "\t\tDevice axi discard error count: {:?}", error_info.axi_discard_error_count() ); println!( "\t\tDevice axi doorbell error count: {:?}", error_info.axi_doorbell_error_count() ); println!( "\t\tDevice pcie post error count: {:?}", error_info.pcie_post_error_count() ); println!( "\t\tDevice pcie fetch error count: {:?}", error_info.pcie_fetch_error_count() ); println!( "\t\tDevice pcie discard error count: {:?}", error_info.pcie_discard_error_count() ); println!( "\t\tDevice pcie doorbell error count: {:?}", error_info.pcie_doorbell_error_count() ); println!( "\t\tDevice device error count: {:?}", error_info.device_error_count() ); //liveness println!("Device Liveness: {:?}", device.liveness()?); //power consumption println!( "Device Power Consumption: {:?}", device.power_consumption()? ); //temperature let device_temperature = device.device_temperature()?; println!("Device Temperature"); println!("\t\tDevice SOC Peak: {:?}", device_temperature.soc_peak()); println!("\t\tDevice Ambient: {:?}", device_temperature.ambient()); //performance let core_utilization = device.core_utilization()?; let device_performance_counter = device.device_performance_counter()?; println!("Device Utilization"); let pe_performance_counter = device_performance_counter.pe_performance_counters(); let pe_utilization = core_utilization.pe_utilization(); for (pe_util, pe_performance_counter) in pe_utilization.iter().zip(pe_performance_counter.iter()) { println!("\t\tPE Core: {:?}", pe_util.core()); println!("\t\tPE Time Window Mill: {:?}", pe_util.time_window_mill()); println!( "\t\tPE Usage Percentage: {:?}", pe_util.pe_usage_percentage() ); let timestamp = pe_performance_counter.timestamp(); let datetime: DateTime = timestamp.into(); println!("\t\tPE Timestamp: {}", datetime); println!( "\t\tPE Task Execution Cycle: {:?}", pe_performance_counter.task_execution_cycle() ); println!( "\t\tPE Cycle Count: {:?}", pe_performance_counter.cycle_count() ); } let memory_utilization = match device.memory_utilization() { Ok(memory_utilization) => memory_utilization, Err(furiosa_smi_rs::SmiError::NotSupportedError) => { println!("Memory Utilization is not supported yet"); continue; } Err(e) => return Err(e), }; println!("Memory Utilization"); println!( "\t\tMemory Total Bytes: {:?}", memory_utilization.total_bytes() ); println!( "\t\tMemory In Use Bytes: {:?}", memory_utilization.in_use_bytes() ); } Ok(()) }