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