@@ -13,18 +13,30 @@ pub const EXTENSIVE_ENV: &str = "LIBM_EXTENSIVE_TESTS";
1313/// Specify the number of iterations via this environment variable, rather than using the default.
1414pub const EXTENSIVE_ITER_ENV : & str = "LIBM_EXTENSIVE_ITERATIONS" ;
1515
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+
1630/// Maximum number of iterations to run for a single routine.
1731///
1832/// The default value of one greater than `u32::MAX` allows testing single-argument `f32` routines
1933/// and single- or double-argument `f16` routines exhaustively. `f64` and `f128` can't feasibly
2034/// be tested exhaustively; however, [`EXTENSIVE_ITER_ENV`] can be set to run tests for multiple
2135/// 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+ }
2840
2941/// Context passed to [`CheckOutput`].
3042#[ derive( Clone , Debug , PartialEq , Eq ) ]
@@ -206,12 +218,23 @@ pub fn iteration_count(ctx: &CheckCtx, argnum: usize) -> u64 {
206218 let mut total_iterations = match ctx. gen_kind {
207219 GeneratorKind :: QuickSpaced => domain_iter_count,
208220 GeneratorKind :: Random => random_iter_count,
209- GeneratorKind :: Extensive => * EXTENSIVE_MAX_ITERATIONS ,
221+ GeneratorKind :: Extensive => extensive_max_iterations ( ) ,
210222 GeneratorKind :: EdgeCases => {
211223 unimplemented ! ( "edge case tests shoudn't need `iteration_count`" )
212224 }
213225 } ;
214226
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+
215238 // FMA has a huge domain but is reasonably fast to run, so increase iterations.
216239 if ctx. base_name == BaseName :: Fma {
217240 total_iterations *= 4 ;
0 commit comments