From 2ca184f14810ac9951be4edfe65477ed196bcb0a Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 14 Jan 2025 11:17:34 +0000 Subject: [PATCH] inference --- crates/libm-test/benches/icount.rs | 2 +- crates/libm-test/src/run_cfg.rs | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/libm-test/benches/icount.rs b/crates/libm-test/benches/icount.rs index 1fd1e13d..a74409de 100644 --- a/crates/libm-test/benches/icount.rs +++ b/crates/libm-test/benches/icount.rs @@ -19,7 +19,7 @@ macro_rules! icount_benches { CheckBasis::None, GeneratorKind::QuickSpaced ); - ctx.override_ntests(BENCH_ITER_ITEMS); + ctx.override_iterations(BENCH_ITER_ITEMS); let ret = spaced::get_test_cases::(&ctx).0.collect::>(); println!("operation {}, {} steps", Op::NAME, ret.len()); ret diff --git a/crates/libm-test/src/run_cfg.rs b/crates/libm-test/src/run_cfg.rs index 236e5791..a22087dc 100644 --- a/crates/libm-test/src/run_cfg.rs +++ b/crates/libm-test/src/run_cfg.rs @@ -41,7 +41,7 @@ pub struct CheckCtx { pub basis: CheckBasis, pub gen_kind: GeneratorKind, /// If specified, this value will override the value returned by [`iteration_count`]. - pub override_ntests: Option, + pub override_iterations: Option, } impl CheckCtx { @@ -55,7 +55,7 @@ impl CheckCtx { base_name_str: fn_ident.base_name().as_str(), basis, gen_kind, - override_ntests: None, + override_iterations: None, }; ret.ulp = crate::default_ulp(&ret); ret @@ -65,8 +65,8 @@ impl CheckCtx { self.fn_ident.math_op().rust_sig.args.len() } - pub fn override_ntests(&mut self, count: u64) { - self.override_ntests = Some(count) + pub fn override_iterations(&mut self, count: u64) { + self.override_iterations = Some(count) } } @@ -224,20 +224,20 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 { total_iterations = 800; } + let mut overridden = false; + if let Some(count) = ctx.override_iterations { + total_iterations = count; + overridden = true; + } + // Adjust for the number of inputs - let mut ntests = match t_env.input_count { + let ntests = match t_env.input_count { 1 => total_iterations, 2 => (total_iterations as f64).sqrt().ceil() as u64, 3 => (total_iterations as f64).cbrt().ceil() as u64, _ => panic!("test has more than three arguments"), }; - let mut overridden = false; - if let Some(count) = ctx.override_ntests { - ntests = count; - overridden = true; - } - let total = ntests.pow(t_env.input_count.try_into().unwrap()); let seed_msg = match ctx.gen_kind {