Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit b777ece

Browse files
committed
Make extensive a field rather than enum variant
1 parent fd7592e commit b777ece

File tree

6 files changed

+31
-23
lines changed

6 files changed

+31
-23
lines changed

crates/libm-test/benches/icount.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ macro_rules! icount_benches {
2020
let mut ctx = CheckCtx::new(
2121
Op::IDENTIFIER,
2222
CheckBasis::None,
23-
GeneratorKind::QuickSpaced
23+
GeneratorKind::Spaced
2424
);
2525
ctx.override_iterations(BENCH_ITER_ITEMS);
2626
let ret = spaced::get_test_cases::<Op>(&ctx).0.collect::<Vec<_>>();

crates/libm-test/examples/plot_domains.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ where
5555
Op: MathOp<FTy = f32, RustArgs = (f32,)>,
5656
Op::RustArgs: SpacedInput<Op>,
5757
{
58-
let mut ctx = CheckCtx::new(Op::IDENTIFIER, CheckBasis::Mpfr, GeneratorKind::QuickSpaced);
58+
let mut ctx = CheckCtx::new(Op::IDENTIFIER, CheckBasis::Mpfr, GeneratorKind::Spaced);
5959
plot_one_generator(out_dir, &ctx, "logspace", config, spaced::get_test_cases::<Op>(&ctx).0);
6060
ctx.gen_kind = GeneratorKind::EdgeCases;
6161
plot_one_generator(

crates/libm-test/src/run_cfg.rs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ static EXTENSIVE_ITER_OVERRIDE: LazyLock<Option<u64>> = LazyLock::new(|| {
2121
/// Specific tests that need to have a reduced amount of iterations to complete in a reasonable
2222
/// amount of time.
2323
///
24-
/// Contains the itentifier+generator combo to match on, plus the factor to reduce by.
25-
const EXTEMELY_SLOW_TESTS: &[(Identifier, GeneratorKind, u64)] = &[
26-
(Identifier::Fmodf128, GeneratorKind::QuickSpaced, 40),
27-
(Identifier::Fmodf128, GeneratorKind::Extensive, 40),
24+
/// Contains the itentifier+generator+exhaustive combo to match on, plus the factor to reduce by.
25+
const EXTEMELY_SLOW_TESTS: &[(Identifier, GeneratorKind, bool, u64)] = &[
26+
(Identifier::Fmodf128, GeneratorKind::Spaced, false, 40),
27+
(Identifier::Fmodf128, GeneratorKind::Spaced, true, 40),
2828
];
2929

3030
/// Maximum number of iterations to run for a single routine.
@@ -52,6 +52,7 @@ pub struct CheckCtx {
5252
/// Source of truth for tests.
5353
pub basis: CheckBasis,
5454
pub gen_kind: GeneratorKind,
55+
pub extensive: bool,
5556
/// If specified, this value will override the value returned by [`iteration_count`].
5657
pub override_iterations: Option<u64>,
5758
}
@@ -67,12 +68,19 @@ impl CheckCtx {
6768
base_name_str: fn_ident.base_name().as_str(),
6869
basis,
6970
gen_kind,
71+
extensive: false,
7072
override_iterations: None,
7173
};
7274
ret.ulp = crate::default_ulp(&ret);
7375
ret
7476
}
7577

78+
/// Configure that this is an extensive test.
79+
pub fn extensive(mut self, extensive: bool) -> Self {
80+
self.extensive = extensive;
81+
self
82+
}
83+
7684
/// The number of input arguments for this function.
7785
pub fn input_count(&self) -> usize {
7886
self.fn_ident.math_op().rust_sig.args.len()
@@ -99,8 +107,7 @@ pub enum CheckBasis {
99107
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
100108
pub enum GeneratorKind {
101109
EdgeCases,
102-
Extensive,
103-
QuickSpaced,
110+
Spaced,
104111
Random,
105112
}
106113

@@ -216,21 +223,22 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
216223
let random_iter_count = domain_iter_count / 100;
217224

218225
let mut total_iterations = match ctx.gen_kind {
219-
GeneratorKind::QuickSpaced => domain_iter_count,
226+
GeneratorKind::Spaced if ctx.extensive => extensive_max_iterations(),
227+
GeneratorKind::Spaced => domain_iter_count,
220228
GeneratorKind::Random => random_iter_count,
221-
GeneratorKind::Extensive => extensive_max_iterations(),
222229
GeneratorKind::EdgeCases => {
223230
unimplemented!("edge case tests shoudn't need `iteration_count`")
224231
}
225232
};
226233

227234
// Some tests are significantly slower than others and need to be further reduced.
228-
if let Some((_id, _gen, scale)) = EXTEMELY_SLOW_TESTS
229-
.iter()
230-
.find(|(id, gen, _scale)| *id == ctx.fn_ident && *gen == ctx.gen_kind)
235+
if let Some((_id, _gen, _extensive, scale)) =
236+
EXTEMELY_SLOW_TESTS.iter().find(|(id, gen, extensive, _scale)| {
237+
*id == ctx.fn_ident && *gen == ctx.gen_kind && *extensive == ctx.extensive
238+
})
231239
{
232240
// However, do not override if the extensive iteration count has been manually set.
233-
if !(ctx.gen_kind == GeneratorKind::Extensive && EXTENSIVE_ITER_OVERRIDE.is_some()) {
241+
if !(ctx.extensive && EXTENSIVE_ITER_OVERRIDE.is_some()) {
234242
total_iterations /= scale;
235243
}
236244
}
@@ -265,7 +273,7 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
265273
let total = ntests.pow(t_env.input_count.try_into().unwrap());
266274

267275
let seed_msg = match ctx.gen_kind {
268-
GeneratorKind::QuickSpaced | GeneratorKind::Extensive => String::new(),
276+
GeneratorKind::Spaced => String::new(),
269277
GeneratorKind::Random => {
270278
format!(" using `{SEED_ENV}={}`", str::from_utf8(SEED.as_slice()).unwrap())
271279
}
@@ -307,8 +315,8 @@ pub fn int_range(ctx: &CheckCtx, argnum: usize) -> RangeInclusive<i32> {
307315
let extensive_range = (-0xfff)..=0xfffff;
308316

309317
match ctx.gen_kind {
310-
GeneratorKind::Extensive => extensive_range,
311-
GeneratorKind::QuickSpaced | GeneratorKind::Random => non_extensive_range,
318+
_ if ctx.extensive => extensive_range,
319+
GeneratorKind::Spaced | GeneratorKind::Random => non_extensive_range,
312320
GeneratorKind::EdgeCases => extensive_range,
313321
}
314322
}

crates/libm-test/tests/compare_built_musl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ macro_rules! musl_tests {
5454

5555
#[test]
5656
$(#[$attr])*
57-
fn [< musl_quickspace_ $fn_name >]() {
57+
fn [< musl_logspace_ $fn_name >]() {
5858
type Op = libm_test::op::$fn_name::Routine;
59-
let ctx = CheckCtx::new(Op::IDENTIFIER, BASIS, GeneratorKind::QuickSpaced);
59+
let ctx = CheckCtx::new(Op::IDENTIFIER, BASIS, GeneratorKind::Spaced);
6060
let cases = spaced::get_test_cases::<Op>(&ctx).0;
6161
musl_runner::<Op>(&ctx, cases, musl_math_sys::$fn_name);
6262
}

crates/libm-test/tests/multiprecision.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ macro_rules! mp_tests {
4444

4545
#[test]
4646
$(#[$attr])*
47-
fn [< mp_quickspace_ $fn_name >]() {
47+
fn [< mp_logspace_ $fn_name >]() {
4848
type Op = libm_test::op::$fn_name::Routine;
49-
let ctx = CheckCtx::new(Op::IDENTIFIER, BASIS, GeneratorKind::QuickSpaced);
49+
let ctx = CheckCtx::new(Op::IDENTIFIER, BASIS, GeneratorKind::Spaced);
5050
let cases = spaced::get_test_cases::<Op>(&ctx).0;
5151
mp_runner::<Op>(&ctx, cases);
5252
}

crates/libm-test/tests/z_extensive/run.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rayon::prelude::*;
1717
use spaced::SpacedInput;
1818

1919
const BASIS: CheckBasis = CheckBasis::Mpfr;
20-
const GEN_KIND: GeneratorKind = GeneratorKind::Extensive;
20+
const GEN_KIND: GeneratorKind = GeneratorKind::Spaced;
2121

2222
/// Run the extensive test suite.
2323
pub fn run() {
@@ -70,7 +70,7 @@ where
7070
Op::RustArgs: SpacedInput<Op> + Send,
7171
{
7272
let test_name = format!("mp_extensive_{}", Op::NAME);
73-
let ctx = CheckCtx::new(Op::IDENTIFIER, BASIS, GEN_KIND);
73+
let ctx = CheckCtx::new(Op::IDENTIFIER, BASIS, GEN_KIND).extensive(true);
7474
let skip = skip_extensive_test(&ctx);
7575

7676
let runner = move || {

0 commit comments

Comments
 (0)