@@ -13,18 +13,26 @@ pub const EXTENSIVE_ENV: &str = "LIBM_EXTENSIVE_TESTS";
13
13
/// Specify the number of iterations via this environment variable, rather than using the default.
14
14
pub const EXTENSIVE_ITER_ENV : & str = "LIBM_EXTENSIVE_ITERATIONS" ;
15
15
16
+ /// The override value, if set by the above environment.
17
+ static EXTENSIVE_ITER_OVERRIDE : LazyLock < Option < u64 > > = LazyLock :: new ( || {
18
+ env:: var ( EXTENSIVE_ITER_ENV ) . map ( |v| v. parse ( ) . expect ( "failed to parse iteration count" ) ) . ok ( )
19
+ } ) ;
20
+
21
+ /// Specific tests that need to have a reduced amount of iterations to complete in a reasonable
22
+ /// amount of time. Contains the itentifier+generator combo to match on, plus the factor to
23
+ /// reduce by.
24
+ const EXTEMELY_SLOW_TESTS : & [ ( Identifier , Option < GeneratorKind > ) ] = & [ ] ;
25
+
16
26
/// Maximum number of iterations to run for a single routine.
17
27
///
18
28
/// The default value of one greater than `u32::MAX` allows testing single-argument `f32` routines
19
29
/// and single- or double-argument `f16` routines exhaustively. `f64` and `f128` can't feasibly
20
30
/// be tested exhaustively; however, [`EXTENSIVE_ITER_ENV`] can be set to run tests for multiple
21
31
/// hours.
22
- pub static EXTENSIVE_MAX_ITERATIONS : LazyLock < u64 > = LazyLock :: new ( || {
23
- let default = 1 << 32 ;
24
- env:: var ( EXTENSIVE_ITER_ENV )
25
- . map ( |v| v. parse ( ) . expect ( "failed to parse iteration count" ) )
26
- . unwrap_or ( default)
27
- } ) ;
32
+ pub fn extensive_max_iterations ( ) -> u64 {
33
+ let default = 1 << 32 ; // default value
34
+ EXTENSIVE_ITER_OVERRIDE . unwrap_or ( default)
35
+ }
28
36
29
37
/// Context passed to [`CheckOutput`].
30
38
#[ derive( Clone , Debug , PartialEq , Eq ) ]
@@ -206,12 +214,23 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
206
214
let mut total_iterations = match ctx. gen_kind {
207
215
GeneratorKind :: QuickSpaced => domain_iter_count,
208
216
GeneratorKind :: Random => random_iter_count,
209
- GeneratorKind :: Extensive => * EXTENSIVE_MAX_ITERATIONS ,
217
+ GeneratorKind :: Extensive => extensive_max_iterations ( ) ,
210
218
GeneratorKind :: EdgeCases => {
211
219
unimplemented ! ( "edge case tests shoudn't need `iteration_count`" )
212
220
}
213
221
} ;
214
222
223
+ // Some tests are significantly slower than others and need to be further reduced.
224
+ if let Some ( ( _id, _gen, scale) ) = EXTEMELY_SLOW_TESTS
225
+ . iter ( )
226
+ . find ( |( id, gen, _scale) | * id == ctx. fn_ident && * gen == ctx. gen_kind )
227
+ {
228
+ // However, do not override if the extensive iteration count has been manually set.
229
+ if !( ctx. gen_kind == GeneratorKind :: Extensive && EXTENSIVE_ITER_OVERRIDE . is_none ( ) ) {
230
+ total_iterations /= scale;
231
+ }
232
+ }
233
+
215
234
// FMA has a huge domain but is reasonably fast to run, so increase iterations.
216
235
if ctx. base_name == BaseName :: Fma {
217
236
total_iterations *= 4 ;
0 commit comments