Skip to content

Commit

Permalink
update mostly adds logging
Browse files Browse the repository at this point in the history
  • Loading branch information
arcnmx committed Oct 25, 2017
1 parent 1f4d452 commit bf7a7bd
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nvoclock"
version = "0.0.1"
version = "0.0.2"
authors = ["arcnmx"]

description = "NVIDIA overclocking CLI"
Expand All @@ -13,15 +13,17 @@ license = "MIT"

[profile.dev]
panic = "abort"
[profile.release]
panic = "abort"
[profile.test]
panic = "abort"
[profile.bench]
panic = "abort"
[profile.release]
panic = "abort"
opt-level = 2
lto = true

[dependencies]
nvapi-hi = { version = "0.0.2", features = ["serde_types"] }
nvapi-hi = { version = "0.0.3", features = ["serde_types"] }
clap = { version = "2.26.2", default-features = false }
prettytable-rs = { version = "0.6.7", default-features = false }
quick-error = "1.2.1"
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ of a modern overclocking tool:
- `-g 0` flag can be used to filter results and operations to a specific GPU
- `-O json` prints out information in JSON format to be parsed or handled by
automated scripts.
- `set RUST_LOG=trace` to get excessive debugging information. You'll probably
want to use `nvoclock info 2> nvolog.txt` to save to a file for later
interpretation.

## Future Items

Expand Down
6 changes: 3 additions & 3 deletions src/human.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn n_a() -> String {
}

pub fn print_settings(set: &GpuSettings) {
if let Ok(ref boost) = set.voltage_boost {
if let Some(ref boost) = set.voltage_boost {
pline!("Voltage Boost", "{}", boost);
}
for limit in &set.sensor_limits {
Expand Down Expand Up @@ -85,7 +85,7 @@ pub fn print_status(status: &GpuStatus) {
status.memory.dedicated_available,
status.memory.dedicated_evictions, status.memory.dedicated_evictions_size,
);
pline!("Core Voltage", "{}", status.voltage.map(|v| v.to_string()).ok().unwrap_or_else(n_a));
pline!("Core Voltage", "{}", status.voltage.map(|v| v.to_string()).unwrap_or_else(n_a));
pline!("Limits", "{}",
status.perf.limits.fold(None, |state, v| if let Some(state) = state {
Some(format!("{}, {}", state, v))
Expand Down Expand Up @@ -120,7 +120,7 @@ pub fn print_status(status: &GpuStatus) {
},
CoolerControl::Variable => entry.level.to_string(),
};
let tach = status.tachometer.as_ref().ok()
let tach = status.tachometer.as_ref()
.and_then(|&t| if i == 0 { Some(format!(" ({} RPM)", t)) } else { None })
.unwrap_or_else(|| String::new());
pline!(format!("Cooler {}", cooler.kind), "{}{}", level, tach);
Expand Down
19 changes: 10 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,21 +432,21 @@ fn main_result() -> Result<i32, Error> {
if show_coolers {
human::print_coolers(
status.coolers.iter().map(|&(ref desc, ref cooler)| (desc, cooler)),
status.tachometer.ok()
status.tachometer
);
}

if show_vfp {
let vfp = status.vfp.as_ref()?;
let vfp_deltas = set.vfp.as_ref()?;
let vfp = status.vfp.as_ref().ok_or(Status::NotSupported)?;
let vfp_deltas = set.vfp.as_ref().ok_or(Status::NotSupported)?;
let lock = set.vfp_locks.iter().map(|(_, e)| e)
.filter(|&e| e.mode == ClockLockMode::Manual).map(|e| e.voltage).max();
human::print_vfp(vfp.graphics.iter().zip(vfp_deltas.graphics.iter())
.map(|((i0, p), (i1, d))| {
assert_eq!(i0, i1);
(*i0, VfPoint::new(p.clone(), d.clone()))
}),
lock, status.voltage.ok()
lock, status.voltage
);
}

Expand Down Expand Up @@ -609,7 +609,8 @@ fn main_result() -> Result<i32, Error> {
let status = gpu.status()?;
let settings = gpu.settings()?;

let points = status.vfp?.graphics.into_iter().zip(settings.vfp?.graphics.into_iter())
let points = status.vfp.ok_or(Status::NotSupported)?.graphics
.into_iter().zip(settings.vfp.ok_or(Status::NotSupported)?.graphics.into_iter())
.map(|((i0, point), (i1, delta))| {
assert_eq!(i0, i1);
VfPoint::new(point, delta)
Expand All @@ -627,7 +628,7 @@ fn main_result() -> Result<i32, Error> {
let input = matches.value_of("input").unwrap();

let status = gpu.status()?;
let vfp = status.vfp?.graphics;
let vfp = status.vfp.ok_or(Status::NotSupported)?.graphics;

fn import<R: io::Read>(read: R, delimiter: u8) -> Result<Vec<VfPoint>, csv::Error> {
let mut csv = csv::ReaderBuilder::new().delimiter(delimiter).from_reader(read);
Expand Down Expand Up @@ -659,7 +660,7 @@ fn main_result() -> Result<i32, Error> {
let v = if matches.is_present("voltage") {
Microvolts(point)
} else {
gpu.status()?.vfp?.graphics.get(&(point as usize))
gpu.status()?.vfp.ok_or(Status::NotSupported)?.graphics.get(&(point as usize))
.ok_or(Error::Str("invalid point index"))?
.voltage
};
Expand All @@ -681,9 +682,9 @@ fn main_result() -> Result<i32, Error> {
let max = matches.value_of("max").map(u32::from_str).unwrap()?;

let status = gpu.status()?;
let vfp = status.vfp?;
let vfp = status.vfp.ok_or(Status::NotSupported)?;
let settings = gpu.settings()?;
let vfp_delta = settings.vfp?;
let vfp_delta = settings.vfp.ok_or(Status::NotSupported)?;
let end = end.unwrap_or(vfp.graphics.iter().map(|(&i, _)| i).max().unwrap());

let options = auto::AutoDetectOptions {
Expand Down

0 comments on commit bf7a7bd

Please sign in to comment.