Implement ppt default (when enabled) value in UI

This commit is contained in:
NGnius (Graham) 2024-02-17 09:37:10 -05:00
parent fb038665c9
commit 808ce76eee
8 changed files with 39 additions and 8 deletions

View file

@ -51,7 +51,9 @@ pub struct GeneralLimits {}
#[derive(Serialize, Deserialize)]
pub struct GpuLimits {
pub fast_ppt_limits: Option<RangeLimit<u64>>,
pub fast_ppt_default: u64,
pub slow_ppt_limits: Option<RangeLimit<u64>>,
pub slow_ppt_default: u64,
pub ppt_step: u64,
pub tdp_limits: Option<RangeLimit<u64>>,
pub tdp_boost_limits: Option<RangeLimit<u64>>,

View file

@ -99,15 +99,17 @@ impl TGpu for Gpu {
log::debug!("dev_mode_Gpu::limits(self) -> {{...}}");
let ppt_divisor = self.limits.ppt_divisor.unwrap_or(1_000_000);
let tdp_divisor = self.limits.tdp_divisor.unwrap_or(1_000_000);
crate::api::GpuLimits {
let limit_struct = crate::api::GpuLimits {
fast_ppt_limits: self.limits.fast_ppt.map(|lim| crate::api::RangeLimit {
min: lim.min.unwrap_or(11_000_000) / ppt_divisor,
max: lim.max.unwrap_or(42_000_000) / ppt_divisor,
}),
fast_ppt_default: self.limits.fast_ppt_default.or_else(|| self.limits.fast_ppt.and_then(|x| x.max)).unwrap_or(2_000_000) / ppt_divisor,
slow_ppt_limits: self.limits.slow_ppt.map(|lim| crate::api::RangeLimit {
min: lim.min.unwrap_or(7_000_000) / ppt_divisor,
max: lim.max.unwrap_or(69_000_000) / ppt_divisor,
}),
slow_ppt_default: self.limits.slow_ppt_default.or_else(|| self.limits.slow_ppt.and_then(|x| x.max)).unwrap_or(3_000_000) / ppt_divisor,
ppt_step: self.limits.ppt_step.unwrap_or(1),
tdp_limits: self.limits.tdp.map(|lim| crate::api::RangeLimit {
min: lim.min.unwrap_or(11_000_000) / tdp_divisor,
@ -132,7 +134,9 @@ impl TGpu for Gpu {
max: lim.max.unwrap_or(1100),
}),
memory_step: self.limits.memory_clock_step.unwrap_or(400),
}
};
log::debug!("dev_mode_Gpu::limits(self) -> {}", serde_json::to_string_pretty(&limit_struct).unwrap());
limit_struct
}
fn json(&self) -> crate::persist::GpuJson {

View file

@ -167,6 +167,14 @@ impl TGpu for Gpu {
x
}
}),
fast_ppt_default: {
let def = self.limits.fast_ppt_default.or_else(|| self.limits.fast_ppt.and_then(|x| x.max)).unwrap_or(15);
if let Some(ppt_divisor) = self.limits.ppt_divisor {
def / ppt_divisor
} else {
def
}
},
slow_ppt_limits: self
.limits
.slow_ppt
@ -181,6 +189,14 @@ impl TGpu for Gpu {
x
}
}),
slow_ppt_default: {
let def = self.limits.slow_ppt_default.or_else(|| self.limits.slow_ppt.and_then(|x| x.max)).unwrap_or(15);
if let Some(ppt_divisor) = self.limits.ppt_divisor {
def / ppt_divisor
} else {
def
}
},
ppt_step: self.limits.ppt_step.unwrap_or(1),
tdp_limits: self
.limits

View file

@ -327,7 +327,9 @@ impl crate::settings::OnUnload for Gpu {
fn bad_gpu_limits() -> crate::api::GpuLimits {
crate::api::GpuLimits {
fast_ppt_limits: None,
fast_ppt_default: 1,
slow_ppt_limits: None,
slow_ppt_default: 1,
ppt_step: 1,
tdp_limits: None,
tdp_boost_limits: None,

View file

@ -638,19 +638,22 @@ impl crate::settings::OnUnload for Gpu {
impl TGpu for Gpu {
fn limits(&self) -> crate::api::GpuLimits {
let max_gpu_clock = self.read_max_gpu_clock();
let ppt_divisor = self.limits.ppt_divisor.unwrap_or(PPT_DIVISOR);
crate::api::GpuLimits {
fast_ppt_limits: Some(RangeLimit {
min: super::util::range_min_or_fallback(&self.limits.fast_ppt, MIN_FAST_PPT)
/ self.limits.ppt_divisor.unwrap_or(PPT_DIVISOR),
/ ppt_divisor,
max: super::util::range_max_or_fallback(&self.limits.fast_ppt, MAX_FAST_PPT)
/ self.limits.ppt_divisor.unwrap_or(PPT_DIVISOR),
/ ppt_divisor,
}),
fast_ppt_default: self.limits.fast_ppt_default.or_else(|| self.limits.fast_ppt.and_then(|x| x.max)).unwrap_or(MAX_FAST_PPT) / ppt_divisor,
slow_ppt_limits: Some(RangeLimit {
min: super::util::range_min_or_fallback(&self.limits.slow_ppt, MIN_SLOW_PPT)
/ self.limits.ppt_divisor.unwrap_or(PPT_DIVISOR),
/ ppt_divisor,
max: super::util::range_max_or_fallback(&self.limits.slow_ppt, MIN_SLOW_PPT)
/ self.limits.ppt_divisor.unwrap_or(PPT_DIVISOR),
/ ppt_divisor,
}),
slow_ppt_default: self.limits.slow_ppt_default.or_else(|| self.limits.slow_ppt.and_then(|x| x.max)).unwrap_or(MAX_SLOW_PPT) / ppt_divisor,
ppt_step: self.limits.ppt_step.unwrap_or(1),
tdp_limits: None,
tdp_boost_limits: None,

View file

@ -71,7 +71,9 @@ impl TGpu for Gpu {
fn limits(&self) -> crate::api::GpuLimits {
crate::api::GpuLimits {
fast_ppt_limits: None,
fast_ppt_default: 1_000_000,
slow_ppt_limits: None,
slow_ppt_default: 1_000_000,
ppt_step: 1_000_000,
tdp_limits: None,
tdp_boost_limits: None,

View file

@ -85,7 +85,9 @@ export type GeneralLimits = {};
export type GpuLimits = {
fast_ppt_limits: RangeLimit | null;
fast_ppt_default: number;
slow_ppt_limits: RangeLimit | null;
slow_ppt_default: number;
ppt_step: number;
clock_min_limits: RangeLimit | null;
clock_max_limits: RangeLimit | null;

View file

@ -41,11 +41,11 @@ export class Gpu extends Component<backend.IdcProps> {
onChange={(value: boolean) => {
if (value) {
if ((get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.slow_ppt_limits != null) {
set_value(SLOW_PPT_GPU, (get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.slow_ppt_limits!.max);
set_value(SLOW_PPT_GPU, (get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.slow_ppt_default);
}
if ((get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.fast_ppt_limits != null) {
set_value(FAST_PPT_GPU, (get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.fast_ppt_limits!.max);
set_value(FAST_PPT_GPU, (get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.fast_ppt_default);
}
reloadGUI("GPUPPTToggle");
} else {