Skip to content

Commit f790449

Browse files
committed
Scale test iteration count at a later point
Currently the argument multiplier and large float multiplier happen before selecting count based on generator. However, this means that bivariate and trivariate functions don't get scaled at all (except for the special cased fma). Move this scaling to a later point.
1 parent 72d0f00 commit f790449

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

libm/crates/libm-test/src/run_cfg.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ static EXTENSIVE_ITER_OVERRIDE: LazyLock<Option<u64>> = LazyLock::new(|| {
2323
///
2424
/// Contains the itentifier+generator combo to match on, plus the factor to reduce by.
2525
const EXTEMELY_SLOW_TESTS: &[(Identifier, GeneratorKind, u64)] = &[
26-
(Identifier::Fmodf128, GeneratorKind::QuickSpaced, 40),
27-
(Identifier::Fmodf128, GeneratorKind::Extensive, 40),
26+
(Identifier::Fmodf128, GeneratorKind::QuickSpaced, 50),
27+
(Identifier::Fmodf128, GeneratorKind::Extensive, 50),
2828
];
2929

3030
/// Maximum number of iterations to run for a single routine.
@@ -200,15 +200,6 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
200200
domain_iter_count = 100_000;
201201
}
202202

203-
// Larger float types get more iterations.
204-
if t_env.large_float_ty {
205-
domain_iter_count *= 4;
206-
}
207-
208-
// Functions with more arguments get more iterations.
209-
let arg_multiplier = 1 << (t_env.input_count - 1);
210-
domain_iter_count *= arg_multiplier;
211-
212203
// If we will be running tests against MPFR, we don't need to test as much against musl.
213204
// However, there are some platforms where we have to test against musl since MPFR can't be
214205
// built.
@@ -228,6 +219,25 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
228219
}
229220
};
230221

222+
// Larger float types get more iterations.
223+
if t_env.large_float_ty && ctx.gen_kind != GeneratorKind::Extensive {
224+
if ctx.gen_kind == GeneratorKind::Extensive {
225+
// Extensive already has a pretty high test count.
226+
total_iterations *= 2;
227+
} else {
228+
total_iterations *= 4;
229+
}
230+
}
231+
232+
// Functions with more arguments get more iterations.
233+
let arg_multiplier = 1 << (t_env.input_count - 1);
234+
total_iterations *= arg_multiplier;
235+
236+
// FMA has a huge domain but is reasonably fast to run, so increase another 1.5x.
237+
if ctx.base_name == BaseName::Fma {
238+
total_iterations = 3 * total_iterations / 2;
239+
}
240+
231241
// Some tests are significantly slower than others and need to be further reduced.
232242
if let Some((_id, _gen, scale)) = EXTEMELY_SLOW_TESTS
233243
.iter()
@@ -239,11 +249,6 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
239249
}
240250
}
241251

242-
// FMA has a huge domain but is reasonably fast to run, so increase iterations.
243-
if ctx.base_name == BaseName::Fma {
244-
total_iterations *= 4;
245-
}
246-
247252
if cfg!(optimizations_enabled) {
248253
// Always run at least 10,000 tests.
249254
total_iterations = total_iterations.max(10_000);

0 commit comments

Comments
 (0)