@@ -13,18 +13,30 @@ 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.
23
+ ///
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 ) ,
28
+ ] ;
29
+
16
30
/// Maximum number of iterations to run for a single routine.
17
31
///
18
32
/// The default value of one greater than `u32::MAX` allows testing single-argument `f32` routines
19
33
/// and single- or double-argument `f16` routines exhaustively. `f64` and `f128` can't feasibly
20
34
/// be tested exhaustively; however, [`EXTENSIVE_ITER_ENV`] can be set to run tests for multiple
21
35
/// 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
- } ) ;
36
+ pub fn extensive_max_iterations ( ) -> u64 {
37
+ let default = 1 << 32 ; // default value
38
+ EXTENSIVE_ITER_OVERRIDE . unwrap_or ( default)
39
+ }
28
40
29
41
/// Context passed to [`CheckOutput`].
30
42
#[ derive( Clone , Debug , PartialEq , Eq ) ]
@@ -206,12 +218,23 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
206
218
let mut total_iterations = match ctx. gen_kind {
207
219
GeneratorKind :: QuickSpaced => domain_iter_count,
208
220
GeneratorKind :: Random => random_iter_count,
209
- GeneratorKind :: Extensive => * EXTENSIVE_MAX_ITERATIONS ,
221
+ GeneratorKind :: Extensive => extensive_max_iterations ( ) ,
210
222
GeneratorKind :: EdgeCases => {
211
223
unimplemented ! ( "edge case tests shoudn't need `iteration_count`" )
212
224
}
213
225
} ;
214
226
227
+ // 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 )
231
+ {
232
+ // 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 ( ) ) {
234
+ total_iterations /= scale;
235
+ }
236
+ }
237
+
215
238
// FMA has a huge domain but is reasonably fast to run, so increase iterations.
216
239
if ctx. base_name == BaseName :: Fma {
217
240
total_iterations *= 4 ;
0 commit comments