Skip to content

Commit

Permalink
lib, xdna, tui, smi, gui, json: Rust 2024 Edition
Browse files Browse the repository at this point in the history
  • Loading branch information
Umio-Yasuno committed Feb 21, 2025
1 parent 2e1a74f commit 18629dd
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "amdgpu_top"
version = "0.10.3"
edition = "2021"
edition = "2024"
license = "MIT"
repository = "https://github.com/Umio-Yasuno/amdgpu_top"
authors = ["Umio Yasuno <[email protected]>"]
Expand Down Expand Up @@ -39,7 +39,7 @@ members = [

[workspace.package]
version = "0.10.3"
edition = "2021"
edition = "2024"
authors = ["Umio Yasuno <[email protected]>"]
repository = "https://github.com/Umio-Yasuno/amdgpu_top"

Expand Down
8 changes: 4 additions & 4 deletions crates/amdgpu_top_gui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,21 +452,21 @@ impl MyApp {
let min_max = if let [Some(min), Some(max)] = [sensors.min_dpm_link, sensors.max_dpm_link] {
format!(
" (Gen{}x{} - Gen{}x{})",
min.gen,
min.r#gen,
min.width,
max.gen,
max.r#gen,
max.width,
)
} else if let Some(max) = sensors.max_dpm_link {
format!(" ({} Gen{}x{})", fl!("max"), max.gen, max.width)
format!(" ({} Gen{}x{})", fl!("max"), max.r#gen, max.width)
} else {
String::new()
};

ui.label(format!(
"{} => Gen{}x{} {min_max}",
fl!("pcie_link_speed"),
cur.gen,
cur.r#gen,
cur.width,
));
}
Expand Down
8 changes: 4 additions & 4 deletions crates/amdgpu_top_gui/src/gui_device_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,23 +366,23 @@ impl GuiInfo for AppDeviceInfo {
let dpm = fl!("dpm");
if let [Some(min), Some(max)] = [&self.min_dpm_link, &self.max_dpm_link] {
ui.label(format!("{pcie_link_speed} ({dpm})"));
ui.label(format!("Gen{}x{} - Gen{}x{}", min.gen, min.width, max.gen, max.width));
ui.label(format!("Gen{}x{} - Gen{}x{}", min.r#gen, min.width, max.r#gen, max.width));
ui.end_row();
} else if let Some(max) = &self.max_dpm_link {
ui.label(format!("{pcie_link_speed} ({dpm}, {fl_max})"));
ui.label(format!("Gen{}x{}", max.gen, max.width));
ui.label(format!("Gen{}x{}", max.r#gen, max.width));
ui.end_row();
}

if let Some(gpu) = &self.max_gpu_link {
ui.label(format!("{pcie_link_speed} ({}, {fl_max})", fl!("gpu")));
ui.label(format!("Gen{}x{}", gpu.gen, gpu.width));
ui.label(format!("Gen{}x{}", gpu.r#gen, gpu.width));
ui.end_row();
}

if let Some(system) = &self.max_system_link {
ui.label(format!("{pcie_link_speed} ({}, {fl_max})", fl!("system")));
ui.label(format!("Gen{}x{}", system.gen, system.width));
ui.label(format!("Gen{}x{}", system.r#gen, system.width));
ui.end_row();
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/amdgpu_top_json/src/output_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ impl OutputJson for GpuActivity {
impl OutputJson for PCI::LINK {
fn json(&self) -> Value {
json!({
"gen": self.gen,
"gen": self.r#gen,
"width": self.width,
})
}
Expand Down
2 changes: 1 addition & 1 deletion crates/amdgpu_top_tui/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl TuiApp {
self.layout.vram_usage_view.set_value(&self.app_amdgpu_top.stat.vram_usage);
self.layout.activity_view.set_value(&self.app_amdgpu_top.stat.activity);

if let Some(ref sensors) = &self.app_amdgpu_top.stat.sensors {
if let Some(sensors) = &self.app_amdgpu_top.stat.sensors {
let _ = self.layout.sensors_view.print_sensors(sensors);
}

Expand Down
8 changes: 4 additions & 4 deletions crates/amdgpu_top_tui/src/view/sensors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ impl AppTextView {
}

if let Some(cur) = sensors.current_link {
write!(self.text.buf, " PCIe Link Speed => Gen{}x{:<2}", cur.gen, cur.width)?;
write!(self.text.buf, " PCIe Link Speed => Gen{}x{:<2}", cur.r#gen, cur.width)?;

if let [Some(min), Some(max)] = [sensors.min_dpm_link, sensors.max_dpm_link] {
write!(
self.text.buf,
" (Gen{}x{} - Gen{}x{})",
min.gen,
min.r#gen,
min.width,
max.gen,
max.r#gen,
max.width,
)?;
} else if let Some(max) = sensors.max_dpm_link {
write!(self.text.buf, " (Max. Gen{}x{})", max.gen, max.width)?;
write!(self.text.buf, " (Max. Gen{}x{})", max.r#gen, max.width)?;
}

writeln!(self.text.buf)?;
Expand Down
8 changes: 4 additions & 4 deletions crates/libamdgpu_top/src/xdna/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ impl<T> __IncompleteArrayField<T> {
self as *mut _ as *mut T
}
#[inline]
pub unsafe fn as_slice(&self, len: usize) -> &[T] {
pub unsafe fn as_slice(&self, len: usize) -> &[T] { unsafe {
::std::slice::from_raw_parts(self.as_ptr(), len)
}
}}
#[inline]
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] {
pub unsafe fn as_mut_slice(&mut self, len: usize) -> &mut [T] { unsafe {
::std::slice::from_raw_parts_mut(self.as_mut_ptr(), len)
}
}}
}
impl<T> ::std::fmt::Debug for __IncompleteArrayField<T> {
fn fmt(&self, fmt: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
Expand Down
4 changes: 2 additions & 2 deletions crates/libamdgpu_top/src/xdna/ioctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl From<u32> for XdnaPowerMode {
}
}

unsafe fn get_xdna_info<T>(fd: i32, param: u32) -> Result<T, Errno> {
unsafe fn get_xdna_info<T>(fd: i32, param: u32) -> Result<T, Errno> { unsafe {
ioctl_readwrite!(
xdna_get_info,
DRM_IOCTL_BASE,
Expand All @@ -113,7 +113,7 @@ unsafe fn get_xdna_info<T>(fd: i32, param: u32) -> Result<T, Errno> {
let info = info.assume_init();

r.map(|_| info)
}
}}

pub fn get_xdna_clock_metadata(fd: i32) -> Result<XdnaClockMetadata, Errno> {
let clock_metadata: amdxdna_drm_query_clock_metadata = unsafe {
Expand Down
8 changes: 4 additions & 4 deletions src/dump_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,21 @@ fn sensors_info(sensors: &Sensors) {
println!(
"{PCIE_LABEL} {:PCIE_LEN$}: Gen{}x{:<2} - Gen{}x{:<2}",
"(DPM, Min-Max)",
min.gen,
min.r#gen,
min.width,
max.gen,
max.r#gen,
max.width,
);
} else if let Some(max) = &sensors.max_dpm_link {
println!("{PCIE_LABEL} {:PCIE_LEN$}: Gen{}x{:<2}", "(DPM, Max)", max.gen, max.width);
println!("{PCIE_LABEL} {:PCIE_LEN$}: Gen{}x{:<2}", "(DPM, Max)", max.r#gen, max.width);
}

for (link, label) in [
(&sensors.max_gpu_link, "(GPU, Max)"),
(&sensors.max_system_link, "(System, Max)"),
] {
let Some(link) = link else { continue };
println!("{PCIE_LABEL} {label:PCIE_LEN$}: Gen{}x{:<2}", link.gen, link.width);
println!("{PCIE_LABEL} {label:PCIE_LEN$}: Gen{}x{:<2}", link.r#gen, link.width);
}
}

Expand Down

0 comments on commit 18629dd

Please sign in to comment.